Re: [Pharo-users] Xtreams: Extending Bootstrap
Sean P. DeNigris wrote > - is there any specific reason that rules can't contain dashes? This seems > pretty common. Added by changing #grammrPEG from "Identifier <- [a-zA-Z_] [a-zA-Z0-9_]*" to "Identifier <- [a-zA-Z_] [a-zA-Z0-9_\-]*" Sean P. DeNigris wrote > - Why use <- instead of = to separate the rule name from the definition? > The standards I want to parse use the latter. Added by changing #grammrPEG from "ASSIGN <- "<-"" to "ASSIGN <- "<-" / "="" Both seem to be working well. - Cheers, Sean -- View this message in context: http://forum.world.st/Xtreams-Extending-Bootstrap-tp4902579p4903437.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Re: [Pharo-users] Xtreams: Extending Bootstrap
Sean P. DeNigris wrote > I wanted to extend the Xtream grammar to handle "/d97". Okay, I added to PEGParser class>>grammarPEG ... / BACKSLASH [d] [0-9]+ Sean P. DeNigris wrote > I extended PEGParserGenerator and PEGParserParser with the following: > Escape: backslash character: character hexes: hexes Duh, the above method is just the handler for the rule, akin to PetitParser's ==> block - Cheers, Sean -- View this message in context: http://forum.world.st/Xtreams-Extending-Bootstrap-tp4902579p4903436.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
Re: [Pharo-users] Xtreams: Extending Bootstrap
Sean P. DeNigris wrote > I wanted to extend the Xtream grammar to handle "/d97" I also wonder: - is there any specific reason that rules can't contain dashes? This seems pretty common. - Why use <- instead of = to separate the rule name from the definition? The standards I want to parse use the latter. - Cheers, Sean -- View this message in context: http://forum.world.st/Xtreams-Extending-Bootstrap-tp4902579p4902741.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
[Pharo-users] Xtreams: Extending Bootstrap
I copy-pasted the addr-spec grammar from rfc5322 and was converting it to Xtreams format. One PITA was converting all the decimal values to hex e.g. "%d97" -> "\x61". I wanted to extend the Xtream grammar to handle "/d97". I extended PEGParserGenerator and PEGParserParser with the following: Escape: backslash character: character hexes: hexes ... character = $d ifTrue: [^(String withAll: hexes) asNumber asCharacter] But I couldn't figure out how to put this extension into action. PEGParser>>parserBootstrap has a comment "This method was generated with the following code: PEGParser parserPEG parse: 'Grammar' stream: PEGParser grammarPEG actor: PEGParserGenerator new", but evaluating that after extending produced the same output as the original. What am I missing? Thanks. - Cheers, Sean -- View this message in context: http://forum.world.st/Xtreams-Extending-Bootstrap-tp4902579.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.