Skip to content

A fun project to learn something about compilers

License

Notifications You must be signed in to change notification settings

nkilders/compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compiler

Grammatik

Terminale / Tokens

TokenType.java

Statisch

Token mit fester Länge und fester Inhalt

Technischer Name Beschreibung Beispiel
LPAREN Öffnende Klammer (
RPAREN Schließende Klammer )
LBRACE Öffnende geschwungene Klammer {
RBRACE Schließende geschwungene Klammer }
LBRACKET Öffnende eckige Klammer [
RBRACKET Schließende eckige Klammer ]
PLUS Plus +
MINUS Minus -
MULTIPLY Mal *
DIVIDE Geteilt /
MODULO Modulo %
EQUALS Vergleich ==
ASSIGN Zuweisung =
GT Größer als >
GTE Größer als oder gleich >=
LT Kleiner als <
LTE Kleiner als oder gleich <=
SEMICOLON Semikolon ;
COMMA Komma ,
AND Logisches Und &&
OR Logisches Oder ||
NOT Logisches Nicht !

Dynamisch

Token mit variabler Länge und variablem Inhalt

Technischer Name Beschreibung Beispiel
IDENTIFIER Bezeichner doStuff, hehe123
STRING String "abc"
LINE_COMMENT Einzeiliger Kommentar // hello world
MULTI_LINE_COMMENT Mehrzeiliger Kommentar /* hello world */
WHITESPACE Leerzeichen
NUMBER Zahl 123, 3.141

Statisch + Bezeichnerartig (Reserved Keywords)

Statische Keywords mit der gleichen Form wie IDENTIFIER (s. Dynamisch)

ReservedKeyword.java

Technischer Name Beschreibung Beispiel
FUNCTION function
LET let
CONST const
IF if
ELSE else
WHILE while

Regeln

Nichtterminal Ableitungen
Stmt BlockStmt
DeclareStmt
Expr
BlockStmt LBRACE Stmt* RBRACE
DeclareStmt ( LET | CONST ) IDENTIFIER ( ASSIGN Expr )?
Expr AssignExpr
AssignExpr AddExpr
VarExpr ASSIGN AssignExpr
AddExpr MulExpr ( ( PLUS | MINUS ) MulExpr )*
MulExpr UnaryExpr ( ( MULTIPLY | DIVIDE ) UnaryExpr )*
UnaryExpr PrimaryExpr
( ( PLUS | MINUS | NOT ) UnaryExpr )
PrimaryExpr NUMBER
TRUE
FALSE
STRING
VarExpr
ParenExpr
VarExpr IDENTIFIER
ParenExpr LPAREN Expr RPAREN

About

A fun project to learn something about compilers

Resources

License

Stars

Watchers

Forks

Languages