Parser: Don't parse everything as a component

The old parser always try first to find `Foo :=` from the old syntax so it
would error saying it expect an identifier or `:=`
But if we don't find a component, don't try to parse it as a component too early
This way we get better error and better auto-completions
This commit is contained in:
Olivier Goffart 2023-04-15 18:07:10 +02:00 committed by Olivier Goffart
parent 530fbf586c
commit ee9f730a6d
4 changed files with 10 additions and 4 deletions

View file

@ -2,4 +2,4 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
export -
// ^error{expected Identifier}
// ^error{Parse error: expected a top-level item such as a component, a struct, or a global}

View file

@ -7,4 +7,4 @@ export TestCase := Window {
// ^error{expected ':'}
// ^^error{Parse error}
}
//^error{expected Identifier}
//^error{Parse error: expected a top-level item such as a component, a struct, or a global}

View file

@ -14,7 +14,7 @@ export TestCase := Rectangle {
border: 42;
}
]
// ^error{expected Identifier}
// ^error{Parse error: expected a top-level item such as a component, a struct, or a global}
transitions [
in pressed: {