Skip to content

IWonderWhatThisAPIDoes/drawmealemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Draw Me a Lemon

Visualization of the execution of parsers made with the Lemon parser generator. A handy tool for debugging grammars, or just exploring how the parser generator works.

          INPUT || STACK
                ||--,
                || 0|
-> Begin        ||  |
    `-----------||  |--,
                ||  | 2|
-> One          ||  |  |
   |        ,-* ||  |  | lines ::=
   |      lines ||  |  |
   |        `---||  |  |--,
   |            ||  |  | 1|
    `-----------||  |  |  |--,
                ||  |  |  | 4|
-> Two          ||  |  |  |  |
    `-----------||  |  |  |  |--,
                ||  |  |  |  | 3|
-> Two          ||  |  |  |  |  |
   |        ,-* ||  |  |  |xx+xx+ Syntax error
   |      error ||  |  |  |
   |        `---||  |  |  |--,
   |            ||  |  |  | R|
   |        ,---||  |  |--+--` lines ::= lines line
   |      lines ||  |  |
   |        `---||  |  |--,
   |            ||  |  | 1|
   X            ||  |  |  | Syntax error
                ||  |  |  |
-> End          ||  |  |  |
    `-----------||  |  |  |--,
                ||  |  |  | R|
            ,---||  |--+--+--` block ::= Begin lines End
          block ||  |
            `---||  |--,
                ||  | 5|
-> $            ||  |  |
   |        ,---||  |--` start ::= block
   |      start ||  |
   X            ||--`
                || Accept!

Usage

./drawmealemon <grammarFile> [options] -- [tokensToParser]

grammarFile - Lemon grammar file that describes the parser

tokensToParser - Tokens sent to the parser in the sample session that will be visualized

Options

Flag Description
-h, --help Print the usage and exit
-t, --target Specify the output format (see below)
-o, --option Options that further customize the output format (see below)

Output Formats

-t ascii - Outputs an ASCII art of the parser's execution.

Option Description
-o iw=<n> Sets the width (in characters) of the left (input) column
-o utf8 Use utf-8 box drawing characters to render lines

Examples

./drawmealemon examples/grammar.lemon -tascii -oiw=16 -- Begin One Two Two End

About

Visualized execution of Lemon-based parsers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages