Recursive descent parser: Difference between revisions

Content deleted Content added
m Reverted edits by 201.175.151.158 (talk) (HG) (3.4.10)
m Task 70: Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 14:
The following [[Extended Backus–Naur Form|EBNF]]-like [[formal grammar|grammar]] (for [[Niklaus Wirth]]'s [[PL/0]] programming language, from ''[[Algorithms + Data Structures = Programs]]'') is in [[LL parser|LL(1)]] form:
 
<sourcesyntaxhighlight lang="ebnf">
program = block "." .
Line 41:
| number
| "(" expression ")" .
</syntaxhighlight>
</source>
 
[[terminal symbol|Terminals]] are expressed in quotes. Each [[nonterminal symbol|nonterminal]] is defined by a rule in the grammar, except for ''ident'' and ''number'', which are assumed to be implicitly defined.
Line 53:
The implementations of the functions ''nextsym'' and ''error'' are omitted for simplicity.
 
<sourcesyntaxhighlight lang="c">
typedef enum {ident, number, lparen, rparen, times, slash, plus,
minus, eql, neq, lss, leq, gtr, geq, callsym, beginsym, semicolon,
Line 179:
expect(period);
}
</syntaxhighlight>
</source>
 
== Examples ==