Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty bracket pairs properly tokenized #1439

Merged
merged 1 commit into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@ main reactor(@b parm: int) {
parseWithoutError(testCase);
}

@Test
public void testTokenizeEmptyWidth() throws Exception {
String testCase = """
target C;
main reactor {
state foo: int[];
state foo: int[ ]; //spaces are allowed
}
""";
parseWithoutError(testCase);
}

private Model parseWithoutError(String s) throws Exception {
Model model = parser.parse(s);
Assertions.assertNotNull(model);
Expand Down
10 changes: 5 additions & 5 deletions org.lflang/src/org/lflang/LinguaFranca.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ Type:
;

ArraySpec:
ofVariableLength?='[]' | '[' length=INT ']';
'[' ( ofVariableLength?=']' | length=INT ']' );

WidthSpec:
ofVariableLength?='[]' | '[' (terms+=WidthTerm) ('+' terms+=WidthTerm)* ']';
'[' ( ofVariableLength?=']' | (terms+=WidthTerm) ('+' terms+=WidthTerm)* ']' );

WidthTerm:
width=INT
| parameter=[Parameter]
Expand Down Expand Up @@ -502,7 +502,7 @@ Token:
// Braces
'(' | ')' | '{' | '}' |
// Brackets
'[' | ']' | '<' | '>' | '[]' |
'[' | ']' | '<' | '>' |
// Punctuation
':' | ';' | ',' | '.' | '::' |
// Slashes
Expand Down