Fix opt statement productions, start regex for literals
This commit is contained in:
parent
214b6a49cd
commit
2b8186baa0
|
@ -52,6 +52,9 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all
|
||||||
<arithmetic identifier> ::=
|
<arithmetic identifier> ::=
|
||||||
<letter> <opt_letters or digits>
|
<letter> <opt_letters or digits>
|
||||||
|
|
||||||
|
<opt_letters or digits> ::=
|
||||||
|
ε | <letters or digits>
|
||||||
|
|
||||||
<letters or digits> ::=
|
<letters or digits> ::=
|
||||||
<letter or digit> | <letters or digits> <letter or digit>
|
<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> ::=
|
<decimal integer literal> ::=
|
||||||
0 | <non-zero digit> <opt_digits>
|
0 | <non-zero digit> <opt_digits>
|
||||||
|
|
||||||
|
<opt_digits> ::=
|
||||||
|
ε | <digits>
|
||||||
|
|
||||||
<digits> ::=
|
<digits> ::=
|
||||||
<digit> | <digits> <digit>
|
<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
|
### 2.8 String Literals
|
||||||
```
|
```
|
||||||
|
<opt_string literal> ::=
|
||||||
|
ε | <string literal>
|
||||||
|
|
||||||
<string literal> ::=
|
<string literal> ::=
|
||||||
"<opt_string characters>"
|
"<opt_string characters>"
|
||||||
|
|
||||||
<string chacters> ::=
|
<opt_string characters> ::=
|
||||||
|
ε | <string characters>
|
||||||
|
|
||||||
|
<string characters> ::=
|
||||||
<input character> | <string characters> <input character>
|
<input character> | <string characters> <input character>
|
||||||
```
|
```
|
||||||
### 2.9 Separators
|
### 2.9 Separators
|
||||||
|
@ -142,6 +154,9 @@ This does not follow standard BNF/EBNF syntax, I will rewrite it once I get all
|
||||||
<program> ::=
|
<program> ::=
|
||||||
PLATYPUS {<opt_statements>} SEOF
|
PLATYPUS {<opt_statements>} SEOF
|
||||||
|
|
||||||
|
<opt_statements> ::=
|
||||||
|
ε | <statements>
|
||||||
|
|
||||||
<statements> ::=
|
<statements> ::=
|
||||||
<statement> | <statements> <statement>
|
<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 statement> ::=
|
||||||
INPUT (<variable list>);
|
INPUT (<variable list>);
|
||||||
|
|
||||||
|
<opt_variable list> ::=
|
||||||
|
ε | <variable list>
|
||||||
|
|
||||||
<variable list> ::=
|
<variable list> ::=
|
||||||
<variable identifier> | <variable list>,<variable identifier>
|
<variable identifier> | <variable list>,<variable identifier>
|
||||||
```
|
```
|
||||||
|
|
|
@ -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])*"
|
||||||
|
```
|
Loading…
Reference in New Issue