lexer

How to parse multiple statements in sly?

How to parse multiple statements in sly? Question: I am trying to parse some code using sly. I would like to separate the statements with a semicolon. I have defined a token called SEMI which represents a semicolon: class MyLexer(Lexer): tokens = { …, SEMI } SEMI = r";" … If I use SEMI inside …

Total answers: 2

Antlr4 parse issues when changing lexer rule to parser rule| python

Antlr4 parse issues when changing lexer rule to parser rule| python Question: I am new to antlr, and I have been facing some issues when it comes to properly parsing the source code, this is my grammar: compilationUnit : (assignment | declarationList | definitionList)* EOF ; block : LC RC ; assignment: typeSpecifier? IDENTIFIER ‘=’ …

Total answers: 1

How do I iterate through a dictionary/set in SLY?

How do I iterate through a dictionary/set in SLY? Question: So, I’m trying to transition my code from my earlier PLY implementation to SLY. Previously, I had some code that loaded a binary file with a wide range of reserved words scraped from documentation of the scripting language I’m trying to implement. However, when I …

Total answers: 1

Proper way to handle ambiguous tokens in PLY

Proper way to handle ambiguous tokens in PLY Question: I am implementing an existing scripting language in part as a toy project and in part so that I can write my own implementation of the program that uses the language. One of the issues I’m running into is that I have a few constructs that …

Total answers: 1