Work on PL/0 Grammar as a PEG example
parent
5fb6af754b
commit
ea2d4ea261
|
@ -0,0 +1 @@
|
|||
Chris Double
|
|
@ -0,0 +1,13 @@
|
|||
! Copyright (C) 2007 Chris Double.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
!
|
||||
USING: kernel tools.test peg peg.pl0 ;
|
||||
IN: temporary
|
||||
|
||||
{ "abc" } [
|
||||
"abc" 'ident' parse parse-result-ast
|
||||
] unit-test
|
||||
|
||||
{ 55 } [
|
||||
"55abc" 'number' parse parse-result-ast
|
||||
] unit-test
|
|
@ -0,0 +1,14 @@
|
|||
! Copyright (C) 2007 Chris Double.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel arrays strings math.parser peg ;
|
||||
IN: peg.pl0
|
||||
|
||||
#! Grammar for PL/0 based on http://en.wikipedia.org/wiki/PL/0
|
||||
|
||||
: 'ident' ( -- parser )
|
||||
CHAR: a CHAR: z range
|
||||
CHAR: A CHAR: Z range 2array choice repeat1
|
||||
[ >string ] action ;
|
||||
|
||||
: 'number' ( -- parser )
|
||||
CHAR: 0 CHAR: 9 range repeat1 [ string>number ] action ;
|
|
@ -0,0 +1 @@
|
|||
Grammar for PL/0 Language
|
Loading…
Reference in New Issue