From cd18b511767538dd07013bfd2b954d6e46c81e57 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Wed, 22 Feb 2017 19:23:31 -0500 Subject: [PATCH] Start converting UBNF (ugly BNF) into BNF --- PLATYPUS Grammar Specification.md | 116 +++++++++++++++--------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 65d15f8..5e764b5 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -7,147 +7,147 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all the definitions correct and complete.** ### 2.1 Input Elements and Tokens -``` - -> +``` bnf + ::= ASCII characters but not SEOF - -> + ::= SEOF - -> + ::= | - -> + ::= | | | | | | ``` ### 2.2 White Space ``` - -> + ::= ASCII SP character (space) | ASCII HT character (horizontal tab) | ASCII VT character (vertical tab) | ASCII FF character (form feed) | - -> + ::= CR | LF | CR LF ``` ### 2.3 Comments ``` - -> + ::= !< - -> + ::= | - -> + ::= but not ``` ### 2.4 Variable Identifiers ``` - -> + ::= | - -> + ::= - -> + ::= | - -> one of + ::= one of [a-z][A-Z] - -> one of + ::= one of [a-z][A-Z][0-9] - -> + ::= # ``` ### 2.5 Keywords ``` - -> + ::= PLATYPUS | IF | THEN | ELSE | USING | REPEAT | INPUT | OUTPUT ``` ### 2.6 Integer Literals ``` - -> + ::= | - -> + ::= 0 | - -> + ::= | - -> + ::= 0 | - -> one of + ::= one of 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - -> + ::= 0 - -> + ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 - -> + ::= | ``` ### 2.7 Floating-point Literals ``` - -> + ::= . ``` ### 2.8 String Literals ``` - -> + ::= "" - -> + ::= | ``` ### 2.9 Separators ``` - -> + ::= ( | ) | { | } | , | ; | " |. ``` ### 2.10 Operators ``` - -> + ::= | | | | - -> + ::= + | - | * | / - -> + ::= << - -> + ::= > | < | == | <> - -> + ::= .AND. | .OR. - -> + ::= = ``` ## 3. The PLATYPUS Syntactic Specification ### 3.1 PLATYPUS Program ``` - -> + ::= PLATYPUS {} SEOF - -> + ::= | ``` ### 3.2 Statements ``` - -> + ::= | | @@ -156,59 +156,59 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all ``` ### 3.3 Assignment Statement ``` - -> + ::= ; - -> + ::= = | = ``` #### 3.2.2 Selection Statement (`if` statement) ``` - -> + ::= IF () THEN ELSE {}; ``` #### 3.2.3 Iteration Statement (the loop statement) ``` - -> + ::= USING ( , , ) REPEAT { }; ``` #### 3.2.4 Input Statement ``` - -> + ::= INPUT (); - -> + ::= | , ``` #### 3.2.5 Output Statement ``` - -> + ::= OUTPUT( | ); ``` ### 3.3 Expressions #### 3.3.1 Arithmetic Expressions ``` - -> + ::= | - -> + ::= - | + -> + ::= + | - | - -> + ::= * | / | - -> + ::= | | @@ -216,11 +216,11 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all ``` #### 3.3.2 String Expression ``` - -> + ::= | << - -> + ::= | ``` @@ -228,30 +228,30 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all ``` // BNF from C specification adapted to PLATYPUS // source: https://cs.wmich.edu/~gupta/teaching/cs4850/sumII06/The%20syntax%20of%20C%20in%20Backus-Naur%20form.htm - -> + ::= - -> + ::= | .OR. - -> + ::= | .AND. // END BNF from C specification ``` #### 3.3.4 Relational Expression ``` - -> + ::= | - -> + ::= | | - -> + ::= | ``` \ No newline at end of file