Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 428 Bytes

optional.md

File metadata and controls

25 lines (16 loc) · 428 Bytes

Optional

There is a special alternative symbol ?, which allows a grammar to parse a string optionally. For example:

S: A?;

terminals

A: 'a';

This grammar accepts both a and the empty string.

Formally, S: A?; is shorthand for the following grammar rules:

S: AOpt;
AOpt: A | EMPTY;

➡️ Next: One Or More

📘 Back: Table of contents