On Wed, Nov 10, 2010 at 10:24 PM, Shaping <shap...@charter.net> wrote: > > Doing the immediate eval leaves
What is an 'immediate eval'? I ask because the following should only come from a <EBNF ... EBNF> usage, not a EBNF: ... ;EBNF usage: > T{ parser f ~action-parser~ f 4820 } > How am I expected to use this notation?. I read: "a parser instance", > constant f (false), "something to do with a parse and its action", another > false constant, number 4820. I can't do any real thinking with that. Why > don't we have more informative print-strings for our Tuples/Objects? The structure is 'shortened' for printing by default. do a "dup ." to print it out fully. It may take a while as it's a deeply nested structure. Better might be to right click on it in the listener and choose 'inspect', or run the inspect word on it. > V{ ~vector~ ~vector~ } > > Again there is the opacity problem. What does the "~vector~" mean? And why > would I ever want to read such a general description of a 2-vector? It > doesn't say much about what is in the tree. Again it's a shorted print. Do the same as I mentioned above to see the complete contents. > How are the rule statements parsed? There are no periods between them. Periods are no longer needed. > The > EBNF parser must scan forward for the next "<nonterminal>=", to know where > the previous rule ends. Is this what is happening? Yes. > This one failed at the listener: > > "Generic word parse does not define a method for the parser class. Make sure it's using 'parse' from the 'peg' vocab and not from some other vocab. Do a USE: peg to make sure. > > V{ V{ "1" V{ "2" "3" } } V{ } } > > which I suppose is the parse tree for the last rule expr. Yes. > I don't understand the parsing of the rule syntax itself between [EBNF and > EBNF]. "digit=[0-9]" and "rule=digit+" are rules strings without > whitespace. What is happening with the in-between "=> [[ digit> ]]"? This > looks like Factor (for making a vector) not EBNF, or a mixture of both > (quotation and "one or more"). The last part of a rule can be "=> [[ ... ]]" which is an 'action'. The '...' can be any factor code. It can manipulate the parse tree and return a new parse tree. So "[0-9] => [[ digit> ]]" takes the parse tree from "[0-9]" (which is the character code of the number) and uses the factor word 'digit>' to convert that into a number. That number is left on the stack and becomes the parse tree result of the rule. Read the help for "peg.ebnf" and let me know if you have any further questions. In particular: http://docs.factorcode.org/content/article-peg.ebnf.action.html For more general stuff: http://docs.factorcode.org/content/article-peg.ebnf.html Chris. -- http://www.bluishcoder.co.nz ------------------------------------------------------------------------------ The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now! http://p.sf.net/sfu/SAP-dev2dev _______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk