Hi Folks
I am looking for an easy way to display the results of an Xtreams PEG parse visually for debugging/development/sanity purposes.
In the Xtreams evaluator callbacks, we can pick and choose what elements we want from an ordered collection via pragmas.
However, sometimes our grammars do not give us what we think they should.
In this case, visuallizing the parse tree (? correct term) in a graph would be helpful.
Graphviz ain't it afaikt, and I do not have the bandwidth to return to the Roassal work to accomplish this.
I did find this: https://ironcreek.net/syntaxtree/
And I am thinking I may get this to work in Seaside
So, given a PEG grammar rule...
PFStringReplaceTwoPipe <- '{{' "#replace:" PFStringReplaceFlow{'|'} PFStringReplaceFlow{'|'} PFStringReplaceFlow+ '}}'
and a test case...
input := '{{#replace:Foo|Foo | Bar}}'.
output := parser parse: 'PFStringReplaceTwoPipe' stream: input reading actor: actor.
self assert: (output = 'Foo').
In the "callback" for the grammar rule...
PFStringReplaceTwoPipe: anOrderedCollection
<action: 'PFStringReplaceTwoPipe' >
anOrderedCollection inspect.
^anOrderedCollection
I get a Collection that (Array in this case) that looks like this...
{{{ . '#replace:' . an OrderedCollection($F $o $o) . an OrderedCollection($F $o $o Character space) . an OrderedCollection(Character space $B $a $r) . }}}
Which I want to express in labelled bracket notation like this ....[S [NP jsSyntaxTree][VP [V creates][NP nice syntax trees ->1]]]... that I can feed to a Seaside app...
Ideas, suggestions much appreciated...I am guessing that there is a tree traversal algorithm that a good programmer would know that would do the job...
heck...I can just feed the Collection to Seaside and have it do the traversal on the output to create that notation that , hopefully, that JS thing can display.
thx in advance.
cordially
t
squeak-dev@lists.squeakfoundation.org