Skip to content

Commit

Permalink
#290-Specify PEG Typee grammar
Browse files Browse the repository at this point in the history
First temporary draft - to be completed.
  • Loading branch information
schmouk committed Jul 11, 2021
1 parent 5a13fac commit 8e6578f
Show file tree
Hide file tree
Showing 4 changed files with 601 additions and 5 deletions.
64 changes: 64 additions & 0 deletions Language-specifications/PEGrammars.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<NotepadPlus>
<UserLang name="PEGrammars" ext="peg" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00## 01 02 03 04</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
<Keywords name="Numbers, extras1"></Keywords>
<Keywords name="Numbers, extras2"></Keywords>
<Keywords name="Numbers, suffix1"></Keywords>
<Keywords name="Numbers, suffix2"></Keywords>
<Keywords name="Numbers, range"></Keywords>
<Keywords name="Operators1">? * + &amp; ! ( ) . [ ]</Keywords>
<Keywords name="Operators2"></Keywords>
<Keywords name="Folders in code1, open"></Keywords>
<Keywords name="Folders in code1, middle"></Keywords>
<Keywords name="Folders in code1, close"></Keywords>
<Keywords name="Folders in code2, open"></Keywords>
<Keywords name="Folders in code2, middle"></Keywords>
<Keywords name="Folders in code2, close"></Keywords>
<Keywords name="Folders in comment, open"></Keywords>
<Keywords name="Folders in comment, middle"></Keywords>
<Keywords name="Folders in comment, close"></Keywords>
<Keywords name="Keywords1">&lt;- /</Keywords>
<Keywords name="Keywords2"></Keywords>
<Keywords name="Keywords3"></Keywords>
<Keywords name="Keywords4"></Keywords>
<Keywords name="Keywords5"></Keywords>
<Keywords name="Keywords6"></Keywords>
<Keywords name="Keywords7"></Keywords>
<Keywords name="Keywords8"></Keywords>
<Keywords name="Delimiters">00&quot; 01 02&quot; 03&apos; 04 05&apos; 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
</KeywordLists>
<Styles>
<WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="Consolas" fontStyle="0" fontSize="9" nesting="0" />
<WordsStyle name="COMMENTS" fgColor="00A0A0" bgColor="FFFF46" fontName="" fontStyle="3" nesting="0" />
<WordsStyle name="LINE COMMENTS" fgColor="626262" bgColor="FFFF46" fontName="" fontStyle="2" nesting="0" />
<WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="KEYWORDS2" fgColor="008040" bgColor="FFFFFF" fontName="" fontStyle="3" nesting="0" />
<WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="OPERATORS" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="Consolas" fontStyle="0" fontSize="9" nesting="0" />
<WordsStyle name="DELIMITERS1" fgColor="C86400" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS2" fgColor="C86400" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="DELIMITERS3" fgColor="0000A0" bgColor="FFFFFF" fontName="" fontStyle="1" nesting="0" />
<WordsStyle name="DELIMITERS4" fgColor="0000A0" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS5" fgColor="004040" bgColor="00FFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS6" fgColor="0000A0" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
</Styles>
</UserLang>
</NotepadPlus>
6 changes: 6 additions & 0 deletions Language-specifications/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ we use notations `<-` and `/` for instance, while newer papers use `::=`
or `|` instead as it is usual in CFGs (*Context Free Grammars*, which what
LL(1) grammars are).

Notice that we use notation '##' as the starting point for comments, while
Bryan Floyd was using '#' in his original paper. This is a commodity we use
to get colored syntax in Notepad++. Notioce also that Comments are one line
comments only in the very first description of PEG grammars. The PEG
specification of **Typee** conforms to this.

We strongly encourage the reader to get access to the initial article from
Bryan Ford. Section 2 of this paper fully explains the syntax of PEGrammars:
"*Parsing Expression Grammars: A Recognition-Based Syntactic Foundation*",
Expand Down
11 changes: 6 additions & 5 deletions Language-specifications/typee_specs_LL1-v10.grm
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,10 @@ SOFTWARE.
| EPS


<scalar type or dotted name> ::= <scalar type>
| <dotted name>




/***** TYPES ****************************************************/
Expand All @@ -892,6 +896,7 @@ SOFTWARE.
<type'> ::= <auto type>
| '(' <types list> ')'
| <container type>
| <enum type>
| <file type>
| <NONE>
| <scalar type> <dimensions>
Expand All @@ -909,7 +914,6 @@ SOFTWARE.
| EPS

<container type> ::= <array_type>
| <enum type>
| <list type>
| <map type>
| <set type>
Expand All @@ -920,6 +924,7 @@ SOFTWARE.
| EPS
<dimensions'> ::= <integer number>
| <dotted name>

<enum type> ::= 'enum'

<file type> ::= 'file' <contained type>
Expand Down Expand Up @@ -956,10 +961,6 @@ SOFTWARE.
| 'uint32'
| 'uint64'

<scalar type or dotted name> ::= <scalar type>
| <dotted name>


<set type> ::= 'set' <contained type>

<static qualifier> ::= 'static'
Expand Down
Loading

0 comments on commit 8e6578f

Please sign in to comment.