ridencww / goldengine

Java implementation of Devin Cook's GOLD Parser engine
Other
35 stars 14 forks source link

Mismatch when compared between grammar builder parse tree & engine parse tree #12

Closed ashwinfernandes closed 9 years ago

ashwinfernandes commented 9 years ago

Hi @ridencww ,

When using this grammar with the builder & the engine, few of the reductions go missing in the tree with the engine parser. Could you please take a look at it. I'm using goldparser for the first time, so please let me know if there is something wrong in my grammar implementation or engine usage.

MANUFACTURER 252, DEVICE_TYPE 1, DEVICE_REVISION 1, DD_REVISION 1, MANUFACTURER_EXT "xyz"

BLOCK DeviceBlock { TYPE PHYSICAL; NUMBER 1; }

The grammar is for EDDL(Electronic device description language). The grammar implementation is as seen below.

"Name" = 'EDDL grammar' "Author" = 'Ashwin Jason Fernandes' "Version" = 'The version of the grammar and/or language' "About" = 'A short description of the grammar'

"Case Sensitive" = True "Start Symbol" =

{Hex Digit} = {Digit} + [abcdefABCDEF] {Oct Digit} = [01234567]

{String Ch} = {Printable} - ["]

{Id Head} = {Letter} + [_] {Id Tail} = {Id Head} + {Digit}

DecLiteral = [123456789]{digit}*
HexLiteral = 0X | 0x{Hex Digit}+ OctLiteral = 0{Oct Digit} FloatLiteral = {Digit}'.'{Digit}+

Id = {Id Head}{Id Tail}*

! =================================================================== ! Comments ! ===================================================================

Comment Start = '/' Comment End = '/' Comment Line = '//'

! ------------------------------------------------- ! Character Sets ! -------------------------------------------------

{String Chars} = {Printable} + {HT} - ["]

! ------------------------------------------------- ! Terminals ! -------------------------------------------------

!Identifier = {Letter}{AlphaNumeric} StringLiteral = '"' {String Chars}\ '"'

! ------------------------------------------------- ! Constants / Literals ! -------------------------------------------------

::= | StringLiteral ::= | FloatLiteral ::= DecLiteral | HexLiteral | OctLiteral ! ------------------------------------------------- ! Rules ! ------------------------------------------------- ! The grammar starts below ::= | | ! =================================================================== ! EDD Identification Declaration ! =================================================================== ::= ',' | ::= ::= MANUFACTURER | DEVICE_TYPE | DEVICE_REVISION | DD_REVISION | MANUFACTURER_EXT ::= | | | | | | ! =================================================================== ! Type Declaration ! =================================================================== ! =================================================================== ! Block Declaration ! =================================================================== ::= BLOCK Id '{' '}' ::= TYPE ';' | NUMBER';' | ::= PHYSICAL | TRANSDUCER | FUNCTION ! =================================================================== ! Variable Declaration ! =================================================================== ::= VARIABLE Id '{' '}' ::= | |
ashwinfernandes commented 9 years ago

Found out my mistake, i had enabled trimreduction & therefore it gave me an optimized tree.

Thanks, Ashwin