Please rate my grammar

Im building a JIT Compiler and just started the lexer, but wanted to do the grammar first to make things easier. is there any way i can make the grammar any better?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    Grammar:
        IDENTIFIER     [_a-zA-Z][_a-zA-Z0-9]*
        VAR            \$(IDENTIFIER)
        MULTLINESTRING (\"\"\"[^\"\"\"]\"\"\")|(\'\'\'[^\'\'\']\'\'\')
        STRING         (\"[^\"\n]\")|(\'[^\'\n]\')
        INTEGER        [1-9][0-9]*
        FLOAT          (INTEGER\.INTEGER*)|(\.INTEGER+)
        BOOLEAN        ("True")|("False")

        ==================================
        Token :: StatementList
               | FlowBlock
               | LoopBlock
               | Function
               | Null

        StatementList :: Statement ';' StatementList
                       | Null

        Statement :: "import" IDENTIFIER
                   | VarList
                   | Expression
                   | IDENTIFIER '(' ArgList ')'
                   | "pause"
                   | "clear"
                   | "quit"
                   | Null

        VarList :: VarList ',' VarList
                 | VAR
                 | VAR '=' Expression

        Expression :: Expression Operator Expression
                    | '(' Expression ')'
                    | VAR
                    | Datatype

        Operator :: '+' | '-' | '*' | '/' | "**" | '%' | '!' | '~' | '^'
                  | '&' | '|' | "==" | "!=" | '<' | '>' | "<=" | ">="
                  | "&&" | "||"

        Datatype :: MULTLINESTRING | STRING | INTEGER | FLOAT | BOOLEAN

        ArgList :: VarList
                 | Null

        FlowBlock :: IfChain | SwitchBlock

        IfChain :: "if" '(' Expression ')' '{' Token '}' ElseIf Else

        ElseIf :: "elif" '(' Expression ')' '{' Token '}'
                | ElseIf ElseIf
                | Null

        Else :: "else" '{' Token '}'
              | Null

        SwitchBlock :: "switch" '(' VAR ')' '{' CaseList Default '}'

        CaseList :: CaseList CaseList
                  | "case" Datatype ':' Token
                  | Null

        Default :: "default" ':' Token
                 | Null

        LoopBlock :: WhileLoop

        WhileLoop :: "while" '(' Expression ')' '{' Token '}'

        Function :: "function" IDENTIFIER '(' ArgList ')' '{' Token '}' 
Topic archived. No new replies allowed.