sly

Trying to make assembly-level sly programming language

Trying to make assembly-level sly programming language Question: I’m trying to write a low-level parser using sly and python. However, when I run my code I get an error: syntax error: "1", at line 1 The code in question is: #!/bin/python3 from sly import Lexer, Parser class LowLexer(Lexer): tokens = {DAT, MOV, ADD, SUB, MUL, …

Total answers: 1

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

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

Is it possible to easily eliminate this reduce/reduce conflict?

Is it possible to easily eliminate this reduce/reduce conflict? Question: This is my code for if statements that might have elses or elsifs for the scripting language I’m writing a parser for. I’m actually rather proud of how compact I got it: @_( ‘IF LPAREN expr_comp RPAREN THEN NEWLINE statement_set { elsif_statement } ENDIF’, ‘IF …

Total answers: 2