commit 0a9d70219883b2697af9ec52bd62cc66f6bd87fb Author: Marvin Kaiser Date: Mon Oct 28 15:55:18 2019 +0100 Initial commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..06b8208 --- /dev/null +++ b/.classpath @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..61d6617 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + klang + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4fd796d --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//target/generated-sources/antlr4=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.apt.core.prefs b/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b11489f --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1133129 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e549dfc --- /dev/null +++ b/pom.xml @@ -0,0 +1,74 @@ + + 4.0.0 + de.hsrm.compiler + klang + 1.0 + jar + klang + http://maven.apache.org + + UTF-8 + + + + org.antlr + antlr4-runtime + 4.5 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + org.antlr + antlr4-maven-plugin + 4.5 + + + + antlr4 + + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + + simple-command + package + + attached + + + + + + + \ No newline at end of file diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/Klang.interp b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/Klang.interp new file mode 100644 index 0000000..2873b74 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/Klang.interp @@ -0,0 +1,92 @@ +token literal names: +null +'||' +'&&' +'==' +'!=' +'>' +'<' +'>=' +'<=' +'+' +'-' +'*' +'/' +'%' +'^' +'!' +';' +'=' +'(' +')' +'{' +'}' +'true' +'false' +'nil' +'if' +'else' +'while' +'log' +null +null +null +null +null +null +null + +token symbolic names: +null +OR +AND +EQ +NEQ +GT +LT +GTEQ +LTEQ +PLUS +MINUS +MULT +DIV +MOD +POW +NOT +SCOL +ASSIGN +OPAR +CPAR +OBRACE +CBRACE +TRUE +FALSE +NIL +IF +ELSE +WHILE +LOG +ID +INT +FLOAT +STRING +COMMENT +SPACE +OTHER + +rule names: +parse +block +stat +assignment +if_stat +condition_block +stat_block +while_stat +log +expr +atom + + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 37, 124, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 3, 2, 3, 2, 3, 2, 3, 3, 7, 3, 29, 10, 3, 12, 3, 14, 3, 32, 11, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 40, 10, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 7, 6, 52, 10, 6, 12, 6, 14, 6, 55, 11, 6, 3, 6, 3, 6, 5, 6, 59, 10, 6, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 5, 8, 69, 10, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 85, 10, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 7, 11, 108, 10, 11, 12, 11, 14, 11, 111, 11, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 5, 12, 122, 10, 12, 3, 12, 2, 3, 20, 13, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 2, 8, 3, 2, 13, 15, 3, 2, 11, 12, 3, 2, 7, 10, 3, 2, 5, 6, 3, 2, 32, 33, 3, 2, 24, 25, 2, 134, 2, 24, 3, 2, 2, 2, 4, 30, 3, 2, 2, 2, 6, 39, 3, 2, 2, 2, 8, 41, 3, 2, 2, 2, 10, 46, 3, 2, 2, 2, 12, 60, 3, 2, 2, 2, 14, 68, 3, 2, 2, 2, 16, 70, 3, 2, 2, 2, 18, 74, 3, 2, 2, 2, 20, 84, 3, 2, 2, 2, 22, 121, 3, 2, 2, 2, 24, 25, 5, 4, 3, 2, 25, 26, 7, 2, 2, 3, 26, 3, 3, 2, 2, 2, 27, 29, 5, 6, 4, 2, 28, 27, 3, 2, 2, 2, 29, 32, 3, 2, 2, 2, 30, 28, 3, 2, 2, 2, 30, 31, 3, 2, 2, 2, 31, 5, 3, 2, 2, 2, 32, 30, 3, 2, 2, 2, 33, 40, 5, 8, 5, 2, 34, 40, 5, 10, 6, 2, 35, 40, 5, 16, 9, 2, 36, 40, 5, 18, 10, 2, 37, 38, 7, 37, 2, 2, 38, 40, 8, 4, 1, 2, 39, 33, 3, 2, 2, 2, 39, 34, 3, 2, 2, 2, 39, 35, 3, 2, 2, 2, 39, 36, 3, 2, 2, 2, 39, 37, 3, 2, 2, 2, 40, 7, 3, 2, 2, 2, 41, 42, 7, 31, 2, 2, 42, 43, 7, 19, 2, 2, 43, 44, 5, 20, 11, 2, 44, 45, 7, 18, 2, 2, 45, 9, 3, 2, 2, 2, 46, 47, 7, 27, 2, 2, 47, 53, 5, 12, 7, 2, 48, 49, 7, 28, 2, 2, 49, 50, 7, 27, 2, 2, 50, 52, 5, 12, 7, 2, 51, 48, 3, 2, 2, 2, 52, 55, 3, 2, 2, 2, 53, 51, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 58, 3, 2, 2, 2, 55, 53, 3, 2, 2, 2, 56, 57, 7, 28, 2, 2, 57, 59, 5, 14, 8, 2, 58, 56, 3, 2, 2, 2, 58, 59, 3, 2, 2, 2, 59, 11, 3, 2, 2, 2, 60, 61, 5, 20, 11, 2, 61, 62, 5, 14, 8, 2, 62, 13, 3, 2, 2, 2, 63, 64, 7, 22, 2, 2, 64, 65, 5, 4, 3, 2, 65, 66, 7, 23, 2, 2, 66, 69, 3, 2, 2, 2, 67, 69, 5, 6, 4, 2, 68, 63, 3, 2, 2, 2, 68, 67, 3, 2, 2, 2, 69, 15, 3, 2, 2, 2, 70, 71, 7, 29, 2, 2, 71, 72, 5, 20, 11, 2, 72, 73, 5, 14, 8, 2, 73, 17, 3, 2, 2, 2, 74, 75, 7, 30, 2, 2, 75, 76, 5, 20, 11, 2, 76, 77, 7, 18, 2, 2, 77, 19, 3, 2, 2, 2, 78, 79, 8, 11, 1, 2, 79, 80, 7, 12, 2, 2, 80, 85, 5, 20, 11, 11, 81, 82, 7, 17, 2, 2, 82, 85, 5, 20, 11, 10, 83, 85, 5, 22, 12, 2, 84, 78, 3, 2, 2, 2, 84, 81, 3, 2, 2, 2, 84, 83, 3, 2, 2, 2, 85, 109, 3, 2, 2, 2, 86, 87, 12, 12, 2, 2, 87, 88, 7, 16, 2, 2, 88, 108, 5, 20, 11, 13, 89, 90, 12, 9, 2, 2, 90, 91, 9, 2, 2, 2, 91, 108, 5, 20, 11, 10, 92, 93, 12, 8, 2, 2, 93, 94, 9, 3, 2, 2, 94, 108, 5, 20, 11, 9, 95, 96, 12, 7, 2, 2, 96, 97, 9, 4, 2, 2, 97, 108, 5, 20, 11, 8, 98, 99, 12, 6, 2, 2, 99, 100, 9, 5, 2, 2, 100, 108, 5, 20, 11, 7, 101, 102, 12, 5, 2, 2, 102, 103, 7, 4, 2, 2, 103, 108, 5, 20, 11, 6, 104, 105, 12, 4, 2, 2, 105, 106, 7, 3, 2, 2, 106, 108, 5, 20, 11, 5, 107, 86, 3, 2, 2, 2, 107, 89, 3, 2, 2, 2, 107, 92, 3, 2, 2, 2, 107, 95, 3, 2, 2, 2, 107, 98, 3, 2, 2, 2, 107, 101, 3, 2, 2, 2, 107, 104, 3, 2, 2, 2, 108, 111, 3, 2, 2, 2, 109, 107, 3, 2, 2, 2, 109, 110, 3, 2, 2, 2, 110, 21, 3, 2, 2, 2, 111, 109, 3, 2, 2, 2, 112, 113, 7, 20, 2, 2, 113, 114, 5, 20, 11, 2, 114, 115, 7, 21, 2, 2, 115, 122, 3, 2, 2, 2, 116, 122, 9, 6, 2, 2, 117, 122, 9, 7, 2, 2, 118, 122, 7, 31, 2, 2, 119, 122, 7, 34, 2, 2, 120, 122, 7, 26, 2, 2, 121, 112, 3, 2, 2, 2, 121, 116, 3, 2, 2, 2, 121, 117, 3, 2, 2, 2, 121, 118, 3, 2, 2, 2, 121, 119, 3, 2, 2, 2, 121, 120, 3, 2, 2, 2, 122, 23, 3, 2, 2, 2, 11, 30, 39, 53, 58, 68, 84, 107, 109, 121] \ No newline at end of file diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/Klang.tokens b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/Klang.tokens new file mode 100644 index 0000000..d69c013 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/Klang.tokens @@ -0,0 +1,63 @@ +OR=1 +AND=2 +EQ=3 +NEQ=4 +GT=5 +LT=6 +GTEQ=7 +LTEQ=8 +PLUS=9 +MINUS=10 +MULT=11 +DIV=12 +MOD=13 +POW=14 +NOT=15 +SCOL=16 +ASSIGN=17 +OPAR=18 +CPAR=19 +OBRACE=20 +CBRACE=21 +TRUE=22 +FALSE=23 +NIL=24 +IF=25 +ELSE=26 +WHILE=27 +LOG=28 +ID=29 +INT=30 +FLOAT=31 +STRING=32 +COMMENT=33 +SPACE=34 +OTHER=35 +'||'=1 +'&&'=2 +'=='=3 +'!='=4 +'>'=5 +'<'=6 +'>='=7 +'<='=8 +'+'=9 +'-'=10 +'*'=11 +'/'=12 +'%'=13 +'^'=14 +'!'=15 +';'=16 +'='=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'true'=22 +'false'=23 +'nil'=24 +'if'=25 +'else'=26 +'while'=27 +'log'=28 diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.interp b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.interp new file mode 100644 index 0000000..b819235 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.interp @@ -0,0 +1,122 @@ +token literal names: +null +'||' +'&&' +'==' +'!=' +'>' +'<' +'>=' +'<=' +'+' +'-' +'*' +'/' +'%' +'^' +'!' +';' +'=' +'(' +')' +'{' +'}' +'true' +'false' +'nil' +'if' +'else' +'while' +'log' +null +null +null +null +null +null +null + +token symbolic names: +null +OR +AND +EQ +NEQ +GT +LT +GTEQ +LTEQ +PLUS +MINUS +MULT +DIV +MOD +POW +NOT +SCOL +ASSIGN +OPAR +CPAR +OBRACE +CBRACE +TRUE +FALSE +NIL +IF +ELSE +WHILE +LOG +ID +INT +FLOAT +STRING +COMMENT +SPACE +OTHER + +rule names: +OR +AND +EQ +NEQ +GT +LT +GTEQ +LTEQ +PLUS +MINUS +MULT +DIV +MOD +POW +NOT +SCOL +ASSIGN +OPAR +CPAR +OBRACE +CBRACE +TRUE +FALSE +NIL +IF +ELSE +WHILE +LOG +ID +INT +FLOAT +STRING +COMMENT +SPACE +OTHER + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 37, 212, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 7, 30, 157, 10, 30, 12, 30, 14, 30, 160, 11, 30, 3, 31, 6, 31, 163, 10, 31, 13, 31, 14, 31, 164, 3, 32, 6, 32, 168, 10, 32, 13, 32, 14, 32, 169, 3, 32, 3, 32, 7, 32, 174, 10, 32, 12, 32, 14, 32, 177, 11, 32, 3, 32, 3, 32, 6, 32, 181, 10, 32, 13, 32, 14, 32, 182, 5, 32, 185, 10, 32, 3, 33, 3, 33, 3, 33, 3, 33, 7, 33, 191, 10, 33, 12, 33, 14, 33, 194, 11, 33, 3, 33, 3, 33, 3, 34, 3, 34, 7, 34, 200, 10, 34, 12, 34, 14, 34, 203, 11, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 2, 2, 37, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 3, 2, 8, 5, 2, 67, 92, 97, 97, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 3, 2, 50, 59, 5, 2, 12, 12, 15, 15, 36, 36, 4, 2, 12, 12, 15, 15, 5, 2, 11, 12, 15, 15, 34, 34, 2, 220, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 3, 73, 3, 2, 2, 2, 5, 76, 3, 2, 2, 2, 7, 79, 3, 2, 2, 2, 9, 82, 3, 2, 2, 2, 11, 85, 3, 2, 2, 2, 13, 87, 3, 2, 2, 2, 15, 89, 3, 2, 2, 2, 17, 92, 3, 2, 2, 2, 19, 95, 3, 2, 2, 2, 21, 97, 3, 2, 2, 2, 23, 99, 3, 2, 2, 2, 25, 101, 3, 2, 2, 2, 27, 103, 3, 2, 2, 2, 29, 105, 3, 2, 2, 2, 31, 107, 3, 2, 2, 2, 33, 109, 3, 2, 2, 2, 35, 111, 3, 2, 2, 2, 37, 113, 3, 2, 2, 2, 39, 115, 3, 2, 2, 2, 41, 117, 3, 2, 2, 2, 43, 119, 3, 2, 2, 2, 45, 121, 3, 2, 2, 2, 47, 126, 3, 2, 2, 2, 49, 132, 3, 2, 2, 2, 51, 136, 3, 2, 2, 2, 53, 139, 3, 2, 2, 2, 55, 144, 3, 2, 2, 2, 57, 150, 3, 2, 2, 2, 59, 154, 3, 2, 2, 2, 61, 162, 3, 2, 2, 2, 63, 184, 3, 2, 2, 2, 65, 186, 3, 2, 2, 2, 67, 197, 3, 2, 2, 2, 69, 206, 3, 2, 2, 2, 71, 210, 3, 2, 2, 2, 73, 74, 7, 126, 2, 2, 74, 75, 7, 126, 2, 2, 75, 4, 3, 2, 2, 2, 76, 77, 7, 40, 2, 2, 77, 78, 7, 40, 2, 2, 78, 6, 3, 2, 2, 2, 79, 80, 7, 63, 2, 2, 80, 81, 7, 63, 2, 2, 81, 8, 3, 2, 2, 2, 82, 83, 7, 35, 2, 2, 83, 84, 7, 63, 2, 2, 84, 10, 3, 2, 2, 2, 85, 86, 7, 64, 2, 2, 86, 12, 3, 2, 2, 2, 87, 88, 7, 62, 2, 2, 88, 14, 3, 2, 2, 2, 89, 90, 7, 64, 2, 2, 90, 91, 7, 63, 2, 2, 91, 16, 3, 2, 2, 2, 92, 93, 7, 62, 2, 2, 93, 94, 7, 63, 2, 2, 94, 18, 3, 2, 2, 2, 95, 96, 7, 45, 2, 2, 96, 20, 3, 2, 2, 2, 97, 98, 7, 47, 2, 2, 98, 22, 3, 2, 2, 2, 99, 100, 7, 44, 2, 2, 100, 24, 3, 2, 2, 2, 101, 102, 7, 49, 2, 2, 102, 26, 3, 2, 2, 2, 103, 104, 7, 39, 2, 2, 104, 28, 3, 2, 2, 2, 105, 106, 7, 96, 2, 2, 106, 30, 3, 2, 2, 2, 107, 108, 7, 35, 2, 2, 108, 32, 3, 2, 2, 2, 109, 110, 7, 61, 2, 2, 110, 34, 3, 2, 2, 2, 111, 112, 7, 63, 2, 2, 112, 36, 3, 2, 2, 2, 113, 114, 7, 42, 2, 2, 114, 38, 3, 2, 2, 2, 115, 116, 7, 43, 2, 2, 116, 40, 3, 2, 2, 2, 117, 118, 7, 125, 2, 2, 118, 42, 3, 2, 2, 2, 119, 120, 7, 127, 2, 2, 120, 44, 3, 2, 2, 2, 121, 122, 7, 118, 2, 2, 122, 123, 7, 116, 2, 2, 123, 124, 7, 119, 2, 2, 124, 125, 7, 103, 2, 2, 125, 46, 3, 2, 2, 2, 126, 127, 7, 104, 2, 2, 127, 128, 7, 99, 2, 2, 128, 129, 7, 110, 2, 2, 129, 130, 7, 117, 2, 2, 130, 131, 7, 103, 2, 2, 131, 48, 3, 2, 2, 2, 132, 133, 7, 112, 2, 2, 133, 134, 7, 107, 2, 2, 134, 135, 7, 110, 2, 2, 135, 50, 3, 2, 2, 2, 136, 137, 7, 107, 2, 2, 137, 138, 7, 104, 2, 2, 138, 52, 3, 2, 2, 2, 139, 140, 7, 103, 2, 2, 140, 141, 7, 110, 2, 2, 141, 142, 7, 117, 2, 2, 142, 143, 7, 103, 2, 2, 143, 54, 3, 2, 2, 2, 144, 145, 7, 121, 2, 2, 145, 146, 7, 106, 2, 2, 146, 147, 7, 107, 2, 2, 147, 148, 7, 110, 2, 2, 148, 149, 7, 103, 2, 2, 149, 56, 3, 2, 2, 2, 150, 151, 7, 110, 2, 2, 151, 152, 7, 113, 2, 2, 152, 153, 7, 105, 2, 2, 153, 58, 3, 2, 2, 2, 154, 158, 9, 2, 2, 2, 155, 157, 9, 3, 2, 2, 156, 155, 3, 2, 2, 2, 157, 160, 3, 2, 2, 2, 158, 156, 3, 2, 2, 2, 158, 159, 3, 2, 2, 2, 159, 60, 3, 2, 2, 2, 160, 158, 3, 2, 2, 2, 161, 163, 9, 4, 2, 2, 162, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 162, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 62, 3, 2, 2, 2, 166, 168, 9, 4, 2, 2, 167, 166, 3, 2, 2, 2, 168, 169, 3, 2, 2, 2, 169, 167, 3, 2, 2, 2, 169, 170, 3, 2, 2, 2, 170, 171, 3, 2, 2, 2, 171, 175, 7, 48, 2, 2, 172, 174, 9, 4, 2, 2, 173, 172, 3, 2, 2, 2, 174, 177, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 175, 176, 3, 2, 2, 2, 176, 185, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 178, 180, 7, 48, 2, 2, 179, 181, 9, 4, 2, 2, 180, 179, 3, 2, 2, 2, 181, 182, 3, 2, 2, 2, 182, 180, 3, 2, 2, 2, 182, 183, 3, 2, 2, 2, 183, 185, 3, 2, 2, 2, 184, 167, 3, 2, 2, 2, 184, 178, 3, 2, 2, 2, 185, 64, 3, 2, 2, 2, 186, 192, 7, 36, 2, 2, 187, 191, 10, 5, 2, 2, 188, 189, 7, 36, 2, 2, 189, 191, 7, 36, 2, 2, 190, 187, 3, 2, 2, 2, 190, 188, 3, 2, 2, 2, 191, 194, 3, 2, 2, 2, 192, 190, 3, 2, 2, 2, 192, 193, 3, 2, 2, 2, 193, 195, 3, 2, 2, 2, 194, 192, 3, 2, 2, 2, 195, 196, 7, 36, 2, 2, 196, 66, 3, 2, 2, 2, 197, 201, 7, 37, 2, 2, 198, 200, 10, 6, 2, 2, 199, 198, 3, 2, 2, 2, 200, 203, 3, 2, 2, 2, 201, 199, 3, 2, 2, 2, 201, 202, 3, 2, 2, 2, 202, 204, 3, 2, 2, 2, 203, 201, 3, 2, 2, 2, 204, 205, 8, 34, 2, 2, 205, 68, 3, 2, 2, 2, 206, 207, 9, 7, 2, 2, 207, 208, 3, 2, 2, 2, 208, 209, 8, 35, 2, 2, 209, 70, 3, 2, 2, 2, 210, 211, 11, 2, 2, 2, 211, 72, 3, 2, 2, 2, 12, 2, 158, 164, 169, 175, 182, 184, 190, 192, 201, 3, 8, 2, 2] \ No newline at end of file diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.java b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.java new file mode 100644 index 0000000..a6c6af3 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.java @@ -0,0 +1,183 @@ +// Generated from /home/marvin/Documents/university/compiler/antlr_test/klang/klang/src/main/antlr4/de/hsrm/compiler/Klang/Klang.g4 by ANTLR 4.7.1 +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class KlangLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + OR=1, AND=2, EQ=3, NEQ=4, GT=5, LT=6, GTEQ=7, LTEQ=8, PLUS=9, MINUS=10, + MULT=11, DIV=12, MOD=13, POW=14, NOT=15, SCOL=16, ASSIGN=17, OPAR=18, + CPAR=19, OBRACE=20, CBRACE=21, TRUE=22, FALSE=23, NIL=24, IF=25, ELSE=26, + WHILE=27, LOG=28, ID=29, INT=30, FLOAT=31, STRING=32, COMMENT=33, SPACE=34, + OTHER=35; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + public static final String[] ruleNames = { + "OR", "AND", "EQ", "NEQ", "GT", "LT", "GTEQ", "LTEQ", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "POW", "NOT", "SCOL", "ASSIGN", "OPAR", "CPAR", + "OBRACE", "CBRACE", "TRUE", "FALSE", "NIL", "IF", "ELSE", "WHILE", "LOG", + "ID", "INT", "FLOAT", "STRING", "COMMENT", "SPACE", "OTHER" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'||'", "'&&'", "'=='", "'!='", "'>'", "'<'", "'>='", "'<='", "'+'", + "'-'", "'*'", "'/'", "'%'", "'^'", "'!'", "';'", "'='", "'('", "')'", + "'{'", "'}'", "'true'", "'false'", "'nil'", "'if'", "'else'", "'while'", + "'log'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, "OR", "AND", "EQ", "NEQ", "GT", "LT", "GTEQ", "LTEQ", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "POW", "NOT", "SCOL", "ASSIGN", "OPAR", "CPAR", + "OBRACE", "CBRACE", "TRUE", "FALSE", "NIL", "IF", "ELSE", "WHILE", "LOG", + "ID", "INT", "FLOAT", "STRING", "COMMENT", "SPACE", "OTHER" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public KlangLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "Klang.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2%\u00d4\b\1\4\2\t"+ + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ + "\t!\4\"\t\"\4#\t#\4$\t$\3\2\3\2\3\2\3\3\3\3\3\3\3\4\3\4\3\4\3\5\3\5\3"+ + "\5\3\6\3\6\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3"+ + "\r\3\r\3\16\3\16\3\17\3\17\3\20\3\20\3\21\3\21\3\22\3\22\3\23\3\23\3\24"+ + "\3\24\3\25\3\25\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30"+ + "\3\30\3\30\3\31\3\31\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33"+ + "\3\34\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\36\3\36\7\36\u009d"+ + "\n\36\f\36\16\36\u00a0\13\36\3\37\6\37\u00a3\n\37\r\37\16\37\u00a4\3 "+ + "\6 \u00a8\n \r \16 \u00a9\3 \3 \7 \u00ae\n \f \16 \u00b1\13 \3 \3 \6 "+ + "\u00b5\n \r \16 \u00b6\5 \u00b9\n \3!\3!\3!\3!\7!\u00bf\n!\f!\16!\u00c2"+ + "\13!\3!\3!\3\"\3\"\7\"\u00c8\n\"\f\"\16\"\u00cb\13\"\3\"\3\"\3#\3#\3#"+ + "\3#\3$\3$\2\2%\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16"+ + "\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34"+ + "\67\359\36;\37= ?!A\"C#E$G%\3\2\b\5\2C\\aac|\6\2\62;C\\aac|\3\2\62;\5"+ + "\2\f\f\17\17$$\4\2\f\f\17\17\5\2\13\f\17\17\"\"\2\u00dc\2\3\3\2\2\2\2"+ + "\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2"+ + "\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2"+ + "\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2"+ + "\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2"+ + "\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2"+ + "\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\3I\3\2\2\2\5"+ + "L\3\2\2\2\7O\3\2\2\2\tR\3\2\2\2\13U\3\2\2\2\rW\3\2\2\2\17Y\3\2\2\2\21"+ + "\\\3\2\2\2\23_\3\2\2\2\25a\3\2\2\2\27c\3\2\2\2\31e\3\2\2\2\33g\3\2\2\2"+ + "\35i\3\2\2\2\37k\3\2\2\2!m\3\2\2\2#o\3\2\2\2%q\3\2\2\2\'s\3\2\2\2)u\3"+ + "\2\2\2+w\3\2\2\2-y\3\2\2\2/~\3\2\2\2\61\u0084\3\2\2\2\63\u0088\3\2\2\2"+ + "\65\u008b\3\2\2\2\67\u0090\3\2\2\29\u0096\3\2\2\2;\u009a\3\2\2\2=\u00a2"+ + "\3\2\2\2?\u00b8\3\2\2\2A\u00ba\3\2\2\2C\u00c5\3\2\2\2E\u00ce\3\2\2\2G"+ + "\u00d2\3\2\2\2IJ\7~\2\2JK\7~\2\2K\4\3\2\2\2LM\7(\2\2MN\7(\2\2N\6\3\2\2"+ + "\2OP\7?\2\2PQ\7?\2\2Q\b\3\2\2\2RS\7#\2\2ST\7?\2\2T\n\3\2\2\2UV\7@\2\2"+ + "V\f\3\2\2\2WX\7>\2\2X\16\3\2\2\2YZ\7@\2\2Z[\7?\2\2[\20\3\2\2\2\\]\7>\2"+ + "\2]^\7?\2\2^\22\3\2\2\2_`\7-\2\2`\24\3\2\2\2ab\7/\2\2b\26\3\2\2\2cd\7"+ + ",\2\2d\30\3\2\2\2ef\7\61\2\2f\32\3\2\2\2gh\7\'\2\2h\34\3\2\2\2ij\7`\2"+ + "\2j\36\3\2\2\2kl\7#\2\2l \3\2\2\2mn\7=\2\2n\"\3\2\2\2op\7?\2\2p$\3\2\2"+ + "\2qr\7*\2\2r&\3\2\2\2st\7+\2\2t(\3\2\2\2uv\7}\2\2v*\3\2\2\2wx\7\177\2"+ + "\2x,\3\2\2\2yz\7v\2\2z{\7t\2\2{|\7w\2\2|}\7g\2\2}.\3\2\2\2~\177\7h\2\2"+ + "\177\u0080\7c\2\2\u0080\u0081\7n\2\2\u0081\u0082\7u\2\2\u0082\u0083\7"+ + "g\2\2\u0083\60\3\2\2\2\u0084\u0085\7p\2\2\u0085\u0086\7k\2\2\u0086\u0087"+ + "\7n\2\2\u0087\62\3\2\2\2\u0088\u0089\7k\2\2\u0089\u008a\7h\2\2\u008a\64"+ + "\3\2\2\2\u008b\u008c\7g\2\2\u008c\u008d\7n\2\2\u008d\u008e\7u\2\2\u008e"+ + "\u008f\7g\2\2\u008f\66\3\2\2\2\u0090\u0091\7y\2\2\u0091\u0092\7j\2\2\u0092"+ + "\u0093\7k\2\2\u0093\u0094\7n\2\2\u0094\u0095\7g\2\2\u00958\3\2\2\2\u0096"+ + "\u0097\7n\2\2\u0097\u0098\7q\2\2\u0098\u0099\7i\2\2\u0099:\3\2\2\2\u009a"+ + "\u009e\t\2\2\2\u009b\u009d\t\3\2\2\u009c\u009b\3\2\2\2\u009d\u00a0\3\2"+ + "\2\2\u009e\u009c\3\2\2\2\u009e\u009f\3\2\2\2\u009f<\3\2\2\2\u00a0\u009e"+ + "\3\2\2\2\u00a1\u00a3\t\4\2\2\u00a2\u00a1\3\2\2\2\u00a3\u00a4\3\2\2\2\u00a4"+ + "\u00a2\3\2\2\2\u00a4\u00a5\3\2\2\2\u00a5>\3\2\2\2\u00a6\u00a8\t\4\2\2"+ + "\u00a7\u00a6\3\2\2\2\u00a8\u00a9\3\2\2\2\u00a9\u00a7\3\2\2\2\u00a9\u00aa"+ + "\3\2\2\2\u00aa\u00ab\3\2\2\2\u00ab\u00af\7\60\2\2\u00ac\u00ae\t\4\2\2"+ + "\u00ad\u00ac\3\2\2\2\u00ae\u00b1\3\2\2\2\u00af\u00ad\3\2\2\2\u00af\u00b0"+ + "\3\2\2\2\u00b0\u00b9\3\2\2\2\u00b1\u00af\3\2\2\2\u00b2\u00b4\7\60\2\2"+ + "\u00b3\u00b5\t\4\2\2\u00b4\u00b3\3\2\2\2\u00b5\u00b6\3\2\2\2\u00b6\u00b4"+ + "\3\2\2\2\u00b6\u00b7\3\2\2\2\u00b7\u00b9\3\2\2\2\u00b8\u00a7\3\2\2\2\u00b8"+ + "\u00b2\3\2\2\2\u00b9@\3\2\2\2\u00ba\u00c0\7$\2\2\u00bb\u00bf\n\5\2\2\u00bc"+ + "\u00bd\7$\2\2\u00bd\u00bf\7$\2\2\u00be\u00bb\3\2\2\2\u00be\u00bc\3\2\2"+ + "\2\u00bf\u00c2\3\2\2\2\u00c0\u00be\3\2\2\2\u00c0\u00c1\3\2\2\2\u00c1\u00c3"+ + "\3\2\2\2\u00c2\u00c0\3\2\2\2\u00c3\u00c4\7$\2\2\u00c4B\3\2\2\2\u00c5\u00c9"+ + "\7%\2\2\u00c6\u00c8\n\6\2\2\u00c7\u00c6\3\2\2\2\u00c8\u00cb\3\2\2\2\u00c9"+ + "\u00c7\3\2\2\2\u00c9\u00ca\3\2\2\2\u00ca\u00cc\3\2\2\2\u00cb\u00c9\3\2"+ + "\2\2\u00cc\u00cd\b\"\2\2\u00cdD\3\2\2\2\u00ce\u00cf\t\7\2\2\u00cf\u00d0"+ + "\3\2\2\2\u00d0\u00d1\b#\2\2\u00d1F\3\2\2\2\u00d2\u00d3\13\2\2\2\u00d3"+ + "H\3\2\2\2\f\2\u009e\u00a4\u00a9\u00af\u00b6\u00b8\u00be\u00c0\u00c9\3"+ + "\b\2\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.tokens b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.tokens new file mode 100644 index 0000000..d69c013 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangLexer.tokens @@ -0,0 +1,63 @@ +OR=1 +AND=2 +EQ=3 +NEQ=4 +GT=5 +LT=6 +GTEQ=7 +LTEQ=8 +PLUS=9 +MINUS=10 +MULT=11 +DIV=12 +MOD=13 +POW=14 +NOT=15 +SCOL=16 +ASSIGN=17 +OPAR=18 +CPAR=19 +OBRACE=20 +CBRACE=21 +TRUE=22 +FALSE=23 +NIL=24 +IF=25 +ELSE=26 +WHILE=27 +LOG=28 +ID=29 +INT=30 +FLOAT=31 +STRING=32 +COMMENT=33 +SPACE=34 +OTHER=35 +'||'=1 +'&&'=2 +'=='=3 +'!='=4 +'>'=5 +'<'=6 +'>='=7 +'<='=8 +'+'=9 +'-'=10 +'*'=11 +'/'=12 +'%'=13 +'^'=14 +'!'=15 +';'=16 +'='=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'true'=22 +'false'=23 +'nil'=24 +'if'=25 +'else'=26 +'while'=27 +'log'=28 diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangParser.java b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangParser.java new file mode 100644 index 0000000..eec12e5 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/KlangParser.java @@ -0,0 +1,1074 @@ +// Generated from /home/marvin/Documents/university/compiler/antlr_test/klang/klang/src/main/antlr4/de/hsrm/compiler/Klang/Klang.g4 by ANTLR 4.7.1 +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class KlangParser extends Parser { + static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + OR=1, AND=2, EQ=3, NEQ=4, GT=5, LT=6, GTEQ=7, LTEQ=8, PLUS=9, MINUS=10, + MULT=11, DIV=12, MOD=13, POW=14, NOT=15, SCOL=16, ASSIGN=17, OPAR=18, + CPAR=19, OBRACE=20, CBRACE=21, TRUE=22, FALSE=23, NIL=24, IF=25, ELSE=26, + WHILE=27, LOG=28, ID=29, INT=30, FLOAT=31, STRING=32, COMMENT=33, SPACE=34, + OTHER=35; + public static final int + RULE_parse = 0, RULE_block = 1, RULE_stat = 2, RULE_assignment = 3, RULE_if_stat = 4, + RULE_condition_block = 5, RULE_stat_block = 6, RULE_while_stat = 7, RULE_log = 8, + RULE_expr = 9, RULE_atom = 10; + public static final String[] ruleNames = { + "parse", "block", "stat", "assignment", "if_stat", "condition_block", + "stat_block", "while_stat", "log", "expr", "atom" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'||'", "'&&'", "'=='", "'!='", "'>'", "'<'", "'>='", "'<='", "'+'", + "'-'", "'*'", "'/'", "'%'", "'^'", "'!'", "';'", "'='", "'('", "')'", + "'{'", "'}'", "'true'", "'false'", "'nil'", "'if'", "'else'", "'while'", + "'log'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, "OR", "AND", "EQ", "NEQ", "GT", "LT", "GTEQ", "LTEQ", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "POW", "NOT", "SCOL", "ASSIGN", "OPAR", "CPAR", + "OBRACE", "CBRACE", "TRUE", "FALSE", "NIL", "IF", "ELSE", "WHILE", "LOG", + "ID", "INT", "FLOAT", "STRING", "COMMENT", "SPACE", "OTHER" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "Klang.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public KlangParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + public static class ParseContext extends ParserRuleContext { + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TerminalNode EOF() { return getToken(KlangParser.EOF, 0); } + public ParseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_parse; } + } + + public final ParseContext parse() throws RecognitionException { + ParseContext _localctx = new ParseContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_parse); + try { + enterOuterAlt(_localctx, 1); + { + setState(22); + block(); + setState(23); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class BlockContext extends ParserRuleContext { + public List stat() { + return getRuleContexts(StatContext.class); + } + public StatContext stat(int i) { + return getRuleContext(StatContext.class,i); + } + public BlockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_block; } + } + + public final BlockContext block() throws RecognitionException { + BlockContext _localctx = new BlockContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_block); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(28); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << IF) | (1L << WHILE) | (1L << LOG) | (1L << ID) | (1L << OTHER))) != 0)) { + { + { + setState(25); + stat(); + } + } + setState(30); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class StatContext extends ParserRuleContext { + public Token OTHER; + public AssignmentContext assignment() { + return getRuleContext(AssignmentContext.class,0); + } + public If_statContext if_stat() { + return getRuleContext(If_statContext.class,0); + } + public While_statContext while_stat() { + return getRuleContext(While_statContext.class,0); + } + public LogContext log() { + return getRuleContext(LogContext.class,0); + } + public TerminalNode OTHER() { return getToken(KlangParser.OTHER, 0); } + public StatContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_stat; } + } + + public final StatContext stat() throws RecognitionException { + StatContext _localctx = new StatContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_stat); + try { + setState(37); + _errHandler.sync(this); + switch (_input.LA(1)) { + case ID: + enterOuterAlt(_localctx, 1); + { + setState(31); + assignment(); + } + break; + case IF: + enterOuterAlt(_localctx, 2); + { + setState(32); + if_stat(); + } + break; + case WHILE: + enterOuterAlt(_localctx, 3); + { + setState(33); + while_stat(); + } + break; + case LOG: + enterOuterAlt(_localctx, 4); + { + setState(34); + log(); + } + break; + case OTHER: + enterOuterAlt(_localctx, 5); + { + setState(35); + ((StatContext)_localctx).OTHER = match(OTHER); + System.err.println("unknown char: " + (((StatContext)_localctx).OTHER!=null?((StatContext)_localctx).OTHER.getText():null)); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class AssignmentContext extends ParserRuleContext { + public TerminalNode ID() { return getToken(KlangParser.ID, 0); } + public TerminalNode ASSIGN() { return getToken(KlangParser.ASSIGN, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode SCOL() { return getToken(KlangParser.SCOL, 0); } + public AssignmentContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_assignment; } + } + + public final AssignmentContext assignment() throws RecognitionException { + AssignmentContext _localctx = new AssignmentContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_assignment); + try { + enterOuterAlt(_localctx, 1); + { + setState(39); + match(ID); + setState(40); + match(ASSIGN); + setState(41); + expr(0); + setState(42); + match(SCOL); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class If_statContext extends ParserRuleContext { + public List IF() { return getTokens(KlangParser.IF); } + public TerminalNode IF(int i) { + return getToken(KlangParser.IF, i); + } + public List condition_block() { + return getRuleContexts(Condition_blockContext.class); + } + public Condition_blockContext condition_block(int i) { + return getRuleContext(Condition_blockContext.class,i); + } + public List ELSE() { return getTokens(KlangParser.ELSE); } + public TerminalNode ELSE(int i) { + return getToken(KlangParser.ELSE, i); + } + public Stat_blockContext stat_block() { + return getRuleContext(Stat_blockContext.class,0); + } + public If_statContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_if_stat; } + } + + public final If_statContext if_stat() throws RecognitionException { + If_statContext _localctx = new If_statContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_if_stat); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(44); + match(IF); + setState(45); + condition_block(); + setState(51); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(46); + match(ELSE); + setState(47); + match(IF); + setState(48); + condition_block(); + } + } + } + setState(53); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + } + setState(56); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { + case 1: + { + setState(54); + match(ELSE); + setState(55); + stat_block(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Condition_blockContext extends ParserRuleContext { + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public Stat_blockContext stat_block() { + return getRuleContext(Stat_blockContext.class,0); + } + public Condition_blockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_condition_block; } + } + + public final Condition_blockContext condition_block() throws RecognitionException { + Condition_blockContext _localctx = new Condition_blockContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_condition_block); + try { + enterOuterAlt(_localctx, 1); + { + setState(58); + expr(0); + setState(59); + stat_block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Stat_blockContext extends ParserRuleContext { + public TerminalNode OBRACE() { return getToken(KlangParser.OBRACE, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TerminalNode CBRACE() { return getToken(KlangParser.CBRACE, 0); } + public StatContext stat() { + return getRuleContext(StatContext.class,0); + } + public Stat_blockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_stat_block; } + } + + public final Stat_blockContext stat_block() throws RecognitionException { + Stat_blockContext _localctx = new Stat_blockContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_stat_block); + try { + setState(66); + _errHandler.sync(this); + switch (_input.LA(1)) { + case OBRACE: + enterOuterAlt(_localctx, 1); + { + setState(61); + match(OBRACE); + setState(62); + block(); + setState(63); + match(CBRACE); + } + break; + case IF: + case WHILE: + case LOG: + case ID: + case OTHER: + enterOuterAlt(_localctx, 2); + { + setState(65); + stat(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class While_statContext extends ParserRuleContext { + public TerminalNode WHILE() { return getToken(KlangParser.WHILE, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public Stat_blockContext stat_block() { + return getRuleContext(Stat_blockContext.class,0); + } + public While_statContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_while_stat; } + } + + public final While_statContext while_stat() throws RecognitionException { + While_statContext _localctx = new While_statContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_while_stat); + try { + enterOuterAlt(_localctx, 1); + { + setState(68); + match(WHILE); + setState(69); + expr(0); + setState(70); + stat_block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class LogContext extends ParserRuleContext { + public TerminalNode LOG() { return getToken(KlangParser.LOG, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode SCOL() { return getToken(KlangParser.SCOL, 0); } + public LogContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_log; } + } + + public final LogContext log() throws RecognitionException { + LogContext _localctx = new LogContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_log); + try { + enterOuterAlt(_localctx, 1); + { + setState(72); + match(LOG); + setState(73); + expr(0); + setState(74); + match(SCOL); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class ExprContext extends ParserRuleContext { + public ExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expr; } + + public ExprContext() { } + public void copyFrom(ExprContext ctx) { + super.copyFrom(ctx); + } + } + public static class NotExprContext extends ExprContext { + public TerminalNode NOT() { return getToken(KlangParser.NOT, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public NotExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class UnaryMinusExprContext extends ExprContext { + public TerminalNode MINUS() { return getToken(KlangParser.MINUS, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public UnaryMinusExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class MultiplicationExprContext extends ExprContext { + public Token op; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode MULT() { return getToken(KlangParser.MULT, 0); } + public TerminalNode DIV() { return getToken(KlangParser.DIV, 0); } + public TerminalNode MOD() { return getToken(KlangParser.MOD, 0); } + public MultiplicationExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class AtomExprContext extends ExprContext { + public AtomContext atom() { + return getRuleContext(AtomContext.class,0); + } + public AtomExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class OrExprContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode OR() { return getToken(KlangParser.OR, 0); } + public OrExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class AdditiveExprContext extends ExprContext { + public Token op; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode PLUS() { return getToken(KlangParser.PLUS, 0); } + public TerminalNode MINUS() { return getToken(KlangParser.MINUS, 0); } + public AdditiveExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class PowExprContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode POW() { return getToken(KlangParser.POW, 0); } + public PowExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class RelationalExprContext extends ExprContext { + public Token op; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode LTEQ() { return getToken(KlangParser.LTEQ, 0); } + public TerminalNode GTEQ() { return getToken(KlangParser.GTEQ, 0); } + public TerminalNode LT() { return getToken(KlangParser.LT, 0); } + public TerminalNode GT() { return getToken(KlangParser.GT, 0); } + public RelationalExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class EqualityExprContext extends ExprContext { + public Token op; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode EQ() { return getToken(KlangParser.EQ, 0); } + public TerminalNode NEQ() { return getToken(KlangParser.NEQ, 0); } + public EqualityExprContext(ExprContext ctx) { copyFrom(ctx); } + } + public static class AndExprContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode AND() { return getToken(KlangParser.AND, 0); } + public AndExprContext(ExprContext ctx) { copyFrom(ctx); } + } + + public final ExprContext expr() throws RecognitionException { + return expr(0); + } + + private ExprContext expr(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + ExprContext _localctx = new ExprContext(_ctx, _parentState); + ExprContext _prevctx = _localctx; + int _startState = 18; + enterRecursionRule(_localctx, 18, RULE_expr, _p); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(82); + _errHandler.sync(this); + switch (_input.LA(1)) { + case MINUS: + { + _localctx = new UnaryMinusExprContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(77); + match(MINUS); + setState(78); + expr(9); + } + break; + case NOT: + { + _localctx = new NotExprContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(79); + match(NOT); + setState(80); + expr(8); + } + break; + case OPAR: + case TRUE: + case FALSE: + case NIL: + case ID: + case INT: + case FLOAT: + case STRING: + { + _localctx = new AtomExprContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(81); + atom(); + } + break; + default: + throw new NoViableAltException(this); + } + _ctx.stop = _input.LT(-1); + setState(107); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,7,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(105); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { + case 1: + { + _localctx = new PowExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(84); + if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); + setState(85); + match(POW); + setState(86); + expr(11); + } + break; + case 2: + { + _localctx = new MultiplicationExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(87); + if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); + setState(88); + ((MultiplicationExprContext)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << MULT) | (1L << DIV) | (1L << MOD))) != 0)) ) { + ((MultiplicationExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(89); + expr(8); + } + break; + case 3: + { + _localctx = new AdditiveExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(90); + if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); + setState(91); + ((AdditiveExprContext)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !(_la==PLUS || _la==MINUS) ) { + ((AdditiveExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(92); + expr(7); + } + break; + case 4: + { + _localctx = new RelationalExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(93); + if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); + setState(94); + ((RelationalExprContext)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << GT) | (1L << LT) | (1L << GTEQ) | (1L << LTEQ))) != 0)) ) { + ((RelationalExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(95); + expr(6); + } + break; + case 5: + { + _localctx = new EqualityExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(96); + if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)"); + setState(97); + ((EqualityExprContext)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !(_la==EQ || _la==NEQ) ) { + ((EqualityExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(98); + expr(5); + } + break; + case 6: + { + _localctx = new AndExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(99); + if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)"); + setState(100); + match(AND); + setState(101); + expr(4); + } + break; + case 7: + { + _localctx = new OrExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(102); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(103); + match(OR); + setState(104); + expr(3); + } + break; + } + } + } + setState(109); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,7,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + public static class AtomContext extends ParserRuleContext { + public AtomContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_atom; } + + public AtomContext() { } + public void copyFrom(AtomContext ctx) { + super.copyFrom(ctx); + } + } + public static class ParExprContext extends AtomContext { + public TerminalNode OPAR() { return getToken(KlangParser.OPAR, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode CPAR() { return getToken(KlangParser.CPAR, 0); } + public ParExprContext(AtomContext ctx) { copyFrom(ctx); } + } + public static class BooleanAtomContext extends AtomContext { + public TerminalNode TRUE() { return getToken(KlangParser.TRUE, 0); } + public TerminalNode FALSE() { return getToken(KlangParser.FALSE, 0); } + public BooleanAtomContext(AtomContext ctx) { copyFrom(ctx); } + } + public static class IdAtomContext extends AtomContext { + public TerminalNode ID() { return getToken(KlangParser.ID, 0); } + public IdAtomContext(AtomContext ctx) { copyFrom(ctx); } + } + public static class StringAtomContext extends AtomContext { + public TerminalNode STRING() { return getToken(KlangParser.STRING, 0); } + public StringAtomContext(AtomContext ctx) { copyFrom(ctx); } + } + public static class NilAtomContext extends AtomContext { + public TerminalNode NIL() { return getToken(KlangParser.NIL, 0); } + public NilAtomContext(AtomContext ctx) { copyFrom(ctx); } + } + public static class NumberAtomContext extends AtomContext { + public TerminalNode INT() { return getToken(KlangParser.INT, 0); } + public TerminalNode FLOAT() { return getToken(KlangParser.FLOAT, 0); } + public NumberAtomContext(AtomContext ctx) { copyFrom(ctx); } + } + + public final AtomContext atom() throws RecognitionException { + AtomContext _localctx = new AtomContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_atom); + int _la; + try { + setState(119); + _errHandler.sync(this); + switch (_input.LA(1)) { + case OPAR: + _localctx = new ParExprContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(110); + match(OPAR); + setState(111); + expr(0); + setState(112); + match(CPAR); + } + break; + case INT: + case FLOAT: + _localctx = new NumberAtomContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(114); + _la = _input.LA(1); + if ( !(_la==INT || _la==FLOAT) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + break; + case TRUE: + case FALSE: + _localctx = new BooleanAtomContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(115); + _la = _input.LA(1); + if ( !(_la==TRUE || _la==FALSE) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + break; + case ID: + _localctx = new IdAtomContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(116); + match(ID); + } + break; + case STRING: + _localctx = new StringAtomContext(_localctx); + enterOuterAlt(_localctx, 5); + { + setState(117); + match(STRING); + } + break; + case NIL: + _localctx = new NilAtomContext(_localctx); + enterOuterAlt(_localctx, 6); + { + setState(118); + match(NIL); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 9: + return expr_sempred((ExprContext)_localctx, predIndex); + } + return true; + } + private boolean expr_sempred(ExprContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 10); + case 1: + return precpred(_ctx, 7); + case 2: + return precpred(_ctx, 6); + case 3: + return precpred(_ctx, 5); + case 4: + return precpred(_ctx, 4); + case 5: + return precpred(_ctx, 3); + case 6: + return precpred(_ctx, 2); + } + return true; + } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3%|\4\2\t\2\4\3\t\3"+ + "\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f"+ + "\t\f\3\2\3\2\3\2\3\3\7\3\35\n\3\f\3\16\3 \13\3\3\4\3\4\3\4\3\4\3\4\3\4"+ + "\5\4(\n\4\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\7\6\64\n\6\f\6\16\6"+ + "\67\13\6\3\6\3\6\5\6;\n\6\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\5\bE\n\b\3\t"+ + "\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\5\13U\n\13"+ + "\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13"+ + "\3\13\3\13\3\13\3\13\3\13\3\13\3\13\7\13l\n\13\f\13\16\13o\13\13\3\f\3"+ + "\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\5\fz\n\f\3\f\2\3\24\r\2\4\6\b\n\f\16\20"+ + "\22\24\26\2\b\3\2\r\17\3\2\13\f\3\2\7\n\3\2\5\6\3\2 !\3\2\30\31\2\u0086"+ + "\2\30\3\2\2\2\4\36\3\2\2\2\6\'\3\2\2\2\b)\3\2\2\2\n.\3\2\2\2\f<\3\2\2"+ + "\2\16D\3\2\2\2\20F\3\2\2\2\22J\3\2\2\2\24T\3\2\2\2\26y\3\2\2\2\30\31\5"+ + "\4\3\2\31\32\7\2\2\3\32\3\3\2\2\2\33\35\5\6\4\2\34\33\3\2\2\2\35 \3\2"+ + "\2\2\36\34\3\2\2\2\36\37\3\2\2\2\37\5\3\2\2\2 \36\3\2\2\2!(\5\b\5\2\""+ + "(\5\n\6\2#(\5\20\t\2$(\5\22\n\2%&\7%\2\2&(\b\4\1\2\'!\3\2\2\2\'\"\3\2"+ + "\2\2\'#\3\2\2\2\'$\3\2\2\2\'%\3\2\2\2(\7\3\2\2\2)*\7\37\2\2*+\7\23\2\2"+ + "+,\5\24\13\2,-\7\22\2\2-\t\3\2\2\2./\7\33\2\2/\65\5\f\7\2\60\61\7\34\2"+ + "\2\61\62\7\33\2\2\62\64\5\f\7\2\63\60\3\2\2\2\64\67\3\2\2\2\65\63\3\2"+ + "\2\2\65\66\3\2\2\2\66:\3\2\2\2\67\65\3\2\2\289\7\34\2\29;\5\16\b\2:8\3"+ + "\2\2\2:;\3\2\2\2;\13\3\2\2\2<=\5\24\13\2=>\5\16\b\2>\r\3\2\2\2?@\7\26"+ + "\2\2@A\5\4\3\2AB\7\27\2\2BE\3\2\2\2CE\5\6\4\2D?\3\2\2\2DC\3\2\2\2E\17"+ + "\3\2\2\2FG\7\35\2\2GH\5\24\13\2HI\5\16\b\2I\21\3\2\2\2JK\7\36\2\2KL\5"+ + "\24\13\2LM\7\22\2\2M\23\3\2\2\2NO\b\13\1\2OP\7\f\2\2PU\5\24\13\13QR\7"+ + "\21\2\2RU\5\24\13\nSU\5\26\f\2TN\3\2\2\2TQ\3\2\2\2TS\3\2\2\2Um\3\2\2\2"+ + "VW\f\f\2\2WX\7\20\2\2Xl\5\24\13\rYZ\f\t\2\2Z[\t\2\2\2[l\5\24\13\n\\]\f"+ + "\b\2\2]^\t\3\2\2^l\5\24\13\t_`\f\7\2\2`a\t\4\2\2al\5\24\13\bbc\f\6\2\2"+ + "cd\t\5\2\2dl\5\24\13\7ef\f\5\2\2fg\7\4\2\2gl\5\24\13\6hi\f\4\2\2ij\7\3"+ + "\2\2jl\5\24\13\5kV\3\2\2\2kY\3\2\2\2k\\\3\2\2\2k_\3\2\2\2kb\3\2\2\2ke"+ + "\3\2\2\2kh\3\2\2\2lo\3\2\2\2mk\3\2\2\2mn\3\2\2\2n\25\3\2\2\2om\3\2\2\2"+ + "pq\7\24\2\2qr\5\24\13\2rs\7\25\2\2sz\3\2\2\2tz\t\6\2\2uz\t\7\2\2vz\7\37"+ + "\2\2wz\7\"\2\2xz\7\32\2\2yp\3\2\2\2yt\3\2\2\2yu\3\2\2\2yv\3\2\2\2yw\3"+ + "\2\2\2yx\3\2\2\2z\27\3\2\2\2\13\36\'\65:DTkmy"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.interp b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.interp new file mode 100644 index 0000000..b819235 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.interp @@ -0,0 +1,122 @@ +token literal names: +null +'||' +'&&' +'==' +'!=' +'>' +'<' +'>=' +'<=' +'+' +'-' +'*' +'/' +'%' +'^' +'!' +';' +'=' +'(' +')' +'{' +'}' +'true' +'false' +'nil' +'if' +'else' +'while' +'log' +null +null +null +null +null +null +null + +token symbolic names: +null +OR +AND +EQ +NEQ +GT +LT +GTEQ +LTEQ +PLUS +MINUS +MULT +DIV +MOD +POW +NOT +SCOL +ASSIGN +OPAR +CPAR +OBRACE +CBRACE +TRUE +FALSE +NIL +IF +ELSE +WHILE +LOG +ID +INT +FLOAT +STRING +COMMENT +SPACE +OTHER + +rule names: +OR +AND +EQ +NEQ +GT +LT +GTEQ +LTEQ +PLUS +MINUS +MULT +DIV +MOD +POW +NOT +SCOL +ASSIGN +OPAR +CPAR +OBRACE +CBRACE +TRUE +FALSE +NIL +IF +ELSE +WHILE +LOG +ID +INT +FLOAT +STRING +COMMENT +SPACE +OTHER + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 37, 212, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 7, 30, 157, 10, 30, 12, 30, 14, 30, 160, 11, 30, 3, 31, 6, 31, 163, 10, 31, 13, 31, 14, 31, 164, 3, 32, 6, 32, 168, 10, 32, 13, 32, 14, 32, 169, 3, 32, 3, 32, 7, 32, 174, 10, 32, 12, 32, 14, 32, 177, 11, 32, 3, 32, 3, 32, 6, 32, 181, 10, 32, 13, 32, 14, 32, 182, 5, 32, 185, 10, 32, 3, 33, 3, 33, 3, 33, 3, 33, 7, 33, 191, 10, 33, 12, 33, 14, 33, 194, 11, 33, 3, 33, 3, 33, 3, 34, 3, 34, 7, 34, 200, 10, 34, 12, 34, 14, 34, 203, 11, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 2, 2, 37, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 3, 2, 8, 5, 2, 67, 92, 97, 97, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 3, 2, 50, 59, 5, 2, 12, 12, 15, 15, 36, 36, 4, 2, 12, 12, 15, 15, 5, 2, 11, 12, 15, 15, 34, 34, 2, 220, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 3, 73, 3, 2, 2, 2, 5, 76, 3, 2, 2, 2, 7, 79, 3, 2, 2, 2, 9, 82, 3, 2, 2, 2, 11, 85, 3, 2, 2, 2, 13, 87, 3, 2, 2, 2, 15, 89, 3, 2, 2, 2, 17, 92, 3, 2, 2, 2, 19, 95, 3, 2, 2, 2, 21, 97, 3, 2, 2, 2, 23, 99, 3, 2, 2, 2, 25, 101, 3, 2, 2, 2, 27, 103, 3, 2, 2, 2, 29, 105, 3, 2, 2, 2, 31, 107, 3, 2, 2, 2, 33, 109, 3, 2, 2, 2, 35, 111, 3, 2, 2, 2, 37, 113, 3, 2, 2, 2, 39, 115, 3, 2, 2, 2, 41, 117, 3, 2, 2, 2, 43, 119, 3, 2, 2, 2, 45, 121, 3, 2, 2, 2, 47, 126, 3, 2, 2, 2, 49, 132, 3, 2, 2, 2, 51, 136, 3, 2, 2, 2, 53, 139, 3, 2, 2, 2, 55, 144, 3, 2, 2, 2, 57, 150, 3, 2, 2, 2, 59, 154, 3, 2, 2, 2, 61, 162, 3, 2, 2, 2, 63, 184, 3, 2, 2, 2, 65, 186, 3, 2, 2, 2, 67, 197, 3, 2, 2, 2, 69, 206, 3, 2, 2, 2, 71, 210, 3, 2, 2, 2, 73, 74, 7, 126, 2, 2, 74, 75, 7, 126, 2, 2, 75, 4, 3, 2, 2, 2, 76, 77, 7, 40, 2, 2, 77, 78, 7, 40, 2, 2, 78, 6, 3, 2, 2, 2, 79, 80, 7, 63, 2, 2, 80, 81, 7, 63, 2, 2, 81, 8, 3, 2, 2, 2, 82, 83, 7, 35, 2, 2, 83, 84, 7, 63, 2, 2, 84, 10, 3, 2, 2, 2, 85, 86, 7, 64, 2, 2, 86, 12, 3, 2, 2, 2, 87, 88, 7, 62, 2, 2, 88, 14, 3, 2, 2, 2, 89, 90, 7, 64, 2, 2, 90, 91, 7, 63, 2, 2, 91, 16, 3, 2, 2, 2, 92, 93, 7, 62, 2, 2, 93, 94, 7, 63, 2, 2, 94, 18, 3, 2, 2, 2, 95, 96, 7, 45, 2, 2, 96, 20, 3, 2, 2, 2, 97, 98, 7, 47, 2, 2, 98, 22, 3, 2, 2, 2, 99, 100, 7, 44, 2, 2, 100, 24, 3, 2, 2, 2, 101, 102, 7, 49, 2, 2, 102, 26, 3, 2, 2, 2, 103, 104, 7, 39, 2, 2, 104, 28, 3, 2, 2, 2, 105, 106, 7, 96, 2, 2, 106, 30, 3, 2, 2, 2, 107, 108, 7, 35, 2, 2, 108, 32, 3, 2, 2, 2, 109, 110, 7, 61, 2, 2, 110, 34, 3, 2, 2, 2, 111, 112, 7, 63, 2, 2, 112, 36, 3, 2, 2, 2, 113, 114, 7, 42, 2, 2, 114, 38, 3, 2, 2, 2, 115, 116, 7, 43, 2, 2, 116, 40, 3, 2, 2, 2, 117, 118, 7, 125, 2, 2, 118, 42, 3, 2, 2, 2, 119, 120, 7, 127, 2, 2, 120, 44, 3, 2, 2, 2, 121, 122, 7, 118, 2, 2, 122, 123, 7, 116, 2, 2, 123, 124, 7, 119, 2, 2, 124, 125, 7, 103, 2, 2, 125, 46, 3, 2, 2, 2, 126, 127, 7, 104, 2, 2, 127, 128, 7, 99, 2, 2, 128, 129, 7, 110, 2, 2, 129, 130, 7, 117, 2, 2, 130, 131, 7, 103, 2, 2, 131, 48, 3, 2, 2, 2, 132, 133, 7, 112, 2, 2, 133, 134, 7, 107, 2, 2, 134, 135, 7, 110, 2, 2, 135, 50, 3, 2, 2, 2, 136, 137, 7, 107, 2, 2, 137, 138, 7, 104, 2, 2, 138, 52, 3, 2, 2, 2, 139, 140, 7, 103, 2, 2, 140, 141, 7, 110, 2, 2, 141, 142, 7, 117, 2, 2, 142, 143, 7, 103, 2, 2, 143, 54, 3, 2, 2, 2, 144, 145, 7, 121, 2, 2, 145, 146, 7, 106, 2, 2, 146, 147, 7, 107, 2, 2, 147, 148, 7, 110, 2, 2, 148, 149, 7, 103, 2, 2, 149, 56, 3, 2, 2, 2, 150, 151, 7, 110, 2, 2, 151, 152, 7, 113, 2, 2, 152, 153, 7, 105, 2, 2, 153, 58, 3, 2, 2, 2, 154, 158, 9, 2, 2, 2, 155, 157, 9, 3, 2, 2, 156, 155, 3, 2, 2, 2, 157, 160, 3, 2, 2, 2, 158, 156, 3, 2, 2, 2, 158, 159, 3, 2, 2, 2, 159, 60, 3, 2, 2, 2, 160, 158, 3, 2, 2, 2, 161, 163, 9, 4, 2, 2, 162, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 162, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 62, 3, 2, 2, 2, 166, 168, 9, 4, 2, 2, 167, 166, 3, 2, 2, 2, 168, 169, 3, 2, 2, 2, 169, 167, 3, 2, 2, 2, 169, 170, 3, 2, 2, 2, 170, 171, 3, 2, 2, 2, 171, 175, 7, 48, 2, 2, 172, 174, 9, 4, 2, 2, 173, 172, 3, 2, 2, 2, 174, 177, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 175, 176, 3, 2, 2, 2, 176, 185, 3, 2, 2, 2, 177, 175, 3, 2, 2, 2, 178, 180, 7, 48, 2, 2, 179, 181, 9, 4, 2, 2, 180, 179, 3, 2, 2, 2, 181, 182, 3, 2, 2, 2, 182, 180, 3, 2, 2, 2, 182, 183, 3, 2, 2, 2, 183, 185, 3, 2, 2, 2, 184, 167, 3, 2, 2, 2, 184, 178, 3, 2, 2, 2, 185, 64, 3, 2, 2, 2, 186, 192, 7, 36, 2, 2, 187, 191, 10, 5, 2, 2, 188, 189, 7, 36, 2, 2, 189, 191, 7, 36, 2, 2, 190, 187, 3, 2, 2, 2, 190, 188, 3, 2, 2, 2, 191, 194, 3, 2, 2, 2, 192, 190, 3, 2, 2, 2, 192, 193, 3, 2, 2, 2, 193, 195, 3, 2, 2, 2, 194, 192, 3, 2, 2, 2, 195, 196, 7, 36, 2, 2, 196, 66, 3, 2, 2, 2, 197, 201, 7, 37, 2, 2, 198, 200, 10, 6, 2, 2, 199, 198, 3, 2, 2, 2, 200, 203, 3, 2, 2, 2, 201, 199, 3, 2, 2, 2, 201, 202, 3, 2, 2, 2, 202, 204, 3, 2, 2, 2, 203, 201, 3, 2, 2, 2, 204, 205, 8, 34, 2, 2, 205, 68, 3, 2, 2, 2, 206, 207, 9, 7, 2, 2, 207, 208, 3, 2, 2, 2, 208, 209, 8, 35, 2, 2, 209, 70, 3, 2, 2, 2, 210, 211, 11, 2, 2, 2, 211, 72, 3, 2, 2, 2, 12, 2, 158, 164, 169, 175, 182, 184, 190, 192, 201, 3, 8, 2, 2] \ No newline at end of file diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.java b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.java new file mode 100644 index 0000000..1c4e2f4 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.java @@ -0,0 +1,183 @@ +// Generated from /home/marvin/Documents/university/compiler/antlr_test/klang/klang/src/main/antlr4/de/hsrm/compiler/Klang/Klang.g4 by ANTLR 4.7.1 +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class calculatorLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + OR=1, AND=2, EQ=3, NEQ=4, GT=5, LT=6, GTEQ=7, LTEQ=8, PLUS=9, MINUS=10, + MULT=11, DIV=12, MOD=13, POW=14, NOT=15, SCOL=16, ASSIGN=17, OPAR=18, + CPAR=19, OBRACE=20, CBRACE=21, TRUE=22, FALSE=23, NIL=24, IF=25, ELSE=26, + WHILE=27, LOG=28, ID=29, INT=30, FLOAT=31, STRING=32, COMMENT=33, SPACE=34, + OTHER=35; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + public static final String[] ruleNames = { + "OR", "AND", "EQ", "NEQ", "GT", "LT", "GTEQ", "LTEQ", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "POW", "NOT", "SCOL", "ASSIGN", "OPAR", "CPAR", + "OBRACE", "CBRACE", "TRUE", "FALSE", "NIL", "IF", "ELSE", "WHILE", "LOG", + "ID", "INT", "FLOAT", "STRING", "COMMENT", "SPACE", "OTHER" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'||'", "'&&'", "'=='", "'!='", "'>'", "'<'", "'>='", "'<='", "'+'", + "'-'", "'*'", "'/'", "'%'", "'^'", "'!'", "';'", "'='", "'('", "')'", + "'{'", "'}'", "'true'", "'false'", "'nil'", "'if'", "'else'", "'while'", + "'log'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, "OR", "AND", "EQ", "NEQ", "GT", "LT", "GTEQ", "LTEQ", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "POW", "NOT", "SCOL", "ASSIGN", "OPAR", "CPAR", + "OBRACE", "CBRACE", "TRUE", "FALSE", "NIL", "IF", "ELSE", "WHILE", "LOG", + "ID", "INT", "FLOAT", "STRING", "COMMENT", "SPACE", "OTHER" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public calculatorLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "Klang.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2%\u00d4\b\1\4\2\t"+ + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ + "\t!\4\"\t\"\4#\t#\4$\t$\3\2\3\2\3\2\3\3\3\3\3\3\3\4\3\4\3\4\3\5\3\5\3"+ + "\5\3\6\3\6\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3"+ + "\r\3\r\3\16\3\16\3\17\3\17\3\20\3\20\3\21\3\21\3\22\3\22\3\23\3\23\3\24"+ + "\3\24\3\25\3\25\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30"+ + "\3\30\3\30\3\31\3\31\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33"+ + "\3\34\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\36\3\36\7\36\u009d"+ + "\n\36\f\36\16\36\u00a0\13\36\3\37\6\37\u00a3\n\37\r\37\16\37\u00a4\3 "+ + "\6 \u00a8\n \r \16 \u00a9\3 \3 \7 \u00ae\n \f \16 \u00b1\13 \3 \3 \6 "+ + "\u00b5\n \r \16 \u00b6\5 \u00b9\n \3!\3!\3!\3!\7!\u00bf\n!\f!\16!\u00c2"+ + "\13!\3!\3!\3\"\3\"\7\"\u00c8\n\"\f\"\16\"\u00cb\13\"\3\"\3\"\3#\3#\3#"+ + "\3#\3$\3$\2\2%\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16"+ + "\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34"+ + "\67\359\36;\37= ?!A\"C#E$G%\3\2\b\5\2C\\aac|\6\2\62;C\\aac|\3\2\62;\5"+ + "\2\f\f\17\17$$\4\2\f\f\17\17\5\2\13\f\17\17\"\"\2\u00dc\2\3\3\2\2\2\2"+ + "\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2"+ + "\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2"+ + "\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2"+ + "\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2"+ + "\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2"+ + "\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\3I\3\2\2\2\5"+ + "L\3\2\2\2\7O\3\2\2\2\tR\3\2\2\2\13U\3\2\2\2\rW\3\2\2\2\17Y\3\2\2\2\21"+ + "\\\3\2\2\2\23_\3\2\2\2\25a\3\2\2\2\27c\3\2\2\2\31e\3\2\2\2\33g\3\2\2\2"+ + "\35i\3\2\2\2\37k\3\2\2\2!m\3\2\2\2#o\3\2\2\2%q\3\2\2\2\'s\3\2\2\2)u\3"+ + "\2\2\2+w\3\2\2\2-y\3\2\2\2/~\3\2\2\2\61\u0084\3\2\2\2\63\u0088\3\2\2\2"+ + "\65\u008b\3\2\2\2\67\u0090\3\2\2\29\u0096\3\2\2\2;\u009a\3\2\2\2=\u00a2"+ + "\3\2\2\2?\u00b8\3\2\2\2A\u00ba\3\2\2\2C\u00c5\3\2\2\2E\u00ce\3\2\2\2G"+ + "\u00d2\3\2\2\2IJ\7~\2\2JK\7~\2\2K\4\3\2\2\2LM\7(\2\2MN\7(\2\2N\6\3\2\2"+ + "\2OP\7?\2\2PQ\7?\2\2Q\b\3\2\2\2RS\7#\2\2ST\7?\2\2T\n\3\2\2\2UV\7@\2\2"+ + "V\f\3\2\2\2WX\7>\2\2X\16\3\2\2\2YZ\7@\2\2Z[\7?\2\2[\20\3\2\2\2\\]\7>\2"+ + "\2]^\7?\2\2^\22\3\2\2\2_`\7-\2\2`\24\3\2\2\2ab\7/\2\2b\26\3\2\2\2cd\7"+ + ",\2\2d\30\3\2\2\2ef\7\61\2\2f\32\3\2\2\2gh\7\'\2\2h\34\3\2\2\2ij\7`\2"+ + "\2j\36\3\2\2\2kl\7#\2\2l \3\2\2\2mn\7=\2\2n\"\3\2\2\2op\7?\2\2p$\3\2\2"+ + "\2qr\7*\2\2r&\3\2\2\2st\7+\2\2t(\3\2\2\2uv\7}\2\2v*\3\2\2\2wx\7\177\2"+ + "\2x,\3\2\2\2yz\7v\2\2z{\7t\2\2{|\7w\2\2|}\7g\2\2}.\3\2\2\2~\177\7h\2\2"+ + "\177\u0080\7c\2\2\u0080\u0081\7n\2\2\u0081\u0082\7u\2\2\u0082\u0083\7"+ + "g\2\2\u0083\60\3\2\2\2\u0084\u0085\7p\2\2\u0085\u0086\7k\2\2\u0086\u0087"+ + "\7n\2\2\u0087\62\3\2\2\2\u0088\u0089\7k\2\2\u0089\u008a\7h\2\2\u008a\64"+ + "\3\2\2\2\u008b\u008c\7g\2\2\u008c\u008d\7n\2\2\u008d\u008e\7u\2\2\u008e"+ + "\u008f\7g\2\2\u008f\66\3\2\2\2\u0090\u0091\7y\2\2\u0091\u0092\7j\2\2\u0092"+ + "\u0093\7k\2\2\u0093\u0094\7n\2\2\u0094\u0095\7g\2\2\u00958\3\2\2\2\u0096"+ + "\u0097\7n\2\2\u0097\u0098\7q\2\2\u0098\u0099\7i\2\2\u0099:\3\2\2\2\u009a"+ + "\u009e\t\2\2\2\u009b\u009d\t\3\2\2\u009c\u009b\3\2\2\2\u009d\u00a0\3\2"+ + "\2\2\u009e\u009c\3\2\2\2\u009e\u009f\3\2\2\2\u009f<\3\2\2\2\u00a0\u009e"+ + "\3\2\2\2\u00a1\u00a3\t\4\2\2\u00a2\u00a1\3\2\2\2\u00a3\u00a4\3\2\2\2\u00a4"+ + "\u00a2\3\2\2\2\u00a4\u00a5\3\2\2\2\u00a5>\3\2\2\2\u00a6\u00a8\t\4\2\2"+ + "\u00a7\u00a6\3\2\2\2\u00a8\u00a9\3\2\2\2\u00a9\u00a7\3\2\2\2\u00a9\u00aa"+ + "\3\2\2\2\u00aa\u00ab\3\2\2\2\u00ab\u00af\7\60\2\2\u00ac\u00ae\t\4\2\2"+ + "\u00ad\u00ac\3\2\2\2\u00ae\u00b1\3\2\2\2\u00af\u00ad\3\2\2\2\u00af\u00b0"+ + "\3\2\2\2\u00b0\u00b9\3\2\2\2\u00b1\u00af\3\2\2\2\u00b2\u00b4\7\60\2\2"+ + "\u00b3\u00b5\t\4\2\2\u00b4\u00b3\3\2\2\2\u00b5\u00b6\3\2\2\2\u00b6\u00b4"+ + "\3\2\2\2\u00b6\u00b7\3\2\2\2\u00b7\u00b9\3\2\2\2\u00b8\u00a7\3\2\2\2\u00b8"+ + "\u00b2\3\2\2\2\u00b9@\3\2\2\2\u00ba\u00c0\7$\2\2\u00bb\u00bf\n\5\2\2\u00bc"+ + "\u00bd\7$\2\2\u00bd\u00bf\7$\2\2\u00be\u00bb\3\2\2\2\u00be\u00bc\3\2\2"+ + "\2\u00bf\u00c2\3\2\2\2\u00c0\u00be\3\2\2\2\u00c0\u00c1\3\2\2\2\u00c1\u00c3"+ + "\3\2\2\2\u00c2\u00c0\3\2\2\2\u00c3\u00c4\7$\2\2\u00c4B\3\2\2\2\u00c5\u00c9"+ + "\7%\2\2\u00c6\u00c8\n\6\2\2\u00c7\u00c6\3\2\2\2\u00c8\u00cb\3\2\2\2\u00c9"+ + "\u00c7\3\2\2\2\u00c9\u00ca\3\2\2\2\u00ca\u00cc\3\2\2\2\u00cb\u00c9\3\2"+ + "\2\2\u00cc\u00cd\b\"\2\2\u00cdD\3\2\2\2\u00ce\u00cf\t\7\2\2\u00cf\u00d0"+ + "\3\2\2\2\u00d0\u00d1\b#\2\2\u00d1F\3\2\2\2\u00d2\u00d3\13\2\2\2\u00d3"+ + "H\3\2\2\2\f\2\u009e\u00a4\u00a9\u00af\u00b6\u00b8\u00be\u00c0\u00c9\3"+ + "\b\2\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.tokens b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.tokens new file mode 100644 index 0000000..d69c013 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/.antlr/calculatorLexer.tokens @@ -0,0 +1,63 @@ +OR=1 +AND=2 +EQ=3 +NEQ=4 +GT=5 +LT=6 +GTEQ=7 +LTEQ=8 +PLUS=9 +MINUS=10 +MULT=11 +DIV=12 +MOD=13 +POW=14 +NOT=15 +SCOL=16 +ASSIGN=17 +OPAR=18 +CPAR=19 +OBRACE=20 +CBRACE=21 +TRUE=22 +FALSE=23 +NIL=24 +IF=25 +ELSE=26 +WHILE=27 +LOG=28 +ID=29 +INT=30 +FLOAT=31 +STRING=32 +COMMENT=33 +SPACE=34 +OTHER=35 +'||'=1 +'&&'=2 +'=='=3 +'!='=4 +'>'=5 +'<'=6 +'>='=7 +'<='=8 +'+'=9 +'-'=10 +'*'=11 +'/'=12 +'%'=13 +'^'=14 +'!'=15 +';'=16 +'='=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'true'=22 +'false'=23 +'nil'=24 +'if'=25 +'else'=26 +'while'=27 +'log'=28 diff --git a/src/main/antlr4/de/hsrm/compiler/Klang/Klang.g4 b/src/main/antlr4/de/hsrm/compiler/Klang/Klang.g4 new file mode 100644 index 0000000..68d4247 --- /dev/null +++ b/src/main/antlr4/de/hsrm/compiler/Klang/Klang.g4 @@ -0,0 +1,124 @@ +grammar Klang; + +parse + : block EOF + ; + +block + : stat* + ; + +stat + : assignment + | if_stat + | while_stat + | log + | OTHER {System.err.println("unknown char: " + $OTHER.text);} + ; + +assignment + : ID ASSIGN expr SCOL + ; + +if_stat + : IF condition_block (ELSE IF condition_block)* (ELSE stat_block)? + ; + +condition_block + : expr stat_block + ; + +stat_block + : OBRACE block CBRACE + | stat + ; + +while_stat + : WHILE expr stat_block + ; + +log + : LOG expr SCOL + ; + +expr + : expr POW expr #powExpr + | MINUS expr #unaryMinusExpr + | NOT expr #notExpr + | expr op=(MULT | DIV | MOD) expr #multiplicationExpr + | expr op=(PLUS | MINUS) expr #additiveExpr + | expr op=(LTEQ | GTEQ | LT | GT) expr #relationalExpr + | expr op=(EQ | NEQ) expr #equalityExpr + | expr AND expr #andExpr + | expr OR expr #orExpr + | atom #atomExpr + ; + +atom + : OPAR expr CPAR #parExpr + | (INT | FLOAT) #numberAtom + | (TRUE | FALSE) #booleanAtom + | ID #idAtom + | STRING #stringAtom + | NIL #nilAtom + ; + +OR : '||'; +AND : '&&'; +EQ : '=='; +NEQ : '!='; +GT : '>'; +LT : '<'; +GTEQ : '>='; +LTEQ : '<='; +PLUS : '+'; +MINUS : '-'; +MULT : '*'; +DIV : '/'; +MOD : '%'; +POW : '^'; +NOT : '!'; + +SCOL : ';'; +ASSIGN : '='; +OPAR : '('; +CPAR : ')'; +OBRACE : '{'; +CBRACE : '}'; + +TRUE : 'true'; +FALSE : 'false'; +NIL : 'nil'; +IF : 'if'; +ELSE : 'else'; +WHILE : 'while'; +LOG : 'log'; + +ID + : [a-zA-Z_] [a-zA-Z_0-9]* + ; + +INT + : [0-9]+ + ; + +FLOAT + : [0-9]+ '.' [0-9]* + | '.' [0-9]+ + ; + +STRING + : '"' (~["\r\n] | '""')* '"' + ; + +COMMENT + : '#' ~[\r\n]* -> skip + ; + +SPACE + : [ \t\r\n] -> skip + ; + +OTHER + : . + ; \ No newline at end of file diff --git a/src/main/java/de/hsrm/compiler/Klang/Klang.java b/src/main/java/de/hsrm/compiler/Klang/Klang.java new file mode 100644 index 0000000..a25a865 --- /dev/null +++ b/src/main/java/de/hsrm/compiler/Klang/Klang.java @@ -0,0 +1,24 @@ +package de.hsrm.compiler.Klang; + +// import ANTLR's runtime libraries +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.tree.*; + +public class Klang { + public static void main(String[] args) throws Exception { + // create a CharStream that reads from standard input + ANTLRInputStream input = new ANTLRInputStream(System.in); + + // create a lexer that feeds off of input CharStream + KlangLexer lexer = new KlangLexer(input); + + // create a buffer of tokens pulled from the lexer + CommonTokenStream tokens = new CommonTokenStream(lexer); + + // create a parser that feeds off the tokens buffer + KlangParser parser = new KlangParser(tokens); + + ParseTree tree = parser.parse(); // begin parsing at init rule + System.out.println(tree.toStringTree(parser)); // print LISP-style tree + } +} diff --git a/target/classes/Klang.tokens b/target/classes/Klang.tokens new file mode 100644 index 0000000..d69c013 --- /dev/null +++ b/target/classes/Klang.tokens @@ -0,0 +1,63 @@ +OR=1 +AND=2 +EQ=3 +NEQ=4 +GT=5 +LT=6 +GTEQ=7 +LTEQ=8 +PLUS=9 +MINUS=10 +MULT=11 +DIV=12 +MOD=13 +POW=14 +NOT=15 +SCOL=16 +ASSIGN=17 +OPAR=18 +CPAR=19 +OBRACE=20 +CBRACE=21 +TRUE=22 +FALSE=23 +NIL=24 +IF=25 +ELSE=26 +WHILE=27 +LOG=28 +ID=29 +INT=30 +FLOAT=31 +STRING=32 +COMMENT=33 +SPACE=34 +OTHER=35 +'||'=1 +'&&'=2 +'=='=3 +'!='=4 +'>'=5 +'<'=6 +'>='=7 +'<='=8 +'+'=9 +'-'=10 +'*'=11 +'/'=12 +'%'=13 +'^'=14 +'!'=15 +';'=16 +'='=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'true'=22 +'false'=23 +'nil'=24 +'if'=25 +'else'=26 +'while'=27 +'log'=28 diff --git a/target/classes/KlangLexer.tokens b/target/classes/KlangLexer.tokens new file mode 100644 index 0000000..d69c013 --- /dev/null +++ b/target/classes/KlangLexer.tokens @@ -0,0 +1,63 @@ +OR=1 +AND=2 +EQ=3 +NEQ=4 +GT=5 +LT=6 +GTEQ=7 +LTEQ=8 +PLUS=9 +MINUS=10 +MULT=11 +DIV=12 +MOD=13 +POW=14 +NOT=15 +SCOL=16 +ASSIGN=17 +OPAR=18 +CPAR=19 +OBRACE=20 +CBRACE=21 +TRUE=22 +FALSE=23 +NIL=24 +IF=25 +ELSE=26 +WHILE=27 +LOG=28 +ID=29 +INT=30 +FLOAT=31 +STRING=32 +COMMENT=33 +SPACE=34 +OTHER=35 +'||'=1 +'&&'=2 +'=='=3 +'!='=4 +'>'=5 +'<'=6 +'>='=7 +'<='=8 +'+'=9 +'-'=10 +'*'=11 +'/'=12 +'%'=13 +'^'=14 +'!'=15 +';'=16 +'='=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'true'=22 +'false'=23 +'nil'=24 +'if'=25 +'else'=26 +'while'=27 +'log'=28 diff --git a/target/classes/de/hsrm/compiler/Klang/Klang.class b/target/classes/de/hsrm/compiler/Klang/Klang.class new file mode 100644 index 0000000..c768ae7 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/Klang.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangBaseListener.class b/target/classes/de/hsrm/compiler/Klang/KlangBaseListener.class new file mode 100644 index 0000000..eee285d Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangBaseListener.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangLexer.class b/target/classes/de/hsrm/compiler/Klang/KlangLexer.class new file mode 100644 index 0000000..69868fc Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangLexer.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangListener.class b/target/classes/de/hsrm/compiler/Klang/KlangListener.class new file mode 100644 index 0000000..637f9fd Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangListener.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$AdditiveExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$AdditiveExprContext.class new file mode 100644 index 0000000..7d6bc9c Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$AdditiveExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$AndExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$AndExprContext.class new file mode 100644 index 0000000..eff5b74 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$AndExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$AssignmentContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$AssignmentContext.class new file mode 100644 index 0000000..b5c022d Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$AssignmentContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$AtomContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$AtomContext.class new file mode 100644 index 0000000..a359874 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$AtomContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$AtomExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$AtomExprContext.class new file mode 100644 index 0000000..208c224 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$AtomExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$BlockContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$BlockContext.class new file mode 100644 index 0000000..0f2da33 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$BlockContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$BooleanAtomContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$BooleanAtomContext.class new file mode 100644 index 0000000..be8756e Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$BooleanAtomContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$Condition_blockContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$Condition_blockContext.class new file mode 100644 index 0000000..0a7c4bd Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$Condition_blockContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$EqualityExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$EqualityExprContext.class new file mode 100644 index 0000000..a728197 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$EqualityExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$ExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$ExprContext.class new file mode 100644 index 0000000..6b9d04a Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$ExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$IdAtomContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$IdAtomContext.class new file mode 100644 index 0000000..d250fd9 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$IdAtomContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$If_statContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$If_statContext.class new file mode 100644 index 0000000..26b3837 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$If_statContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$LogContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$LogContext.class new file mode 100644 index 0000000..b18b0ea Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$LogContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$MultiplicationExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$MultiplicationExprContext.class new file mode 100644 index 0000000..1a19478 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$MultiplicationExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$NilAtomContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$NilAtomContext.class new file mode 100644 index 0000000..fe6ed1e Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$NilAtomContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$NotExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$NotExprContext.class new file mode 100644 index 0000000..4453017 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$NotExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$NumberAtomContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$NumberAtomContext.class new file mode 100644 index 0000000..e771d1c Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$NumberAtomContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$OrExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$OrExprContext.class new file mode 100644 index 0000000..ad94fe9 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$OrExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$ParExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$ParExprContext.class new file mode 100644 index 0000000..7de1dfc Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$ParExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$ParseContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$ParseContext.class new file mode 100644 index 0000000..8e0c250 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$ParseContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$PowExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$PowExprContext.class new file mode 100644 index 0000000..2167fc1 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$PowExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$RelationalExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$RelationalExprContext.class new file mode 100644 index 0000000..64a5a7e Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$RelationalExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$StatContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$StatContext.class new file mode 100644 index 0000000..b42d807 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$StatContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$Stat_blockContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$Stat_blockContext.class new file mode 100644 index 0000000..e60e649 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$Stat_blockContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$StringAtomContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$StringAtomContext.class new file mode 100644 index 0000000..15f7cff Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$StringAtomContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$UnaryMinusExprContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$UnaryMinusExprContext.class new file mode 100644 index 0000000..e52b303 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$UnaryMinusExprContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser$While_statContext.class b/target/classes/de/hsrm/compiler/Klang/KlangParser$While_statContext.class new file mode 100644 index 0000000..70a454b Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser$While_statContext.class differ diff --git a/target/classes/de/hsrm/compiler/Klang/KlangParser.class b/target/classes/de/hsrm/compiler/Klang/KlangParser.class new file mode 100644 index 0000000..cd696b5 Binary files /dev/null and b/target/classes/de/hsrm/compiler/Klang/KlangParser.class differ diff --git a/target/generated-sources/antlr4/Klang.tokens b/target/generated-sources/antlr4/Klang.tokens new file mode 100644 index 0000000..d69c013 --- /dev/null +++ b/target/generated-sources/antlr4/Klang.tokens @@ -0,0 +1,63 @@ +OR=1 +AND=2 +EQ=3 +NEQ=4 +GT=5 +LT=6 +GTEQ=7 +LTEQ=8 +PLUS=9 +MINUS=10 +MULT=11 +DIV=12 +MOD=13 +POW=14 +NOT=15 +SCOL=16 +ASSIGN=17 +OPAR=18 +CPAR=19 +OBRACE=20 +CBRACE=21 +TRUE=22 +FALSE=23 +NIL=24 +IF=25 +ELSE=26 +WHILE=27 +LOG=28 +ID=29 +INT=30 +FLOAT=31 +STRING=32 +COMMENT=33 +SPACE=34 +OTHER=35 +'||'=1 +'&&'=2 +'=='=3 +'!='=4 +'>'=5 +'<'=6 +'>='=7 +'<='=8 +'+'=9 +'-'=10 +'*'=11 +'/'=12 +'%'=13 +'^'=14 +'!'=15 +';'=16 +'='=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'true'=22 +'false'=23 +'nil'=24 +'if'=25 +'else'=26 +'while'=27 +'log'=28 diff --git a/target/generated-sources/antlr4/KlangLexer.tokens b/target/generated-sources/antlr4/KlangLexer.tokens new file mode 100644 index 0000000..d69c013 --- /dev/null +++ b/target/generated-sources/antlr4/KlangLexer.tokens @@ -0,0 +1,63 @@ +OR=1 +AND=2 +EQ=3 +NEQ=4 +GT=5 +LT=6 +GTEQ=7 +LTEQ=8 +PLUS=9 +MINUS=10 +MULT=11 +DIV=12 +MOD=13 +POW=14 +NOT=15 +SCOL=16 +ASSIGN=17 +OPAR=18 +CPAR=19 +OBRACE=20 +CBRACE=21 +TRUE=22 +FALSE=23 +NIL=24 +IF=25 +ELSE=26 +WHILE=27 +LOG=28 +ID=29 +INT=30 +FLOAT=31 +STRING=32 +COMMENT=33 +SPACE=34 +OTHER=35 +'||'=1 +'&&'=2 +'=='=3 +'!='=4 +'>'=5 +'<'=6 +'>='=7 +'<='=8 +'+'=9 +'-'=10 +'*'=11 +'/'=12 +'%'=13 +'^'=14 +'!'=15 +';'=16 +'='=17 +'('=18 +')'=19 +'{'=20 +'}'=21 +'true'=22 +'false'=23 +'nil'=24 +'if'=25 +'else'=26 +'while'=27 +'log'=28 diff --git a/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangBaseListener.java b/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangBaseListener.java new file mode 100644 index 0000000..6d0bec9 --- /dev/null +++ b/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangBaseListener.java @@ -0,0 +1,340 @@ +// Generated from de/hsrm/compiler/Klang/Klang.g4 by ANTLR 4.5 +package de.hsrm.compiler.Klang; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.misc.NotNull; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link KlangListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +public class KlangBaseListener implements KlangListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParse(KlangParser.ParseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParse(KlangParser.ParseContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBlock(KlangParser.BlockContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBlock(KlangParser.BlockContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStat(KlangParser.StatContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStat(KlangParser.StatContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAssignment(KlangParser.AssignmentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssignment(KlangParser.AssignmentContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIf_stat(KlangParser.If_statContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIf_stat(KlangParser.If_statContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCondition_block(KlangParser.Condition_blockContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCondition_block(KlangParser.Condition_blockContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStat_block(KlangParser.Stat_blockContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStat_block(KlangParser.Stat_blockContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterWhile_stat(KlangParser.While_statContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitWhile_stat(KlangParser.While_statContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLog(KlangParser.LogContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLog(KlangParser.LogContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNotExpr(KlangParser.NotExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNotExpr(KlangParser.NotExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterUnaryMinusExpr(KlangParser.UnaryMinusExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitUnaryMinusExpr(KlangParser.UnaryMinusExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterMultiplicationExpr(KlangParser.MultiplicationExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitMultiplicationExpr(KlangParser.MultiplicationExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAtomExpr(KlangParser.AtomExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAtomExpr(KlangParser.AtomExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterOrExpr(KlangParser.OrExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitOrExpr(KlangParser.OrExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAdditiveExpr(KlangParser.AdditiveExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAdditiveExpr(KlangParser.AdditiveExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPowExpr(KlangParser.PowExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPowExpr(KlangParser.PowExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterRelationalExpr(KlangParser.RelationalExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitRelationalExpr(KlangParser.RelationalExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEqualityExpr(KlangParser.EqualityExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEqualityExpr(KlangParser.EqualityExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterAndExpr(KlangParser.AndExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAndExpr(KlangParser.AndExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParExpr(KlangParser.ParExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParExpr(KlangParser.ParExprContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNumberAtom(KlangParser.NumberAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNumberAtom(KlangParser.NumberAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBooleanAtom(KlangParser.BooleanAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBooleanAtom(KlangParser.BooleanAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIdAtom(KlangParser.IdAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIdAtom(KlangParser.IdAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterStringAtom(KlangParser.StringAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitStringAtom(KlangParser.StringAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNilAtom(KlangParser.NilAtomContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNilAtom(KlangParser.NilAtomContext ctx) { } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitTerminal(TerminalNode node) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangLexer.java b/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangLexer.java new file mode 100644 index 0000000..1c6ef82 --- /dev/null +++ b/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangLexer.java @@ -0,0 +1,177 @@ +// Generated from de/hsrm/compiler/Klang/Klang.g4 by ANTLR 4.5 +package de.hsrm.compiler.Klang; +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class KlangLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.5", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + OR=1, AND=2, EQ=3, NEQ=4, GT=5, LT=6, GTEQ=7, LTEQ=8, PLUS=9, MINUS=10, + MULT=11, DIV=12, MOD=13, POW=14, NOT=15, SCOL=16, ASSIGN=17, OPAR=18, + CPAR=19, OBRACE=20, CBRACE=21, TRUE=22, FALSE=23, NIL=24, IF=25, ELSE=26, + WHILE=27, LOG=28, ID=29, INT=30, FLOAT=31, STRING=32, COMMENT=33, SPACE=34, + OTHER=35; + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + public static final String[] ruleNames = { + "OR", "AND", "EQ", "NEQ", "GT", "LT", "GTEQ", "LTEQ", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "POW", "NOT", "SCOL", "ASSIGN", "OPAR", "CPAR", + "OBRACE", "CBRACE", "TRUE", "FALSE", "NIL", "IF", "ELSE", "WHILE", "LOG", + "ID", "INT", "FLOAT", "STRING", "COMMENT", "SPACE", "OTHER" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'||'", "'&&'", "'=='", "'!='", "'>'", "'<'", "'>='", "'<='", "'+'", + "'-'", "'*'", "'/'", "'%'", "'^'", "'!'", "';'", "'='", "'('", "')'", + "'{'", "'}'", "'true'", "'false'", "'nil'", "'if'", "'else'", "'while'", + "'log'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, "OR", "AND", "EQ", "NEQ", "GT", "LT", "GTEQ", "LTEQ", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "POW", "NOT", "SCOL", "ASSIGN", "OPAR", "CPAR", + "OBRACE", "CBRACE", "TRUE", "FALSE", "NIL", "IF", "ELSE", "WHILE", "LOG", + "ID", "INT", "FLOAT", "STRING", "COMMENT", "SPACE", "OTHER" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public KlangLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "Klang.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2%\u00d4\b\1\4\2\t"+ + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ + "\t!\4\"\t\"\4#\t#\4$\t$\3\2\3\2\3\2\3\3\3\3\3\3\3\4\3\4\3\4\3\5\3\5\3"+ + "\5\3\6\3\6\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3"+ + "\r\3\r\3\16\3\16\3\17\3\17\3\20\3\20\3\21\3\21\3\22\3\22\3\23\3\23\3\24"+ + "\3\24\3\25\3\25\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30"+ + "\3\30\3\30\3\31\3\31\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33"+ + "\3\34\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\36\3\36\7\36\u009d"+ + "\n\36\f\36\16\36\u00a0\13\36\3\37\6\37\u00a3\n\37\r\37\16\37\u00a4\3 "+ + "\6 \u00a8\n \r \16 \u00a9\3 \3 \7 \u00ae\n \f \16 \u00b1\13 \3 \3 \6 "+ + "\u00b5\n \r \16 \u00b6\5 \u00b9\n \3!\3!\3!\3!\7!\u00bf\n!\f!\16!\u00c2"+ + "\13!\3!\3!\3\"\3\"\7\"\u00c8\n\"\f\"\16\"\u00cb\13\"\3\"\3\"\3#\3#\3#"+ + "\3#\3$\3$\2\2%\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16"+ + "\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34"+ + "\67\359\36;\37= ?!A\"C#E$G%\3\2\b\5\2C\\aac|\6\2\62;C\\aac|\3\2\62;\5"+ + "\2\f\f\17\17$$\4\2\f\f\17\17\5\2\13\f\17\17\"\"\u00dc\2\3\3\2\2\2\2\5"+ + "\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2"+ + "\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33"+ + "\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2"+ + "\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2"+ + "\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2"+ + "\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\3I\3\2\2\2\5L"+ + "\3\2\2\2\7O\3\2\2\2\tR\3\2\2\2\13U\3\2\2\2\rW\3\2\2\2\17Y\3\2\2\2\21\\"+ + "\3\2\2\2\23_\3\2\2\2\25a\3\2\2\2\27c\3\2\2\2\31e\3\2\2\2\33g\3\2\2\2\35"+ + "i\3\2\2\2\37k\3\2\2\2!m\3\2\2\2#o\3\2\2\2%q\3\2\2\2\'s\3\2\2\2)u\3\2\2"+ + "\2+w\3\2\2\2-y\3\2\2\2/~\3\2\2\2\61\u0084\3\2\2\2\63\u0088\3\2\2\2\65"+ + "\u008b\3\2\2\2\67\u0090\3\2\2\29\u0096\3\2\2\2;\u009a\3\2\2\2=\u00a2\3"+ + "\2\2\2?\u00b8\3\2\2\2A\u00ba\3\2\2\2C\u00c5\3\2\2\2E\u00ce\3\2\2\2G\u00d2"+ + "\3\2\2\2IJ\7~\2\2JK\7~\2\2K\4\3\2\2\2LM\7(\2\2MN\7(\2\2N\6\3\2\2\2OP\7"+ + "?\2\2PQ\7?\2\2Q\b\3\2\2\2RS\7#\2\2ST\7?\2\2T\n\3\2\2\2UV\7@\2\2V\f\3\2"+ + "\2\2WX\7>\2\2X\16\3\2\2\2YZ\7@\2\2Z[\7?\2\2[\20\3\2\2\2\\]\7>\2\2]^\7"+ + "?\2\2^\22\3\2\2\2_`\7-\2\2`\24\3\2\2\2ab\7/\2\2b\26\3\2\2\2cd\7,\2\2d"+ + "\30\3\2\2\2ef\7\61\2\2f\32\3\2\2\2gh\7\'\2\2h\34\3\2\2\2ij\7`\2\2j\36"+ + "\3\2\2\2kl\7#\2\2l \3\2\2\2mn\7=\2\2n\"\3\2\2\2op\7?\2\2p$\3\2\2\2qr\7"+ + "*\2\2r&\3\2\2\2st\7+\2\2t(\3\2\2\2uv\7}\2\2v*\3\2\2\2wx\7\177\2\2x,\3"+ + "\2\2\2yz\7v\2\2z{\7t\2\2{|\7w\2\2|}\7g\2\2}.\3\2\2\2~\177\7h\2\2\177\u0080"+ + "\7c\2\2\u0080\u0081\7n\2\2\u0081\u0082\7u\2\2\u0082\u0083\7g\2\2\u0083"+ + "\60\3\2\2\2\u0084\u0085\7p\2\2\u0085\u0086\7k\2\2\u0086\u0087\7n\2\2\u0087"+ + "\62\3\2\2\2\u0088\u0089\7k\2\2\u0089\u008a\7h\2\2\u008a\64\3\2\2\2\u008b"+ + "\u008c\7g\2\2\u008c\u008d\7n\2\2\u008d\u008e\7u\2\2\u008e\u008f\7g\2\2"+ + "\u008f\66\3\2\2\2\u0090\u0091\7y\2\2\u0091\u0092\7j\2\2\u0092\u0093\7"+ + "k\2\2\u0093\u0094\7n\2\2\u0094\u0095\7g\2\2\u00958\3\2\2\2\u0096\u0097"+ + "\7n\2\2\u0097\u0098\7q\2\2\u0098\u0099\7i\2\2\u0099:\3\2\2\2\u009a\u009e"+ + "\t\2\2\2\u009b\u009d\t\3\2\2\u009c\u009b\3\2\2\2\u009d\u00a0\3\2\2\2\u009e"+ + "\u009c\3\2\2\2\u009e\u009f\3\2\2\2\u009f<\3\2\2\2\u00a0\u009e\3\2\2\2"+ + "\u00a1\u00a3\t\4\2\2\u00a2\u00a1\3\2\2\2\u00a3\u00a4\3\2\2\2\u00a4\u00a2"+ + "\3\2\2\2\u00a4\u00a5\3\2\2\2\u00a5>\3\2\2\2\u00a6\u00a8\t\4\2\2\u00a7"+ + "\u00a6\3\2\2\2\u00a8\u00a9\3\2\2\2\u00a9\u00a7\3\2\2\2\u00a9\u00aa\3\2"+ + "\2\2\u00aa\u00ab\3\2\2\2\u00ab\u00af\7\60\2\2\u00ac\u00ae\t\4\2\2\u00ad"+ + "\u00ac\3\2\2\2\u00ae\u00b1\3\2\2\2\u00af\u00ad\3\2\2\2\u00af\u00b0\3\2"+ + "\2\2\u00b0\u00b9\3\2\2\2\u00b1\u00af\3\2\2\2\u00b2\u00b4\7\60\2\2\u00b3"+ + "\u00b5\t\4\2\2\u00b4\u00b3\3\2\2\2\u00b5\u00b6\3\2\2\2\u00b6\u00b4\3\2"+ + "\2\2\u00b6\u00b7\3\2\2\2\u00b7\u00b9\3\2\2\2\u00b8\u00a7\3\2\2\2\u00b8"+ + "\u00b2\3\2\2\2\u00b9@\3\2\2\2\u00ba\u00c0\7$\2\2\u00bb\u00bf\n\5\2\2\u00bc"+ + "\u00bd\7$\2\2\u00bd\u00bf\7$\2\2\u00be\u00bb\3\2\2\2\u00be\u00bc\3\2\2"+ + "\2\u00bf\u00c2\3\2\2\2\u00c0\u00be\3\2\2\2\u00c0\u00c1\3\2\2\2\u00c1\u00c3"+ + "\3\2\2\2\u00c2\u00c0\3\2\2\2\u00c3\u00c4\7$\2\2\u00c4B\3\2\2\2\u00c5\u00c9"+ + "\7%\2\2\u00c6\u00c8\n\6\2\2\u00c7\u00c6\3\2\2\2\u00c8\u00cb\3\2\2\2\u00c9"+ + "\u00c7\3\2\2\2\u00c9\u00ca\3\2\2\2\u00ca\u00cc\3\2\2\2\u00cb\u00c9\3\2"+ + "\2\2\u00cc\u00cd\b\"\2\2\u00cdD\3\2\2\2\u00ce\u00cf\t\7\2\2\u00cf\u00d0"+ + "\3\2\2\2\u00d0\u00d1\b#\2\2\u00d1F\3\2\2\2\u00d2\u00d3\13\2\2\2\u00d3"+ + "H\3\2\2\2\f\2\u009e\u00a4\u00a9\u00af\u00b6\u00b8\u00be\u00c0\u00c9\3"+ + "\b\2\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangListener.java b/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangListener.java new file mode 100644 index 0000000..9eafcbe --- /dev/null +++ b/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangListener.java @@ -0,0 +1,293 @@ +// Generated from de/hsrm/compiler/Klang/Klang.g4 by ANTLR 4.5 +package de.hsrm.compiler.Klang; +import org.antlr.v4.runtime.misc.NotNull; +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link KlangParser}. + */ +public interface KlangListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link KlangParser#parse}. + * @param ctx the parse tree + */ + void enterParse(KlangParser.ParseContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#parse}. + * @param ctx the parse tree + */ + void exitParse(KlangParser.ParseContext ctx); + /** + * Enter a parse tree produced by {@link KlangParser#block}. + * @param ctx the parse tree + */ + void enterBlock(KlangParser.BlockContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#block}. + * @param ctx the parse tree + */ + void exitBlock(KlangParser.BlockContext ctx); + /** + * Enter a parse tree produced by {@link KlangParser#stat}. + * @param ctx the parse tree + */ + void enterStat(KlangParser.StatContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#stat}. + * @param ctx the parse tree + */ + void exitStat(KlangParser.StatContext ctx); + /** + * Enter a parse tree produced by {@link KlangParser#assignment}. + * @param ctx the parse tree + */ + void enterAssignment(KlangParser.AssignmentContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#assignment}. + * @param ctx the parse tree + */ + void exitAssignment(KlangParser.AssignmentContext ctx); + /** + * Enter a parse tree produced by {@link KlangParser#if_stat}. + * @param ctx the parse tree + */ + void enterIf_stat(KlangParser.If_statContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#if_stat}. + * @param ctx the parse tree + */ + void exitIf_stat(KlangParser.If_statContext ctx); + /** + * Enter a parse tree produced by {@link KlangParser#condition_block}. + * @param ctx the parse tree + */ + void enterCondition_block(KlangParser.Condition_blockContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#condition_block}. + * @param ctx the parse tree + */ + void exitCondition_block(KlangParser.Condition_blockContext ctx); + /** + * Enter a parse tree produced by {@link KlangParser#stat_block}. + * @param ctx the parse tree + */ + void enterStat_block(KlangParser.Stat_blockContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#stat_block}. + * @param ctx the parse tree + */ + void exitStat_block(KlangParser.Stat_blockContext ctx); + /** + * Enter a parse tree produced by {@link KlangParser#while_stat}. + * @param ctx the parse tree + */ + void enterWhile_stat(KlangParser.While_statContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#while_stat}. + * @param ctx the parse tree + */ + void exitWhile_stat(KlangParser.While_statContext ctx); + /** + * Enter a parse tree produced by {@link KlangParser#log}. + * @param ctx the parse tree + */ + void enterLog(KlangParser.LogContext ctx); + /** + * Exit a parse tree produced by {@link KlangParser#log}. + * @param ctx the parse tree + */ + void exitLog(KlangParser.LogContext ctx); + /** + * Enter a parse tree produced by the {@code notExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterNotExpr(KlangParser.NotExprContext ctx); + /** + * Exit a parse tree produced by the {@code notExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitNotExpr(KlangParser.NotExprContext ctx); + /** + * Enter a parse tree produced by the {@code unaryMinusExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterUnaryMinusExpr(KlangParser.UnaryMinusExprContext ctx); + /** + * Exit a parse tree produced by the {@code unaryMinusExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitUnaryMinusExpr(KlangParser.UnaryMinusExprContext ctx); + /** + * Enter a parse tree produced by the {@code multiplicationExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterMultiplicationExpr(KlangParser.MultiplicationExprContext ctx); + /** + * Exit a parse tree produced by the {@code multiplicationExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitMultiplicationExpr(KlangParser.MultiplicationExprContext ctx); + /** + * Enter a parse tree produced by the {@code atomExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterAtomExpr(KlangParser.AtomExprContext ctx); + /** + * Exit a parse tree produced by the {@code atomExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitAtomExpr(KlangParser.AtomExprContext ctx); + /** + * Enter a parse tree produced by the {@code orExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterOrExpr(KlangParser.OrExprContext ctx); + /** + * Exit a parse tree produced by the {@code orExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitOrExpr(KlangParser.OrExprContext ctx); + /** + * Enter a parse tree produced by the {@code additiveExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterAdditiveExpr(KlangParser.AdditiveExprContext ctx); + /** + * Exit a parse tree produced by the {@code additiveExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitAdditiveExpr(KlangParser.AdditiveExprContext ctx); + /** + * Enter a parse tree produced by the {@code powExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterPowExpr(KlangParser.PowExprContext ctx); + /** + * Exit a parse tree produced by the {@code powExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitPowExpr(KlangParser.PowExprContext ctx); + /** + * Enter a parse tree produced by the {@code relationalExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterRelationalExpr(KlangParser.RelationalExprContext ctx); + /** + * Exit a parse tree produced by the {@code relationalExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitRelationalExpr(KlangParser.RelationalExprContext ctx); + /** + * Enter a parse tree produced by the {@code equalityExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterEqualityExpr(KlangParser.EqualityExprContext ctx); + /** + * Exit a parse tree produced by the {@code equalityExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitEqualityExpr(KlangParser.EqualityExprContext ctx); + /** + * Enter a parse tree produced by the {@code andExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void enterAndExpr(KlangParser.AndExprContext ctx); + /** + * Exit a parse tree produced by the {@code andExpr} + * labeled alternative in {@link KlangParser#expr}. + * @param ctx the parse tree + */ + void exitAndExpr(KlangParser.AndExprContext ctx); + /** + * Enter a parse tree produced by the {@code parExpr} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void enterParExpr(KlangParser.ParExprContext ctx); + /** + * Exit a parse tree produced by the {@code parExpr} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void exitParExpr(KlangParser.ParExprContext ctx); + /** + * Enter a parse tree produced by the {@code numberAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void enterNumberAtom(KlangParser.NumberAtomContext ctx); + /** + * Exit a parse tree produced by the {@code numberAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void exitNumberAtom(KlangParser.NumberAtomContext ctx); + /** + * Enter a parse tree produced by the {@code booleanAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void enterBooleanAtom(KlangParser.BooleanAtomContext ctx); + /** + * Exit a parse tree produced by the {@code booleanAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void exitBooleanAtom(KlangParser.BooleanAtomContext ctx); + /** + * Enter a parse tree produced by the {@code idAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void enterIdAtom(KlangParser.IdAtomContext ctx); + /** + * Exit a parse tree produced by the {@code idAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void exitIdAtom(KlangParser.IdAtomContext ctx); + /** + * Enter a parse tree produced by the {@code stringAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void enterStringAtom(KlangParser.StringAtomContext ctx); + /** + * Exit a parse tree produced by the {@code stringAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void exitStringAtom(KlangParser.StringAtomContext ctx); + /** + * Enter a parse tree produced by the {@code nilAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void enterNilAtom(KlangParser.NilAtomContext ctx); + /** + * Exit a parse tree produced by the {@code nilAtom} + * labeled alternative in {@link KlangParser#atom}. + * @param ctx the parse tree + */ + void exitNilAtom(KlangParser.NilAtomContext ctx); +} \ No newline at end of file diff --git a/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangParser.java b/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangParser.java new file mode 100644 index 0000000..59fa897 --- /dev/null +++ b/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangParser.java @@ -0,0 +1,1251 @@ +// Generated from de/hsrm/compiler/Klang/Klang.g4 by ANTLR 4.5 +package de.hsrm.compiler.Klang; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) +public class KlangParser extends Parser { + static { RuntimeMetaData.checkVersion("4.5", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + OR=1, AND=2, EQ=3, NEQ=4, GT=5, LT=6, GTEQ=7, LTEQ=8, PLUS=9, MINUS=10, + MULT=11, DIV=12, MOD=13, POW=14, NOT=15, SCOL=16, ASSIGN=17, OPAR=18, + CPAR=19, OBRACE=20, CBRACE=21, TRUE=22, FALSE=23, NIL=24, IF=25, ELSE=26, + WHILE=27, LOG=28, ID=29, INT=30, FLOAT=31, STRING=32, COMMENT=33, SPACE=34, + OTHER=35; + public static final int + RULE_parse = 0, RULE_block = 1, RULE_stat = 2, RULE_assignment = 3, RULE_if_stat = 4, + RULE_condition_block = 5, RULE_stat_block = 6, RULE_while_stat = 7, RULE_log = 8, + RULE_expr = 9, RULE_atom = 10; + public static final String[] ruleNames = { + "parse", "block", "stat", "assignment", "if_stat", "condition_block", + "stat_block", "while_stat", "log", "expr", "atom" + }; + + private static final String[] _LITERAL_NAMES = { + null, "'||'", "'&&'", "'=='", "'!='", "'>'", "'<'", "'>='", "'<='", "'+'", + "'-'", "'*'", "'/'", "'%'", "'^'", "'!'", "';'", "'='", "'('", "')'", + "'{'", "'}'", "'true'", "'false'", "'nil'", "'if'", "'else'", "'while'", + "'log'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, "OR", "AND", "EQ", "NEQ", "GT", "LT", "GTEQ", "LTEQ", "PLUS", "MINUS", + "MULT", "DIV", "MOD", "POW", "NOT", "SCOL", "ASSIGN", "OPAR", "CPAR", + "OBRACE", "CBRACE", "TRUE", "FALSE", "NIL", "IF", "ELSE", "WHILE", "LOG", + "ID", "INT", "FLOAT", "STRING", "COMMENT", "SPACE", "OTHER" + }; + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "Klang.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public KlangParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + public static class ParseContext extends ParserRuleContext { + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TerminalNode EOF() { return getToken(KlangParser.EOF, 0); } + public ParseContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_parse; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterParse(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitParse(this); + } + } + + public final ParseContext parse() throws RecognitionException { + ParseContext _localctx = new ParseContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_parse); + try { + enterOuterAlt(_localctx, 1); + { + setState(22); + block(); + setState(23); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class BlockContext extends ParserRuleContext { + public List stat() { + return getRuleContexts(StatContext.class); + } + public StatContext stat(int i) { + return getRuleContext(StatContext.class,i); + } + public BlockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_block; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterBlock(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitBlock(this); + } + } + + public final BlockContext block() throws RecognitionException { + BlockContext _localctx = new BlockContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_block); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(28); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << IF) | (1L << WHILE) | (1L << LOG) | (1L << ID) | (1L << OTHER))) != 0)) { + { + { + setState(25); + stat(); + } + } + setState(30); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class StatContext extends ParserRuleContext { + public Token OTHER; + public AssignmentContext assignment() { + return getRuleContext(AssignmentContext.class,0); + } + public If_statContext if_stat() { + return getRuleContext(If_statContext.class,0); + } + public While_statContext while_stat() { + return getRuleContext(While_statContext.class,0); + } + public LogContext log() { + return getRuleContext(LogContext.class,0); + } + public TerminalNode OTHER() { return getToken(KlangParser.OTHER, 0); } + public StatContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_stat; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterStat(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitStat(this); + } + } + + public final StatContext stat() throws RecognitionException { + StatContext _localctx = new StatContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_stat); + try { + setState(37); + switch (_input.LA(1)) { + case ID: + enterOuterAlt(_localctx, 1); + { + setState(31); + assignment(); + } + break; + case IF: + enterOuterAlt(_localctx, 2); + { + setState(32); + if_stat(); + } + break; + case WHILE: + enterOuterAlt(_localctx, 3); + { + setState(33); + while_stat(); + } + break; + case LOG: + enterOuterAlt(_localctx, 4); + { + setState(34); + log(); + } + break; + case OTHER: + enterOuterAlt(_localctx, 5); + { + setState(35); + ((StatContext)_localctx).OTHER = match(OTHER); + System.err.println("unknown char: " + (((StatContext)_localctx).OTHER!=null?((StatContext)_localctx).OTHER.getText():null)); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class AssignmentContext extends ParserRuleContext { + public TerminalNode ID() { return getToken(KlangParser.ID, 0); } + public TerminalNode ASSIGN() { return getToken(KlangParser.ASSIGN, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode SCOL() { return getToken(KlangParser.SCOL, 0); } + public AssignmentContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_assignment; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterAssignment(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitAssignment(this); + } + } + + public final AssignmentContext assignment() throws RecognitionException { + AssignmentContext _localctx = new AssignmentContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_assignment); + try { + enterOuterAlt(_localctx, 1); + { + setState(39); + match(ID); + setState(40); + match(ASSIGN); + setState(41); + expr(0); + setState(42); + match(SCOL); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class If_statContext extends ParserRuleContext { + public List IF() { return getTokens(KlangParser.IF); } + public TerminalNode IF(int i) { + return getToken(KlangParser.IF, i); + } + public List condition_block() { + return getRuleContexts(Condition_blockContext.class); + } + public Condition_blockContext condition_block(int i) { + return getRuleContext(Condition_blockContext.class,i); + } + public List ELSE() { return getTokens(KlangParser.ELSE); } + public TerminalNode ELSE(int i) { + return getToken(KlangParser.ELSE, i); + } + public Stat_blockContext stat_block() { + return getRuleContext(Stat_blockContext.class,0); + } + public If_statContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_if_stat; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterIf_stat(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitIf_stat(this); + } + } + + public final If_statContext if_stat() throws RecognitionException { + If_statContext _localctx = new If_statContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_if_stat); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(44); + match(IF); + setState(45); + condition_block(); + setState(51); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(46); + match(ELSE); + setState(47); + match(IF); + setState(48); + condition_block(); + } + } + } + setState(53); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + } + setState(56); + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { + case 1: + { + setState(54); + match(ELSE); + setState(55); + stat_block(); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Condition_blockContext extends ParserRuleContext { + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public Stat_blockContext stat_block() { + return getRuleContext(Stat_blockContext.class,0); + } + public Condition_blockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_condition_block; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterCondition_block(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitCondition_block(this); + } + } + + public final Condition_blockContext condition_block() throws RecognitionException { + Condition_blockContext _localctx = new Condition_blockContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_condition_block); + try { + enterOuterAlt(_localctx, 1); + { + setState(58); + expr(0); + setState(59); + stat_block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class Stat_blockContext extends ParserRuleContext { + public TerminalNode OBRACE() { return getToken(KlangParser.OBRACE, 0); } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public TerminalNode CBRACE() { return getToken(KlangParser.CBRACE, 0); } + public StatContext stat() { + return getRuleContext(StatContext.class,0); + } + public Stat_blockContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_stat_block; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterStat_block(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitStat_block(this); + } + } + + public final Stat_blockContext stat_block() throws RecognitionException { + Stat_blockContext _localctx = new Stat_blockContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_stat_block); + try { + setState(66); + switch (_input.LA(1)) { + case OBRACE: + enterOuterAlt(_localctx, 1); + { + setState(61); + match(OBRACE); + setState(62); + block(); + setState(63); + match(CBRACE); + } + break; + case IF: + case WHILE: + case LOG: + case ID: + case OTHER: + enterOuterAlt(_localctx, 2); + { + setState(65); + stat(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class While_statContext extends ParserRuleContext { + public TerminalNode WHILE() { return getToken(KlangParser.WHILE, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public Stat_blockContext stat_block() { + return getRuleContext(Stat_blockContext.class,0); + } + public While_statContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_while_stat; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterWhile_stat(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitWhile_stat(this); + } + } + + public final While_statContext while_stat() throws RecognitionException { + While_statContext _localctx = new While_statContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_while_stat); + try { + enterOuterAlt(_localctx, 1); + { + setState(68); + match(WHILE); + setState(69); + expr(0); + setState(70); + stat_block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class LogContext extends ParserRuleContext { + public TerminalNode LOG() { return getToken(KlangParser.LOG, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode SCOL() { return getToken(KlangParser.SCOL, 0); } + public LogContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_log; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterLog(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitLog(this); + } + } + + public final LogContext log() throws RecognitionException { + LogContext _localctx = new LogContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_log); + try { + enterOuterAlt(_localctx, 1); + { + setState(72); + match(LOG); + setState(73); + expr(0); + setState(74); + match(SCOL); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static class ExprContext extends ParserRuleContext { + public ExprContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expr; } + + public ExprContext() { } + public void copyFrom(ExprContext ctx) { + super.copyFrom(ctx); + } + } + public static class NotExprContext extends ExprContext { + public TerminalNode NOT() { return getToken(KlangParser.NOT, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public NotExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterNotExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitNotExpr(this); + } + } + public static class UnaryMinusExprContext extends ExprContext { + public TerminalNode MINUS() { return getToken(KlangParser.MINUS, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public UnaryMinusExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterUnaryMinusExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitUnaryMinusExpr(this); + } + } + public static class MultiplicationExprContext extends ExprContext { + public Token op; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode MULT() { return getToken(KlangParser.MULT, 0); } + public TerminalNode DIV() { return getToken(KlangParser.DIV, 0); } + public TerminalNode MOD() { return getToken(KlangParser.MOD, 0); } + public MultiplicationExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterMultiplicationExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitMultiplicationExpr(this); + } + } + public static class AtomExprContext extends ExprContext { + public AtomContext atom() { + return getRuleContext(AtomContext.class,0); + } + public AtomExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterAtomExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitAtomExpr(this); + } + } + public static class OrExprContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode OR() { return getToken(KlangParser.OR, 0); } + public OrExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterOrExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitOrExpr(this); + } + } + public static class AdditiveExprContext extends ExprContext { + public Token op; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode PLUS() { return getToken(KlangParser.PLUS, 0); } + public TerminalNode MINUS() { return getToken(KlangParser.MINUS, 0); } + public AdditiveExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterAdditiveExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitAdditiveExpr(this); + } + } + public static class PowExprContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode POW() { return getToken(KlangParser.POW, 0); } + public PowExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterPowExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitPowExpr(this); + } + } + public static class RelationalExprContext extends ExprContext { + public Token op; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode LTEQ() { return getToken(KlangParser.LTEQ, 0); } + public TerminalNode GTEQ() { return getToken(KlangParser.GTEQ, 0); } + public TerminalNode LT() { return getToken(KlangParser.LT, 0); } + public TerminalNode GT() { return getToken(KlangParser.GT, 0); } + public RelationalExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterRelationalExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitRelationalExpr(this); + } + } + public static class EqualityExprContext extends ExprContext { + public Token op; + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode EQ() { return getToken(KlangParser.EQ, 0); } + public TerminalNode NEQ() { return getToken(KlangParser.NEQ, 0); } + public EqualityExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterEqualityExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitEqualityExpr(this); + } + } + public static class AndExprContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public TerminalNode AND() { return getToken(KlangParser.AND, 0); } + public AndExprContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterAndExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitAndExpr(this); + } + } + + public final ExprContext expr() throws RecognitionException { + return expr(0); + } + + private ExprContext expr(int _p) throws RecognitionException { + ParserRuleContext _parentctx = _ctx; + int _parentState = getState(); + ExprContext _localctx = new ExprContext(_ctx, _parentState); + ExprContext _prevctx = _localctx; + int _startState = 18; + enterRecursionRule(_localctx, 18, RULE_expr, _p); + int _la; + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(82); + switch (_input.LA(1)) { + case MINUS: + { + _localctx = new UnaryMinusExprContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(77); + match(MINUS); + setState(78); + expr(9); + } + break; + case NOT: + { + _localctx = new NotExprContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(79); + match(NOT); + setState(80); + expr(8); + } + break; + case OPAR: + case TRUE: + case FALSE: + case NIL: + case ID: + case INT: + case FLOAT: + case STRING: + { + _localctx = new AtomExprContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(81); + atom(); + } + break; + default: + throw new NoViableAltException(this); + } + _ctx.stop = _input.LT(-1); + setState(107); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,7,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(105); + switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { + case 1: + { + _localctx = new PowExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(84); + if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); + setState(85); + match(POW); + setState(86); + expr(11); + } + break; + case 2: + { + _localctx = new MultiplicationExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(87); + if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); + setState(88); + ((MultiplicationExprContext)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << MULT) | (1L << DIV) | (1L << MOD))) != 0)) ) { + ((MultiplicationExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); + } else { + consume(); + } + setState(89); + expr(8); + } + break; + case 3: + { + _localctx = new AdditiveExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(90); + if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); + setState(91); + ((AdditiveExprContext)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !(_la==PLUS || _la==MINUS) ) { + ((AdditiveExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); + } else { + consume(); + } + setState(92); + expr(7); + } + break; + case 4: + { + _localctx = new RelationalExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(93); + if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); + setState(94); + ((RelationalExprContext)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << GT) | (1L << LT) | (1L << GTEQ) | (1L << LTEQ))) != 0)) ) { + ((RelationalExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); + } else { + consume(); + } + setState(95); + expr(6); + } + break; + case 5: + { + _localctx = new EqualityExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(96); + if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)"); + setState(97); + ((EqualityExprContext)_localctx).op = _input.LT(1); + _la = _input.LA(1); + if ( !(_la==EQ || _la==NEQ) ) { + ((EqualityExprContext)_localctx).op = (Token)_errHandler.recoverInline(this); + } else { + consume(); + } + setState(98); + expr(5); + } + break; + case 6: + { + _localctx = new AndExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(99); + if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)"); + setState(100); + match(AND); + setState(101); + expr(4); + } + break; + case 7: + { + _localctx = new OrExprContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(102); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(103); + match(OR); + setState(104); + expr(3); + } + break; + } + } + } + setState(109); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,7,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + public static class AtomContext extends ParserRuleContext { + public AtomContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_atom; } + + public AtomContext() { } + public void copyFrom(AtomContext ctx) { + super.copyFrom(ctx); + } + } + public static class ParExprContext extends AtomContext { + public TerminalNode OPAR() { return getToken(KlangParser.OPAR, 0); } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public TerminalNode CPAR() { return getToken(KlangParser.CPAR, 0); } + public ParExprContext(AtomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterParExpr(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitParExpr(this); + } + } + public static class BooleanAtomContext extends AtomContext { + public TerminalNode TRUE() { return getToken(KlangParser.TRUE, 0); } + public TerminalNode FALSE() { return getToken(KlangParser.FALSE, 0); } + public BooleanAtomContext(AtomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterBooleanAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitBooleanAtom(this); + } + } + public static class IdAtomContext extends AtomContext { + public TerminalNode ID() { return getToken(KlangParser.ID, 0); } + public IdAtomContext(AtomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterIdAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitIdAtom(this); + } + } + public static class StringAtomContext extends AtomContext { + public TerminalNode STRING() { return getToken(KlangParser.STRING, 0); } + public StringAtomContext(AtomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterStringAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitStringAtom(this); + } + } + public static class NilAtomContext extends AtomContext { + public TerminalNode NIL() { return getToken(KlangParser.NIL, 0); } + public NilAtomContext(AtomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterNilAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitNilAtom(this); + } + } + public static class NumberAtomContext extends AtomContext { + public TerminalNode INT() { return getToken(KlangParser.INT, 0); } + public TerminalNode FLOAT() { return getToken(KlangParser.FLOAT, 0); } + public NumberAtomContext(AtomContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).enterNumberAtom(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof KlangListener ) ((KlangListener)listener).exitNumberAtom(this); + } + } + + public final AtomContext atom() throws RecognitionException { + AtomContext _localctx = new AtomContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_atom); + int _la; + try { + setState(119); + switch (_input.LA(1)) { + case OPAR: + _localctx = new ParExprContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(110); + match(OPAR); + setState(111); + expr(0); + setState(112); + match(CPAR); + } + break; + case INT: + case FLOAT: + _localctx = new NumberAtomContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(114); + _la = _input.LA(1); + if ( !(_la==INT || _la==FLOAT) ) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + break; + case TRUE: + case FALSE: + _localctx = new BooleanAtomContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(115); + _la = _input.LA(1); + if ( !(_la==TRUE || _la==FALSE) ) { + _errHandler.recoverInline(this); + } else { + consume(); + } + } + break; + case ID: + _localctx = new IdAtomContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(116); + match(ID); + } + break; + case STRING: + _localctx = new StringAtomContext(_localctx); + enterOuterAlt(_localctx, 5); + { + setState(117); + match(STRING); + } + break; + case NIL: + _localctx = new NilAtomContext(_localctx); + enterOuterAlt(_localctx, 6); + { + setState(118); + match(NIL); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { + switch (ruleIndex) { + case 9: + return expr_sempred((ExprContext)_localctx, predIndex); + } + return true; + } + private boolean expr_sempred(ExprContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 10); + case 1: + return precpred(_ctx, 7); + case 2: + return precpred(_ctx, 6); + case 3: + return precpred(_ctx, 5); + case 4: + return precpred(_ctx, 4); + case 5: + return precpred(_ctx, 3); + case 6: + return precpred(_ctx, 2); + } + return true; + } + + public static final String _serializedATN = + "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3%|\4\2\t\2\4\3\t\3"+ + "\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f"+ + "\t\f\3\2\3\2\3\2\3\3\7\3\35\n\3\f\3\16\3 \13\3\3\4\3\4\3\4\3\4\3\4\3\4"+ + "\5\4(\n\4\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\7\6\64\n\6\f\6\16\6"+ + "\67\13\6\3\6\3\6\5\6;\n\6\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\5\bE\n\b\3\t"+ + "\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\5\13U\n\13"+ + "\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13"+ + "\3\13\3\13\3\13\3\13\3\13\3\13\3\13\7\13l\n\13\f\13\16\13o\13\13\3\f\3"+ + "\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\5\fz\n\f\3\f\2\3\24\r\2\4\6\b\n\f\16\20"+ + "\22\24\26\2\b\3\2\r\17\3\2\13\f\3\2\7\n\3\2\5\6\3\2 !\3\2\30\31\u0086"+ + "\2\30\3\2\2\2\4\36\3\2\2\2\6\'\3\2\2\2\b)\3\2\2\2\n.\3\2\2\2\f<\3\2\2"+ + "\2\16D\3\2\2\2\20F\3\2\2\2\22J\3\2\2\2\24T\3\2\2\2\26y\3\2\2\2\30\31\5"+ + "\4\3\2\31\32\7\2\2\3\32\3\3\2\2\2\33\35\5\6\4\2\34\33\3\2\2\2\35 \3\2"+ + "\2\2\36\34\3\2\2\2\36\37\3\2\2\2\37\5\3\2\2\2 \36\3\2\2\2!(\5\b\5\2\""+ + "(\5\n\6\2#(\5\20\t\2$(\5\22\n\2%&\7%\2\2&(\b\4\1\2\'!\3\2\2\2\'\"\3\2"+ + "\2\2\'#\3\2\2\2\'$\3\2\2\2\'%\3\2\2\2(\7\3\2\2\2)*\7\37\2\2*+\7\23\2\2"+ + "+,\5\24\13\2,-\7\22\2\2-\t\3\2\2\2./\7\33\2\2/\65\5\f\7\2\60\61\7\34\2"+ + "\2\61\62\7\33\2\2\62\64\5\f\7\2\63\60\3\2\2\2\64\67\3\2\2\2\65\63\3\2"+ + "\2\2\65\66\3\2\2\2\66:\3\2\2\2\67\65\3\2\2\289\7\34\2\29;\5\16\b\2:8\3"+ + "\2\2\2:;\3\2\2\2;\13\3\2\2\2<=\5\24\13\2=>\5\16\b\2>\r\3\2\2\2?@\7\26"+ + "\2\2@A\5\4\3\2AB\7\27\2\2BE\3\2\2\2CE\5\6\4\2D?\3\2\2\2DC\3\2\2\2E\17"+ + "\3\2\2\2FG\7\35\2\2GH\5\24\13\2HI\5\16\b\2I\21\3\2\2\2JK\7\36\2\2KL\5"+ + "\24\13\2LM\7\22\2\2M\23\3\2\2\2NO\b\13\1\2OP\7\f\2\2PU\5\24\13\13QR\7"+ + "\21\2\2RU\5\24\13\nSU\5\26\f\2TN\3\2\2\2TQ\3\2\2\2TS\3\2\2\2Um\3\2\2\2"+ + "VW\f\f\2\2WX\7\20\2\2Xl\5\24\13\rYZ\f\t\2\2Z[\t\2\2\2[l\5\24\13\n\\]\f"+ + "\b\2\2]^\t\3\2\2^l\5\24\13\t_`\f\7\2\2`a\t\4\2\2al\5\24\13\bbc\f\6\2\2"+ + "cd\t\5\2\2dl\5\24\13\7ef\f\5\2\2fg\7\4\2\2gl\5\24\13\6hi\f\4\2\2ij\7\3"+ + "\2\2jl\5\24\13\5kV\3\2\2\2kY\3\2\2\2k\\\3\2\2\2k_\3\2\2\2kb\3\2\2\2ke"+ + "\3\2\2\2kh\3\2\2\2lo\3\2\2\2mk\3\2\2\2mn\3\2\2\2n\25\3\2\2\2om\3\2\2\2"+ + "pq\7\24\2\2qr\5\24\13\2rs\7\25\2\2sz\3\2\2\2tz\t\6\2\2uz\t\7\2\2vz\7\37"+ + "\2\2wz\7\"\2\2xz\7\32\2\2yp\3\2\2\2yt\3\2\2\2yu\3\2\2\2yv\3\2\2\2yw\3"+ + "\2\2\2yx\3\2\2\2z\27\3\2\2\2\13\36\'\65:DTkmy"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/target/klang-1.0-jar-with-dependencies.jar b/target/klang-1.0-jar-with-dependencies.jar new file mode 100644 index 0000000..b45f168 Binary files /dev/null and b/target/klang-1.0-jar-with-dependencies.jar differ diff --git a/target/klang-1.0.jar b/target/klang-1.0.jar new file mode 100644 index 0000000..c829dd1 Binary files /dev/null and b/target/klang-1.0.jar differ diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..b250278 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Mon Oct 28 15:44:47 CET 2019 +groupId=de.hsrm.compiler +artifactId=klang +version=1.0 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..a5ea0b6 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,5 @@ +/home/marvin/Documents/university/compiler/antlr_test/klang/klang/src/main/java/de/hsrm/compiler/Klang/Klang.java +/home/marvin/Documents/university/compiler/antlr_test/klang/klang/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangParser.java +/home/marvin/Documents/university/compiler/antlr_test/klang/klang/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangBaseListener.java +/home/marvin/Documents/university/compiler/antlr_test/klang/klang/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangLexer.java +/home/marvin/Documents/university/compiler/antlr_test/klang/klang/target/generated-sources/antlr4/de/hsrm/compiler/Klang/KlangListener.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..1f9497b --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/home/marvin/Documents/university/compiler/antlr_test/klang/klang/src/test/java/de/hsrm/compiler/Klang/KlangTest.java