Fix opt statement productions, start regex for literals

This commit is contained in:
Victor Fernandes 2017-03-13 12:58:58 -04:00
parent 214b6a49cd
commit 2b8186baa0
2 changed files with 66 additions and 1 deletions

View File

@ -52,6 +52,9 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all
<arithmetic identifier> ::=
<letter> <opt_letters or digits>
<opt_letters or digits> ::=
ε | <letters or digits>
<letters or digits> ::=
<letter or digit> | <letters or digits> <letter or digit>
@ -77,6 +80,9 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all
<decimal integer literal> ::=
0 | <non-zero digit> <opt_digits>
<opt_digits> ::=
ε | <digits>
<digits> ::=
<digit> | <digits> <digit>
@ -103,10 +109,16 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all
```
### 2.8 String Literals
```
<opt_string literal> ::=
ε | <string literal>
<string literal> ::=
"<opt_string characters>"
<string chacters> ::=
<opt_string characters> ::=
ε | <string characters>
<string characters> ::=
<input character> | <string characters> <input character>
```
### 2.9 Separators
@ -142,6 +154,9 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all
<program> ::=
PLATYPUS {<opt_statements>} SEOF
<opt_statements> ::=
ε | <statements>
<statements> ::=
<statement> | <statements> <statement>
```
@ -179,6 +194,9 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all
<input statement> ::=
INPUT (<variable list>);
<opt_variable list> ::=
ε | <variable list>
<variable list> ::=
<variable identifier> | <variable list>,<variable identifier>
```

47
PLATYPUS_Regex.md Normal file
View File

@ -0,0 +1,47 @@
# Regular Expressions for PLATYPUS
## Comments
```
L(COMMENT) = !< [^CR]*CR
```
## Keywords
```
L(KEYWORD) = PLATYPUS | IF | THEN | ELSE | USING | REPEAT | INPUT | OUTPUT
```
## Variable Identifiers
```
L(LETTER) = [a-zA-Z]
L(LETTER_OR_DIGIT) = [a-zA-Z0-9]
L(VID) = AVID | SVID
L(AVID) = [a-zA-Z]([a-zA-Z0-9])*
L(SVID) = AVID#
```
## Integer Literals
```
L(DEC_INT_LITERAL) = [0-9]*
L(NON_ZERO_DIGIT) = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
L(DIGIT) = [0-9]+
L(OCT_DIGIT) = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
L(OCT_DIGIT_LITERAL) = 0(OCT_DIGIT)+
L(INT_LITERAL) = (DEC_INT_LITERAL | OCT_INT_LITERAL)
```
## Floating Point Literal
```
L(FLP_LITERAL) = ([0-9]*).([0-9]+)
```
## String Literal
```
L(STR_LITERAL) = "([a-ZA-Z_0-9])*"
```