Remove need for '.' to terminate rule lines in EBNF
parent
9403d97e22
commit
eef6ae7827
|
@ -145,10 +145,17 @@ DEFER: 'rhs'
|
||||||
'identifier' [ <ebnf-terminal> ] action ;
|
'identifier' [ <ebnf-terminal> ] action ;
|
||||||
|
|
||||||
: 'element' ( -- parser )
|
: 'element' ( -- parser )
|
||||||
[
|
#! An element of a rule. It can be a terminal or a
|
||||||
'non-terminal' ,
|
#! non-terminal but must not be followed by a "=".
|
||||||
'terminal' ,
|
#! The latter indicates that it is the beginning of a
|
||||||
] choice* ;
|
#! new rule.
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'non-terminal' ,
|
||||||
|
'terminal' ,
|
||||||
|
] choice* ,
|
||||||
|
"=" syntax ensure-not ,
|
||||||
|
] seq* [ first ] action ;
|
||||||
|
|
||||||
DEFER: 'choice'
|
DEFER: 'choice'
|
||||||
|
|
||||||
|
@ -168,6 +175,8 @@ DEFER: 'choice'
|
||||||
"[" [ <ebnf-optional> ] "]" grouped ;
|
"[" [ <ebnf-optional> ] "]" grouped ;
|
||||||
|
|
||||||
: 'sequence' ( -- parser )
|
: 'sequence' ( -- parser )
|
||||||
|
#! A sequence of terminals and non-terminals, including
|
||||||
|
#! groupings of those.
|
||||||
[
|
[
|
||||||
'element' sp ,
|
'element' sp ,
|
||||||
'group' sp ,
|
'group' sp ,
|
||||||
|
@ -205,7 +214,7 @@ DEFER: 'choice'
|
||||||
] seq* [ first2 <ebnf-rule> ] action ;
|
] seq* [ first2 <ebnf-rule> ] action ;
|
||||||
|
|
||||||
: 'ebnf' ( -- parser )
|
: 'ebnf' ( -- parser )
|
||||||
'rule' sp "." syntax list-of [ <ebnf> ] action ;
|
'rule' sp repeat1 [ <ebnf> ] action ;
|
||||||
|
|
||||||
: ebnf>quot ( string -- quot )
|
: ebnf>quot ( string -- quot )
|
||||||
'ebnf' parse [
|
'ebnf' parse [
|
||||||
|
|
Loading…
Reference in New Issue