diff --git a/TODO b/TODO index 7129463..26418e0 100644 --- a/TODO +++ b/TODO @@ -1,23 +1,38 @@ -(-) common infrastructure (grammar structure) -(2) backend plug per parser type (not LALR/SLR, but *LR) -(3) simple first config file parser (only grammar?) -(4) complete config file grammar -(-) lexer -(6) driver (resolution of parser type + backend, input/output files) -(7) main (option parsing, calling driver) -(8) backend (LR, c++) -(9) table (LALR(1)) -(10) unit tests +T> Parser selection without enum (Thomas) (flexible matching (case insensitive, ...)) +R> Precedence resolution in generator +T> Parsodus regex parser in Lexesis + -> Vrijgeven in libraryformaat: mogelijkheid verschillende tokens opvragen +K> Parsodus Parsodus parser + -> Precedence + -> rule naming (problem: multiple rules same name -> change in backend) + -> grammar struct change to contain optional name per rule + -> Volgorde belangrijk? +-> Voorbeelden + R> JSON port? + -> brainfuck? bare bones? bash transpiler? + R> simple calculator + -> include in tests +-> Unit tests + -> LR(0) + -> SLR + -> LR(1) + -> LALR + #R 1 enkel LR(1) + #K 1 LR(1) + LALR(1) + #T 1 LR(0) + + -> Table generator (independent of specific tables)??? +-> presentation +R> README +R> man pages -ROBIN: 8, 9, 10 -THOMAS: 2, 3, 6, 10 -KOBE: 4, 7, 10 - -extras: - -> bash completion - -> more tables/backends - -> update lexesis parser - -> man pages - -> README +-> Error reporting +-> bash completion +-> bool specialization in backend? +-> publication / LICENSE +-> --- logging + -> write configuration sets, table + -> Generator: logging + -> driver/main: debug flag diff --git a/include/Parsodus/config.h b/include/Parsodus/config.h index 976c314..b96cea4 100644 --- a/include/Parsodus/config.h +++ b/include/Parsodus/config.h @@ -7,10 +7,17 @@ namespace pds { + enum class PrecedenceType { + LEFT, + RIGHT, + NONASSOC + }; + struct Config { util::ParserType parserType; std::string lexesisFile; Grammar grammar; + std::map > precedence; ///< lower value -> higher precedence }; } diff --git a/parser.example.pds b/parser.example.pds index 79a6999..0ec1569 100644 --- a/parser.example.pds +++ b/parser.example.pds @@ -1,12 +1,17 @@ parser: SLR(1) lexesis: lexer.lxs terminals: - TERMINAL -start: s + "A" + "B" + "C" + "D" +precedence: + left "A" "D" + nonassoc "B" + right "C" +start: grammar: - s -> a s - | b - ; - - a → TERMINAL; - b -> a; + ::= [startrule]; + ::= "A" [xA] + | "B" [xB] + ; diff --git a/src/parsodusLexer.lxs b/src/parsodusLexer.lxs index fb5e9c7..04d9e9c 100644 --- a/src/parsodusLexer.lxs +++ b/src/parsodusLexer.lxs @@ -10,10 +10,11 @@ RIGHT = right NONASSOC = nonassoc NUM = [1-9][0-9]* LEXESISNAME = [_a-zA-Z]+\.lxs -TERMINAL = [_A-Z]+ -VARIABLE = [_a-z]+ -ARROW = ->|→ +TERMINAL = "[_a-zA-Z]+" +VARIABLE = <[_a-zA-Z]+> +ARROW = ::= SEMICOLON = ; COLON = : PIPE = \| +RULENAME = \[[_a-zA-Z][_a-zA-Z0-9]*\] ignore = \t| |\n|\r