mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
parser: Tweak parsing during error conditions
When an explicit parsing error is encountered and a CompileError raised, apply the changes to the context state. This way, the rule that catches the exception (e.g. Statement or Until) knows where the error occurred. Also, changed "Expected" errors to be reported at the end of the previous non-whitespace token.
This commit is contained in:
parent
e5d6910626
commit
8f3ae9a626
10 changed files with 69 additions and 37 deletions
|
@ -1 +1 @@
|
|||
1,0,0,File must start with a "using Gtk" directive (e.g. `using Gtk 4.0;`)
|
||||
1,1,0,File must start with a "using Gtk" directive (e.g. `using Gtk 4.0;`)
|
|
@ -1 +1 @@
|
|||
6,1,1,Expected `;`
|
||||
5,4,0,Expected `;`
|
|
@ -1,2 +1 @@
|
|||
5,1,0,Expected a signal detail name
|
||||
4,9,3,Unexpected tokens
|
||||
4,11,0,Expected a signal detail name
|
|
@ -1,2 +1 @@
|
|||
4,5,21,Attributes are not permitted at the top level of a menu
|
||||
4,16,10,Unexpected tokens
|
||||
4,5,21,Attributes are not permitted at the top level of a menu
|
|
@ -1 +1 @@
|
|||
1,11,0,Expected a version number for GTK
|
||||
1,10,0,Expected a version number for GTK
|
||||
|
|
|
@ -143,9 +143,9 @@ class TestSamples(unittest.TestCase):
|
|||
]
|
||||
|
||||
def error_str(error: CompileError):
|
||||
line, col = utils.idx_to_pos(error.range.start + 1, blueprint)
|
||||
line, col = utils.idx_to_pos(error.range.start, blueprint)
|
||||
len = error.range.length
|
||||
return ",".join([str(line + 1), str(col), str(len), error.message])
|
||||
return ",".join([str(line + 1), str(col + 1), str(len), error.message])
|
||||
|
||||
actual = "\n".join([error_str(error) for error in errors])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue