# PLATYPUS Language Specification ## 2. Lexical Specification (INCOMPLETE) ## NOTE: **This is incomplete, I am simply writing this down and will fix it as I read along the informal language specification provided to me 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 ``` bnf ::= 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 ``` bnf ::= !< ::= | ::= but not ``` ### 2.4 Variable Identifiers ``` bnf ::= | ::= ::= ε | ::= | ::= one of [a-z][A-Z] ::= one of [a-z][A-Z][0-9] ::= # ``` ### 2.5 Keywords ``` bnf ::= PLATYPUS | IF | THEN | ELSE | USING | REPEAT | INPUT | OUTPUT ``` ### 2.6 Integer Literals ``` bnf ::= | ::= 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 ``` bnf ::= . ``` ### 2.8 String Literals ``` bnf ::= ε | ::= "" ::= ε | ::= | ``` ### 2.9 Separators ``` bnf ::= ( | ) | { | } | , | ; | " |. ``` ### 2.10 Operators ``` bnf ::= | | | | ::= + | - | * | / ::= << ::= > | < | == | <> ::= .AND. | .OR. ::= = ``` ## 3. The PLATYPUS Syntactic Specification ### 3.1 PLATYPUS Program ``` bnf ::= PLATYPUS {} SEOF ::= ε | ::= | ``` ### 3.2 Statements ``` bnf ::= | | | | ``` ### 3.3 Assignment Statement ``` bnf ::= ; ::= = | = ``` #### 3.2.2 Selection Statement (`if` statement) ``` bnf ::= IF () THEN ELSE {}; ``` #### 3.2.3 Iteration Statement (the loop statement) ``` bnf ::= USING ( , , ) REPEAT { }; ``` #### 3.2.4 Input Statement ``` bnf ::= INPUT (); ::= ε | ::= | , ``` #### 3.2.5 Output Statement ``` bnf ::= OUTPUT( | ); ``` ### 3.3 Expressions #### 3.3.1 Arithmetic Expressions ``` bnf ::= | ::= - | + ::= + | - | ::= * | / | ::= | | | () ``` #### 3.3.2 String Expression ``` bnf ::= | << ::= | ``` #### 3.3.3 Conditional Expression ``` bnf // 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 ``` bnf ::= | ::= | | ::= | ```