From 259d654eafb1141d951f5216921f442973a4cb45 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Fri, 28 Apr 2017 17:15:46 -0400 Subject: [PATCH] Modified grammar for the parser --- PLATYPUS Grammar Specification.txt | 328 +++++++++++++++++++++++++++++ 1 file changed, 328 insertions(+) create mode 100644 PLATYPUS Grammar Specification.txt diff --git a/PLATYPUS Grammar Specification.txt b/PLATYPUS Grammar Specification.txt new file mode 100644 index 0000000..d8b451d --- /dev/null +++ b/PLATYPUS Grammar Specification.txt @@ -0,0 +1,328 @@ +# PLATYPUS Language Specification + +### 2.1 Input Elements and Tokens + + -> + 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 + + -> + | + + -> + + + -> + ε | + + -> + | + + -> + [a-z] | [A-Z] + + -> + | + + -> + # + +### 2.5 Keywords + + -> + PLATYPUS | IF | THEN | ELSE | USING | REPEAT | INPUT | OUTPUT + +### 2.6 Integer Literals + + -> + | + + -> + 0 | + + -> + ε | + + -> + | + + -> + 0 | + + -> 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 + + -> + + | + | + | + | + +### 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 (); + + -> + ε | + +/** New Variable List version below + -> + | , +**/ + + -> + + + -> + , | E + +#### 3.2.5 Output Statement + + -> + OUTPUT( | ); + +### 3.3 Expressions +#### 3.3.1 Arithmetic Expressions + + -> + + | + + -> + - + | + + +/** New Version of Additive Arithmetic Expressions below + -> + + + | - + | +**/ + + -> + + + -> + + + | - + +/** New Version of Mult. Arithmetic Expressions below + -> + * + | / + | +**/ + -> + + + -> + * + | / + + -> + + | + | + | () + +#### 3.3.2 String Expression +/** New version of String Expressions below + -> + + | << +**/ + -> + + + -> + << | E + + -> + + | + +#### 3.3.3 Conditional Expression + + -> + + +/** New Logical OR and Logical AND expressions below + -> + + | .OR. + + -> + + | .AND. +**/ + -> + + + -> + .OR. + + -> + + + -> + .AND. + + +#### 3.3.4 Relational Expressions + +/** New version of Relational expressions below + -> + + | +**/ + + -> + + | + + + -> + + | + | + + -> + == + | <> + | > + | < + + -> + | + + -> + == + | <> + | > + | <