Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 664 Bytes

using_grammar_symbols_in_expressions.md

File metadata and controls

33 lines (22 loc) · 664 Bytes

Using Grammar Symbols In Expressions

The <expression> part of a grammar rule can also contain grammar symbols. Here is an example saying that the grammar symbol S is parsed by parsing the grammar symbol T:

S: T;
T: A;

terminals

A: 'a';

In a grammar rule, a grammar symbol can also be concatenated with another grammar symbol as well as a terminal. For example:

S: T T C T;
T: A B;

terminals

A: 'a';
B: 'b';
C: 'c';

This grammar accepts exactly the string ababcab with optional white spaces allowed in between.

➡️ Next: Empty String

📘 Back: Table of contents