From d5c7383231d3eaef5b0ab1ccb1a7fc6aa1cf1903 Mon Sep 17 00:00:00 2001 From: Victor Fernandes Date: Fri, 10 Feb 2017 16:29:07 -0500 Subject: [PATCH] Rudimentary language specification --- PLATYPUS Grammar Specification.md | 171 ++++++++++++++++++++++++++++-- 1 file changed, 164 insertions(+), 7 deletions(-) diff --git a/PLATYPUS Grammar Specification.md b/PLATYPUS Grammar Specification.md index 4e9b778..ad9b3c7 100644 --- a/PLATYPUS Grammar Specification.md +++ b/PLATYPUS Grammar Specification.md @@ -1,10 +1,10 @@ # PLATYPUS Language Specification -## Lexical Specification (INCOMPLETE) +## 2. Lexical Specification (INCOMPLETE) ## NOTE: **This is incredibly incomplete and broken, I am simply writing this down and will fix it as I read along the informal language specification provided to me** -1. Input Elements and Tokens +### 2.1 Input Elements and Tokens ``` -> ASCII characters but not SEOF @@ -19,7 +19,7 @@ | | | | | | ``` -2. White Space +### 2.2 White Space ``` -> ASCII SP character (space) @@ -31,7 +31,7 @@ -> CR | LF | CR LF ``` -3. Comments +### 2.3 Comments ``` -> !< @@ -42,7 +42,7 @@ -> but not ``` -4. Variable Identifiers +### 2.4 Variable Identifiers ``` -> | @@ -62,12 +62,12 @@ -> # ``` -5. Keywords +### 2.5 Keywords ``` -> PLATYPUS | IF | THEN | ELSE | USING | REPEAT | INPUT | OUTPUT ``` -6. Integer Literals +### 2.6 Integer Literals ``` -> | @@ -93,3 +93,160 @@ -> | +``` +### 2.7 Floating-point Literals +``` + -> + . +``` +### 2.8 String Literals +``` + -> + "" + + -> + | +``` +### 2.9 Separators +``` + -> one of + ( ) { } , ; " . +``` +### 2.10 Operators +``` + -> + | + | | + | + + -> one of + + - * / + + -> one of + > < == <> + + -> + .AND. | .OR. + + -> + = +``` +## 3. The PLATYPUS Syntatic Specification +### 3.1 PLATYPUS Program +``` + -> + PLATYPUS {} SEOF + + -> + | +``` +### 3.2 Statements +``` + -> + + | + | + | + | +``` +### 3.3 Assignment Statement +``` + -> + + + -> + AVID = + | SVID = +``` +#### 3.2.2 Selection Statement (`if` statement) +``` + -> + IF () THEN + ELSE {}; +``` +#### 3.2.3 Iteration Statement (the loop statement) +``` + -> + +``` +#### 3.2.4 Input Statement +``` + -> + INPUT (); + + -> + | , +``` +#### 3.2.5 Output Statement +``` + -> + +``` +### 3.3 Expressions +#### 3.3.1 Arithmetic Expressions +``` + -> + + | + + -> + - + | + -> + + + | - + | + + -> + * + | / + | + + -> + + | + | + | () +``` +#### 3.3.2 String Expression +``` + -> + + | << + + -> + + | +``` +#### 3.3.3 Conditional Expression +``` + -> + + + -> + + + -> + +``` +#### 3.3.4 Relational Expression +``` + -> + == + | <= + | > + | < + | == + | <= + | > + | < + + -> + + | + | + + -> + +``` \ No newline at end of file