Skip to content

Commit

Permalink
Merge pull request #1439 from lf-lang/tokenize-empty-width
Browse files Browse the repository at this point in the history
Tokenize empty bracket pairs properly
  • Loading branch information
lhstrh authored Nov 1, 2022
2 parents c58094e + 066596d commit d9095f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
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

0 comments on commit d9095f4

Please sign in to comment.