Jump to content

Parse EBNF: Difference between revisions

Parse EBNF from string format
m (→‎{{header|PicoLisp}}: Flag problem)
(Parse EBNF from string format)
Line 12:
 
=={{header|PicoLisp}}==
<lang PicoLisp>(de EBNF
{{improve|PicoLisp|The input description should be EBNF, not a parsed form of it.}}
<lang PicoLisp>(def ' "expr : 'ebnfterm '(term (( PLUS | MINUS ) term) *))* ;"
(def 'term "term 'ebnf : '(factor ( ( MULT | DIV ) factor) *))* ;"
(def ' "factor 'ebnf '(: NUMBER ;" ))</lang>
 
(for E EBNF
(use (@S @E)
(unless (and (match '(@S : @E ;) (str E)) (not (cdr @S)))
(quit "Invalid EBNF" E) )
(put (car @S) 'ebnf @E) ) )</lang>
<lang PicoLisp>(de matchEbnf (Pat)
(cond
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.