From e57941f5f43507c275623bc82d4f5f93103876ca Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Tue, 13 Oct 2020 15:46:25 -0600 Subject: test tree-based PEG layout --- syntax.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/syntax.md b/syntax.md index 1555409..c0b043f 100644 --- a/syntax.md +++ b/syntax.md @@ -21,7 +21,7 @@ Tokens are separated by either *whitespace* or a *comment*. ## Keywords -A *keyword* is one of the following 28 literal words: +A *keyword* is one of the following literal words: - `bool` - `break` - `case` @@ -46,7 +46,6 @@ A *keyword* is one of the following 28 literal words: - `sizeof` - `struct` - `switch` -- `typedef` - `unsigned` - `void` - `while` @@ -157,3 +156,15 @@ A *comment* can be either a *line comment* or a *block comment*. A *line comment* begins with the characters `//` if they occur outside of a string literal or comment, and ends with a newline character U+000A. A *block comment* begins with the characters `/*` if they occur outside of a string literal or comment, and ends with the characters `*/`. + +# Parsing + +The syntax of Crowbar is given as a [parsing expression grammar](https://en.wikipedia.org/wiki/Parsing_expression_grammar): + +| Syntax Element | | Parsing Expression | +|:-----------------|:-:|:-------------------------| +|ImplementationFile| ← |ImplementationFileElement*| +|HeaderFile | ← |HeaderFileElement* | +|HeaderFileElement | ← |IncludeStatement | +| | / |TypeDeclaration | +| | / |FunctionDeclaration | -- cgit v1.2.3