Skip to content

Latest commit

 

History

History
36 lines (23 loc) · 931 Bytes

skipping_parts_of_input.md

File metadata and controls

36 lines (23 loc) · 931 Bytes

Skipping Parts Of Input

By default, the generated parser skips white spaces. For example, consider the grammar below:

S: A+;

terminals

A: /a/;

This grammar accepts string a a a even if there are white spaces among a's.

We can change this behavior by the special grammar symbol Layout. For example, we can disable accepting white spaces by Layout: EMPTY;, as described below:

S: A+;
Layout: EMPTY;

terminals

A: /a/;

Now, a a a is not acceptable.

This feature is for parts like comments that are not important in the input string and can be skipped. We can specify how to parse these comments by adding a grammar rule with grammar symbol Layout. The string parsed by Layout will be skipped automatically and will not be shown in the output.

➡️ Next: Default Names For Terminals

📘 Back: Table of contents