Skip to content

mingodad/parsertl-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parsertl lexertl playground

A web based playground for https://github.com/BenHanson/parsertl14 and https://github.com/BenHanson/lexertl14 based on https://github.com/BenHanson/gram_grep .

The playground website is based on https://yhirose.github.io/cpp-peglib/ and also with modifications based on https://chrishixon.github.io/chpeg/playground/ .

The playground save the grammar and the input in the local storage when you click Parse.

The playground has the following main elements:

  • A select labeled Examples to choose one available example to start with.
  • A select labeled Generate to optionally export Yacc/EBNF (for railroad diagrams).
  • A button labeled Parse to build/execute the parser/grammar in the top left side editor over the input in the top right side editor.
  • A bottom right side area to display info about the grammar (errors are clickable links to jump to line in the editor).
  • A bottom left side area to display info about the input source parsing results (errors are clickabel to jump to line in the editor).
  • A center left side foldable read only editor to show debug info about lexing/parsing the grammar or the input.

The availabel debugging options are:

  • Input parse tree pruned
  • Input parse tree full
  • Input lexer dump
  • Input parse trace
  • Grammar parse tree pruned
  • Grammar parse tree full
  • Grammar lexer dump
  • Grammar parse trace
  • Grammar lexer state machine
  • Grammar parse state machine

This project can also be built as a command line tool (see build.sh) then you can use it to check grammar/input on your disc:

./parsertl-playground
usage: ./parsertl-playground [options] grammar_fname input_fname
options can be:
-dumpil        Dump input lexer
-dumpiptree    Dump input parser tree
-dumpiptrace   Dump input parser trace
-dumpgl        Dump grammar lexer
-dumpgptree    Dump grammar parser tree
-dumpgptrace   Dump grammar parser trace
-dumpglsm      Dump grammar lexer state machine
-dumpgsm       Dump grammar parser state machine
-dumpAsEbnfRR  Dump grammar as EBNF for railroad diagram
-dumpAsYacc    Dump grammar as Yacc
-pruneptree    Do not show empty parser tree nodes
-verbose       Show several metrics for debug

The grammar used internally to parse the user grammar is this one playground-master.g the grammar has 4 sections:

/*Grammar header*/
%%
/*Grammar rules*/
%%
/*Lex header*/
%%
/*Lex rules*/
%%

The first two sections are equivalent to yacc/bison format and the other two sections are equivalent to lex/flex format.

Related projects: