I tried the first two yellow blocks in this article
http://www.bluishcoder.co.nz/2007/11/embedded-grammars-in-factor.html
The first block I put on a word, and it compiled. The next three evaluables
didn't not work. For example
"123" number parse
raised an exception
(U) Quotation: [ set-namestack init-catchstack self quot>> call -> stop ]
(O) Word: listener-thread
(O) Word: listener
(O) Word: (listener)
(U) Quotation: [
[ ~quotation~ dip swap ~quotation~ dip ] dip swap
[ call datastack ] dip -> swap [ set-datastack ] dip
]
(U) Quotation: [ call -> datastack ]
(O) Method: M\ object parse
(O) Word: no-method
(O) Method: M\ object throw
(U) Quotation: [
63 special-object error-thread set-global
continuation -> error-continuation set-global
[ original-error set-global ] [ rethrow ] bi
]
Why have you color-coded the "parse" words in the HTML?
Shaping
-----Original Message-----
From: Chris Double [mailto:[email protected]]
Sent: 2010-November-09, 02:57
To: [email protected]
Subject: Re: [Factor-talk] Furnace, XStreams (PEGs) and some observations
about Factor
On Tue, Nov 9, 2010 at 9:38 PM, Shaping <[email protected]> wrote:
> I need to be able to write a parser in a
> straightforward way (XStreams-style maybe) using a PEG (collection of BNF
> productions) so that I can experiment efficiently with this idea. Does
> anyone have any experience with PEGs in Factor?
Read the help for peg.ebnf. You can do this with the following in the
listener:
"peg.ebnf" about
Also these blog posts:
http://www.bluishcoder.co.nz/2007/11/embedded-grammars-in-factor.html
http://www.bluishcoder.co.nz/2008/04/factor-parsing-dsl.html
http://www.bluishcoder.co.nz/2008/06/parsing-javascript-with-factor.html
The code in them is slightly out of date but combined with the
peg.ebnf help you should be able to get the idea. There are a few
peg.ebnf usage examples for a JavaScript grammar, a PL0 grammar and an
expression calculator in the Factor source.
My PDF of articles might have more up to date code examples than the blog
posts:
http://www.bluishcoder.co.nz/factor-articles.pdf
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk