ANTLR4 Swift grammar cannot identify a for-in statement

22 views
Skip to first unread message

Roy Waxman

unread,
Nov 10, 2018, 5:09:40 PM11/10/18
to antlr-discussion

Hello,


I am using ANTLR4 to parse Swift code using the Swift grammar (or at least based on it) from GitHub.

The parser does not identify the for-in statement as a loop statement / for-in statement even if it was defined in the grammar. 

I am trying to understand why.


Thanks, Roy


I am attaching these files via OneDrive:


GameScene.swift


Swift.g4

Roy Waxman

unread,
Nov 13, 2018, 6:03:33 PM11/13/18
to antlr-discussion

Hello,


Upon further investigating i did found out the problem was that the parser was wrongly identifying the 'for' as a variable / regular identifier. 

So, i looked in GitHub swift grammar that they indeed separated the identifier to 2 types to avoid such things.

After i did that, the parser identified the for loop statement correctly...


Thanks


Bye

Reply all
Reply to author
Forward
0 new messages