diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a29b5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/src/main/java/de/dhbw/horb/antlr/ +.idea diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..dab39b2 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copilot/chatSessions/00000000000.xd b/.idea/copilot/chatSessions/00000000000.xd new file mode 100644 index 0000000..16799c9 Binary files /dev/null and b/.idea/copilot/chatSessions/00000000000.xd differ diff --git a/.idea/copilot/chatSessions/blobs/version b/.idea/copilot/chatSessions/blobs/version new file mode 100644 index 0000000..720d64f Binary files /dev/null and b/.idea/copilot/chatSessions/blobs/version differ diff --git a/.idea/copilot/chatSessions/xd.lck b/.idea/copilot/chatSessions/xd.lck new file mode 100644 index 0000000..88b7cff --- /dev/null +++ b/.idea/copilot/chatSessions/xd.lck @@ -0,0 +1,47 @@ +Private property of Exodus: 36669@Simon-Lenovo-Ubuntu + +jetbrains.exodus.io.LockingManager.lock(LockingManager.kt:88) +jetbrains.exodus.io.LockingManager.lock(LockingManager.kt:39) +jetbrains.exodus.io.FileDataWriter.lock(FileDataWriter.kt:70) +jetbrains.exodus.log.Log.tryLock(Log.kt:804) +jetbrains.exodus.log.Log.(Log.kt:117) +jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:117) +jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:81) +jetbrains.exodus.env.Environments.newLogInstance(Environments.kt:77) +jetbrains.exodus.env.Environments$newInstance$4.invoke(Environments.kt:46) +jetbrains.exodus.env.Environments$newInstance$4.invoke(Environments.kt:46) +jetbrains.exodus.env.Environments.prepare(Environments.kt:120) +jetbrains.exodus.env.Environments.newInstance(Environments.kt:46) +kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore(EntityStoreHelper.kt:40) +kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore(EntityStoreHelper.kt:31) +kotlinx.dnq.store.container.EntityStoreHelperKt.createTransientEntityStore$default(EntityStoreHelper.kt:30) +com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.initStore(XdChatSessionPersistenceService.kt:115) +com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.(XdChatSessionPersistenceService.kt:22) +com.github.copilot.chat.session.persistence.xodus.XdChatSessionPersistenceService.(XdChatSessionPersistenceService.kt:15) +com.github.copilot.chat.session.persistence.ChatSessionPersistenceServiceKt.ChatSessionPersistenceService(ChatSessionPersistenceService.kt:43) +com.github.copilot.chat.session.persistence.ChatSessionPersistenceServiceKt.chatSessionsPersistenceService(ChatSessionPersistenceService.kt:53) +com.github.copilot.chat.session.ChatSessionManager.(ChatSessionManager.kt:45) +com.github.copilot.chat.session.ChatSessionManager.(ChatSessionManager.kt:25) +com.github.copilot.chat.window.CopilotChatToolWindow.onCopilotReady(CopilotChatToolWindow.kt:133) +com.github.copilot.chat.window.CopilotChatToolWindow.access$onCopilotReady(CopilotChatToolWindow.kt:40) +com.github.copilot.chat.window.CopilotChatToolWindow$initCopilotStatusListener$1.invoke(CopilotChatToolWindow.kt:118) +com.github.copilot.chat.window.CopilotChatToolWindow$initCopilotStatusListener$1.invoke(CopilotChatToolWindow.kt:115) +com.github.copilot.status.CopilotAuthStatusKt.subscribeToCopilotAuthStatus$lambda$0(CopilotAuthStatus.kt:44) +com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:700) +com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:664) +com.intellij.util.messages.impl.MessageBusImplKt.deliverMessage(MessageBusImpl.kt:423) +com.intellij.util.messages.impl.MessageBusImplKt.pumpWaiting(MessageBusImpl.kt:402) +com.intellij.util.messages.impl.MessageBusImplKt.access$pumpWaiting(MessageBusImpl.kt:1) +com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:461) +jdk.proxy7/jdk.proxy7.$Proxy158.onCopilotStatus(Unknown Source) +com.github.copilot.status.CopilotStatusService.notifyApplication(CopilotStatusService.java:76) +com.github.copilot.status.CopilotStatusService.notifyApplication(CopilotStatusService.java:64) +com.github.copilot.github.GitHubAuthStartupActivity.handleAuthNotifications(GitHubAuthStartupActivity.java:54) +com.github.copilot.github.GitHubAuthStartupActivity.execute(GitHubAuthStartupActivity.java:35) +com.intellij.ide.startup.impl.StartupManagerImplKt$launchActivity$1.invokeSuspend(StartupManagerImpl.kt:482) +kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) +kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) +kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) +kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793) +kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697) +kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684) diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b7d5522 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3a22547..6ec4b17 100644 --- a/pom.xml +++ b/pom.xml @@ -12,8 +12,8 @@ UTF-8 - 19 - 19 + 17 + 17 diff --git a/src/main/java/de/dhbw/horb/ASTGenerator.java b/src/main/java/de/dhbw/horb/ASTGenerator.java index d0802eb..90eb5df 100644 --- a/src/main/java/de/dhbw/horb/ASTGenerator.java +++ b/src/main/java/de/dhbw/horb/ASTGenerator.java @@ -1,6 +1,10 @@ package de.dhbw.horb; -import de.dhbw.horb.ast.*; +import de.dhbw.horb.antlr.DecafParser; +import de.dhbw.horb.ast.Function; +import de.dhbw.horb.ast.Program; +import de.dhbw.horb.ast.Type; +import de.dhbw.horb.ast.Variable; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/de/dhbw/horb/Compiler.java b/src/main/java/de/dhbw/horb/Compiler.java index 3562d1a..8d8b799 100644 --- a/src/main/java/de/dhbw/horb/Compiler.java +++ b/src/main/java/de/dhbw/horb/Compiler.java @@ -1,14 +1,12 @@ package de.dhbw.horb; -import de.dhbw.horb.ast.*; +import de.dhbw.horb.antlr.DecafLexer; +import de.dhbw.horb.antlr.DecafParser; +import de.dhbw.horb.ast.Program; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - /** * Decaf language Compiler */ diff --git a/src/main/java/de/dhbw/horb/ExpressionGenerator.java b/src/main/java/de/dhbw/horb/ExpressionGenerator.java index 205eb65..6baeee8 100644 --- a/src/main/java/de/dhbw/horb/ExpressionGenerator.java +++ b/src/main/java/de/dhbw/horb/ExpressionGenerator.java @@ -1,5 +1,7 @@ package de.dhbw.horb; +import de.dhbw.horb.antlr.DecafParser; +import de.dhbw.horb.antlr.DecafBaseVisitor; import de.dhbw.horb.ast.*; public class ExpressionGenerator extends DecafBaseVisitor { diff --git a/src/main/java/de/dhbw/horb/StatementGenerator.java b/src/main/java/de/dhbw/horb/StatementGenerator.java index 77efb6b..48ca10e 100644 --- a/src/main/java/de/dhbw/horb/StatementGenerator.java +++ b/src/main/java/de/dhbw/horb/StatementGenerator.java @@ -1,9 +1,8 @@ package de.dhbw.horb; -import de.dhbw.horb.ast.*; - -import java.util.ArrayList; -import java.util.List; +import de.dhbw.horb.antlr.DecafBaseVisitor; +import de.dhbw.horb.antlr.DecafParser; +import de.dhbw.horb.ast.Statement; public class StatementGenerator extends DecafBaseVisitor { @Override diff --git a/src/main/java/de/dhbw/horb/antlr/Decaf.interp b/src/main/java/de/dhbw/horb/antlr/Decaf.interp new file mode 100644 index 0000000..fdd9c32 --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/Decaf.interp @@ -0,0 +1,78 @@ +token literal names: +null +';' +'def' +'(' +')' +',' +'{' +'}' +'=' +'if' +'else' +'while' +'return' +'break' +'continue' +'true' +'false' +'-' +'+' +'*' +'int' +'bool' +'void' +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +SUB +ADD +MUL +INT +BOOL +VOID +IDENTIFIER +Number +WS + +rule names: +program +var +type +func +params +param +block +stmt +expr +binaryOp +loc +funcCall +args +literal +boolean +number +id + + +atn: +[4, 1, 25, 167, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 1, 0, 1, 0, 5, 0, 37, 8, 0, 10, 0, 12, 0, 40, 9, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 53, 8, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 5, 4, 61, 8, 4, 10, 4, 12, 4, 64, 9, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 5, 6, 71, 8, 6, 10, 6, 12, 6, 74, 9, 6, 1, 6, 5, 6, 77, 8, 6, 10, 6, 12, 6, 80, 9, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 99, 8, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 117, 8, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 127, 8, 8, 1, 8, 1, 8, 1, 8, 1, 8, 5, 8, 133, 8, 8, 10, 8, 12, 8, 136, 9, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 3, 11, 145, 8, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 5, 12, 152, 8, 12, 10, 12, 12, 12, 155, 9, 12, 1, 13, 1, 13, 3, 13, 159, 8, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 0, 1, 16, 17, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 0, 3, 1, 0, 20, 22, 1, 0, 17, 19, 1, 0, 15, 16, 170, 0, 38, 1, 0, 0, 0, 2, 41, 1, 0, 0, 0, 4, 45, 1, 0, 0, 0, 6, 47, 1, 0, 0, 0, 8, 57, 1, 0, 0, 0, 10, 65, 1, 0, 0, 0, 12, 68, 1, 0, 0, 0, 14, 116, 1, 0, 0, 0, 16, 126, 1, 0, 0, 0, 18, 137, 1, 0, 0, 0, 20, 139, 1, 0, 0, 0, 22, 141, 1, 0, 0, 0, 24, 148, 1, 0, 0, 0, 26, 158, 1, 0, 0, 0, 28, 160, 1, 0, 0, 0, 30, 162, 1, 0, 0, 0, 32, 164, 1, 0, 0, 0, 34, 37, 3, 2, 1, 0, 35, 37, 3, 6, 3, 0, 36, 34, 1, 0, 0, 0, 36, 35, 1, 0, 0, 0, 37, 40, 1, 0, 0, 0, 38, 36, 1, 0, 0, 0, 38, 39, 1, 0, 0, 0, 39, 1, 1, 0, 0, 0, 40, 38, 1, 0, 0, 0, 41, 42, 3, 4, 2, 0, 42, 43, 3, 32, 16, 0, 43, 44, 5, 1, 0, 0, 44, 3, 1, 0, 0, 0, 45, 46, 7, 0, 0, 0, 46, 5, 1, 0, 0, 0, 47, 48, 5, 2, 0, 0, 48, 49, 3, 4, 2, 0, 49, 50, 3, 32, 16, 0, 50, 52, 5, 3, 0, 0, 51, 53, 3, 8, 4, 0, 52, 51, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 55, 5, 4, 0, 0, 55, 56, 3, 12, 6, 0, 56, 7, 1, 0, 0, 0, 57, 62, 3, 10, 5, 0, 58, 59, 5, 5, 0, 0, 59, 61, 3, 10, 5, 0, 60, 58, 1, 0, 0, 0, 61, 64, 1, 0, 0, 0, 62, 60, 1, 0, 0, 0, 62, 63, 1, 0, 0, 0, 63, 9, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 65, 66, 3, 4, 2, 0, 66, 67, 3, 32, 16, 0, 67, 11, 1, 0, 0, 0, 68, 72, 5, 6, 0, 0, 69, 71, 3, 2, 1, 0, 70, 69, 1, 0, 0, 0, 71, 74, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 78, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 75, 77, 3, 14, 7, 0, 76, 75, 1, 0, 0, 0, 77, 80, 1, 0, 0, 0, 78, 76, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 81, 1, 0, 0, 0, 80, 78, 1, 0, 0, 0, 81, 82, 5, 7, 0, 0, 82, 13, 1, 0, 0, 0, 83, 84, 3, 20, 10, 0, 84, 85, 5, 8, 0, 0, 85, 86, 3, 16, 8, 0, 86, 87, 5, 1, 0, 0, 87, 117, 1, 0, 0, 0, 88, 89, 3, 22, 11, 0, 89, 90, 5, 1, 0, 0, 90, 117, 1, 0, 0, 0, 91, 92, 5, 9, 0, 0, 92, 93, 5, 3, 0, 0, 93, 94, 3, 16, 8, 0, 94, 95, 5, 4, 0, 0, 95, 98, 3, 12, 6, 0, 96, 97, 5, 10, 0, 0, 97, 99, 3, 12, 6, 0, 98, 96, 1, 0, 0, 0, 98, 99, 1, 0, 0, 0, 99, 117, 1, 0, 0, 0, 100, 101, 5, 11, 0, 0, 101, 102, 5, 3, 0, 0, 102, 103, 3, 16, 8, 0, 103, 104, 5, 4, 0, 0, 104, 105, 3, 12, 6, 0, 105, 117, 1, 0, 0, 0, 106, 107, 5, 12, 0, 0, 107, 108, 3, 16, 8, 0, 108, 109, 5, 1, 0, 0, 109, 117, 1, 0, 0, 0, 110, 111, 5, 12, 0, 0, 111, 117, 5, 1, 0, 0, 112, 113, 5, 13, 0, 0, 113, 117, 5, 1, 0, 0, 114, 115, 5, 14, 0, 0, 115, 117, 5, 1, 0, 0, 116, 83, 1, 0, 0, 0, 116, 88, 1, 0, 0, 0, 116, 91, 1, 0, 0, 0, 116, 100, 1, 0, 0, 0, 116, 106, 1, 0, 0, 0, 116, 110, 1, 0, 0, 0, 116, 112, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 117, 15, 1, 0, 0, 0, 118, 119, 6, 8, -1, 0, 119, 127, 3, 26, 13, 0, 120, 121, 5, 3, 0, 0, 121, 122, 3, 16, 8, 0, 122, 123, 5, 4, 0, 0, 123, 127, 1, 0, 0, 0, 124, 127, 3, 22, 11, 0, 125, 127, 3, 20, 10, 0, 126, 118, 1, 0, 0, 0, 126, 120, 1, 0, 0, 0, 126, 124, 1, 0, 0, 0, 126, 125, 1, 0, 0, 0, 127, 134, 1, 0, 0, 0, 128, 129, 10, 5, 0, 0, 129, 130, 3, 18, 9, 0, 130, 131, 3, 16, 8, 6, 131, 133, 1, 0, 0, 0, 132, 128, 1, 0, 0, 0, 133, 136, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 17, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 137, 138, 7, 1, 0, 0, 138, 19, 1, 0, 0, 0, 139, 140, 3, 32, 16, 0, 140, 21, 1, 0, 0, 0, 141, 142, 3, 32, 16, 0, 142, 144, 5, 3, 0, 0, 143, 145, 3, 24, 12, 0, 144, 143, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 146, 1, 0, 0, 0, 146, 147, 5, 4, 0, 0, 147, 23, 1, 0, 0, 0, 148, 153, 3, 16, 8, 0, 149, 150, 5, 5, 0, 0, 150, 152, 3, 16, 8, 0, 151, 149, 1, 0, 0, 0, 152, 155, 1, 0, 0, 0, 153, 151, 1, 0, 0, 0, 153, 154, 1, 0, 0, 0, 154, 25, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 156, 159, 3, 30, 15, 0, 157, 159, 3, 28, 14, 0, 158, 156, 1, 0, 0, 0, 158, 157, 1, 0, 0, 0, 159, 27, 1, 0, 0, 0, 160, 161, 7, 2, 0, 0, 161, 29, 1, 0, 0, 0, 162, 163, 5, 24, 0, 0, 163, 31, 1, 0, 0, 0, 164, 165, 5, 23, 0, 0, 165, 33, 1, 0, 0, 0, 13, 36, 38, 52, 62, 72, 78, 98, 116, 126, 134, 144, 153, 158] \ No newline at end of file diff --git a/src/main/java/de/dhbw/horb/antlr/Decaf.tokens b/src/main/java/de/dhbw/horb/antlr/Decaf.tokens new file mode 100644 index 0000000..bb87b00 --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/Decaf.tokens @@ -0,0 +1,47 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +T__7=8 +T__8=9 +T__9=10 +T__10=11 +T__11=12 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +SUB=17 +ADD=18 +MUL=19 +INT=20 +BOOL=21 +VOID=22 +IDENTIFIER=23 +Number=24 +WS=25 +';'=1 +'def'=2 +'('=3 +')'=4 +','=5 +'{'=6 +'}'=7 +'='=8 +'if'=9 +'else'=10 +'while'=11 +'return'=12 +'break'=13 +'continue'=14 +'true'=15 +'false'=16 +'-'=17 +'+'=18 +'*'=19 +'int'=20 +'bool'=21 +'void'=22 diff --git a/src/main/java/de/dhbw/horb/antlr/DecafBaseListener.java b/src/main/java/de/dhbw/horb/antlr/DecafBaseListener.java new file mode 100644 index 0000000..1dc2280 --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/DecafBaseListener.java @@ -0,0 +1,376 @@ +// Generated from /home/simon/dev/AntlrAssignment3Template/src/main/antlr4/de/dhbw/horb/Decaf.g4 by ANTLR 4.13.1 +package de.dhbw.horb.antlr; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link DecafListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class DecafBaseListener implements DecafListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterProgram(DecafParser.ProgramContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitProgram(DecafParser.ProgramContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterVar(DecafParser.VarContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitVar(DecafParser.VarContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterType(DecafParser.TypeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitType(DecafParser.TypeContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunc(DecafParser.FuncContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunc(DecafParser.FuncContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParams(DecafParser.ParamsContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParams(DecafParser.ParamsContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParam(DecafParser.ParamContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParam(DecafParser.ParamContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void enterAssign(DecafParser.AssignContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitAssign(DecafParser.AssignContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunctionCall(DecafParser.FunctionCallContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunctionCall(DecafParser.FunctionCallContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIf(DecafParser.IfContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIf(DecafParser.IfContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterWhile(DecafParser.WhileContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitWhile(DecafParser.WhileContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterReturn(DecafParser.ReturnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitReturn(DecafParser.ReturnContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterReturnVoid(DecafParser.ReturnVoidContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitReturnVoid(DecafParser.ReturnVoidContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBreak(DecafParser.BreakContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBreak(DecafParser.BreakContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterContinue(DecafParser.ContinueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitContinue(DecafParser.ContinueContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExpression(DecafParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExpression(DecafParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunCallExpression(DecafParser.FunCallExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunCallExpression(DecafParser.FunCallExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterConstant(DecafParser.ConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitConstant(DecafParser.ConstantContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBinaryOperation(DecafParser.BinaryOperationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBinaryOperation(DecafParser.BinaryOperationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLocation(DecafParser.LocationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLocation(DecafParser.LocationContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBinaryOp(DecafParser.BinaryOpContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBinaryOp(DecafParser.BinaryOpContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLoc(DecafParser.LocContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLoc(DecafParser.LocContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFuncCall(DecafParser.FuncCallContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFuncCall(DecafParser.FuncCallContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArgs(DecafParser.ArgsContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArgs(DecafParser.ArgsContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLiteral(DecafParser.LiteralContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLiteral(DecafParser.LiteralContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBoolean(DecafParser.BooleanContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBoolean(DecafParser.BooleanContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterNumber(DecafParser.NumberContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitNumber(DecafParser.NumberContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterId(DecafParser.IdContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitId(DecafParser.IdContext 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/src/main/java/de/dhbw/horb/antlr/DecafBaseVisitor.java b/src/main/java/de/dhbw/horb/antlr/DecafBaseVisitor.java new file mode 100644 index 0000000..daf1428 --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/DecafBaseVisitor.java @@ -0,0 +1,211 @@ +// Generated from /home/simon/dev/AntlrAssignment3Template/src/main/antlr4/de/dhbw/horb/Decaf.g4 by ANTLR 4.13.1 +package de.dhbw.horb.antlr; +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link DecafVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +@SuppressWarnings("CheckReturnValue") +public class DecafBaseVisitor extends AbstractParseTreeVisitor implements DecafVisitor { + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitProgram(DecafParser.ProgramContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitVar(DecafParser.VarContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitType(DecafParser.TypeContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunc(DecafParser.FuncContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParams(DecafParser.ParamsContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParam(DecafParser.ParamContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBlock(DecafParser.BlockContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitAssign(DecafParser.AssignContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunctionCall(DecafParser.FunctionCallContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitIf(DecafParser.IfContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitWhile(DecafParser.WhileContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitReturn(DecafParser.ReturnContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitReturnVoid(DecafParser.ReturnVoidContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBreak(DecafParser.BreakContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitContinue(DecafParser.ContinueContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExpression(DecafParser.ExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitConstant(DecafParser.ConstantContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBinaryOperation(DecafParser.BinaryOperationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLocation(DecafParser.LocationContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBinaryOp(DecafParser.BinaryOpContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLoc(DecafParser.LocContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFuncCall(DecafParser.FuncCallContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitArgs(DecafParser.ArgsContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLiteral(DecafParser.LiteralContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitBoolean(DecafParser.BooleanContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitNumber(DecafParser.NumberContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitId(DecafParser.IdContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/main/java/de/dhbw/horb/antlr/DecafLexer.interp b/src/main/java/de/dhbw/horb/antlr/DecafLexer.interp new file mode 100644 index 0000000..22f63d0 --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/DecafLexer.interp @@ -0,0 +1,92 @@ +token literal names: +null +';' +'def' +'(' +')' +',' +'{' +'}' +'=' +'if' +'else' +'while' +'return' +'break' +'continue' +'true' +'false' +'-' +'+' +'*' +'int' +'bool' +'void' +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +SUB +ADD +MUL +INT +BOOL +VOID +IDENTIFIER +Number +WS + +rule names: +T__0 +T__1 +T__2 +T__3 +T__4 +T__5 +T__6 +T__7 +T__8 +T__9 +T__10 +T__11 +T__12 +T__13 +T__14 +T__15 +SUB +ADD +MUL +INT +BOOL +VOID +IDENTIFIER +Number +WS + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 25, 150, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 22, 4, 22, 138, 8, 22, 11, 22, 12, 22, 139, 1, 23, 4, 23, 143, 8, 23, 11, 23, 12, 23, 144, 1, 24, 1, 24, 1, 24, 1, 24, 0, 0, 25, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 1, 0, 3, 2, 0, 65, 90, 97, 122, 1, 0, 48, 57, 3, 0, 9, 10, 13, 13, 32, 32, 151, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 1, 51, 1, 0, 0, 0, 3, 53, 1, 0, 0, 0, 5, 57, 1, 0, 0, 0, 7, 59, 1, 0, 0, 0, 9, 61, 1, 0, 0, 0, 11, 63, 1, 0, 0, 0, 13, 65, 1, 0, 0, 0, 15, 67, 1, 0, 0, 0, 17, 69, 1, 0, 0, 0, 19, 72, 1, 0, 0, 0, 21, 77, 1, 0, 0, 0, 23, 83, 1, 0, 0, 0, 25, 90, 1, 0, 0, 0, 27, 96, 1, 0, 0, 0, 29, 105, 1, 0, 0, 0, 31, 110, 1, 0, 0, 0, 33, 116, 1, 0, 0, 0, 35, 118, 1, 0, 0, 0, 37, 120, 1, 0, 0, 0, 39, 122, 1, 0, 0, 0, 41, 126, 1, 0, 0, 0, 43, 131, 1, 0, 0, 0, 45, 137, 1, 0, 0, 0, 47, 142, 1, 0, 0, 0, 49, 146, 1, 0, 0, 0, 51, 52, 5, 59, 0, 0, 52, 2, 1, 0, 0, 0, 53, 54, 5, 100, 0, 0, 54, 55, 5, 101, 0, 0, 55, 56, 5, 102, 0, 0, 56, 4, 1, 0, 0, 0, 57, 58, 5, 40, 0, 0, 58, 6, 1, 0, 0, 0, 59, 60, 5, 41, 0, 0, 60, 8, 1, 0, 0, 0, 61, 62, 5, 44, 0, 0, 62, 10, 1, 0, 0, 0, 63, 64, 5, 123, 0, 0, 64, 12, 1, 0, 0, 0, 65, 66, 5, 125, 0, 0, 66, 14, 1, 0, 0, 0, 67, 68, 5, 61, 0, 0, 68, 16, 1, 0, 0, 0, 69, 70, 5, 105, 0, 0, 70, 71, 5, 102, 0, 0, 71, 18, 1, 0, 0, 0, 72, 73, 5, 101, 0, 0, 73, 74, 5, 108, 0, 0, 74, 75, 5, 115, 0, 0, 75, 76, 5, 101, 0, 0, 76, 20, 1, 0, 0, 0, 77, 78, 5, 119, 0, 0, 78, 79, 5, 104, 0, 0, 79, 80, 5, 105, 0, 0, 80, 81, 5, 108, 0, 0, 81, 82, 5, 101, 0, 0, 82, 22, 1, 0, 0, 0, 83, 84, 5, 114, 0, 0, 84, 85, 5, 101, 0, 0, 85, 86, 5, 116, 0, 0, 86, 87, 5, 117, 0, 0, 87, 88, 5, 114, 0, 0, 88, 89, 5, 110, 0, 0, 89, 24, 1, 0, 0, 0, 90, 91, 5, 98, 0, 0, 91, 92, 5, 114, 0, 0, 92, 93, 5, 101, 0, 0, 93, 94, 5, 97, 0, 0, 94, 95, 5, 107, 0, 0, 95, 26, 1, 0, 0, 0, 96, 97, 5, 99, 0, 0, 97, 98, 5, 111, 0, 0, 98, 99, 5, 110, 0, 0, 99, 100, 5, 116, 0, 0, 100, 101, 5, 105, 0, 0, 101, 102, 5, 110, 0, 0, 102, 103, 5, 117, 0, 0, 103, 104, 5, 101, 0, 0, 104, 28, 1, 0, 0, 0, 105, 106, 5, 116, 0, 0, 106, 107, 5, 114, 0, 0, 107, 108, 5, 117, 0, 0, 108, 109, 5, 101, 0, 0, 109, 30, 1, 0, 0, 0, 110, 111, 5, 102, 0, 0, 111, 112, 5, 97, 0, 0, 112, 113, 5, 108, 0, 0, 113, 114, 5, 115, 0, 0, 114, 115, 5, 101, 0, 0, 115, 32, 1, 0, 0, 0, 116, 117, 5, 45, 0, 0, 117, 34, 1, 0, 0, 0, 118, 119, 5, 43, 0, 0, 119, 36, 1, 0, 0, 0, 120, 121, 5, 42, 0, 0, 121, 38, 1, 0, 0, 0, 122, 123, 5, 105, 0, 0, 123, 124, 5, 110, 0, 0, 124, 125, 5, 116, 0, 0, 125, 40, 1, 0, 0, 0, 126, 127, 5, 98, 0, 0, 127, 128, 5, 111, 0, 0, 128, 129, 5, 111, 0, 0, 129, 130, 5, 108, 0, 0, 130, 42, 1, 0, 0, 0, 131, 132, 5, 118, 0, 0, 132, 133, 5, 111, 0, 0, 133, 134, 5, 105, 0, 0, 134, 135, 5, 100, 0, 0, 135, 44, 1, 0, 0, 0, 136, 138, 7, 0, 0, 0, 137, 136, 1, 0, 0, 0, 138, 139, 1, 0, 0, 0, 139, 137, 1, 0, 0, 0, 139, 140, 1, 0, 0, 0, 140, 46, 1, 0, 0, 0, 141, 143, 7, 1, 0, 0, 142, 141, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 142, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 48, 1, 0, 0, 0, 146, 147, 7, 2, 0, 0, 147, 148, 1, 0, 0, 0, 148, 149, 6, 24, 0, 0, 149, 50, 1, 0, 0, 0, 3, 0, 139, 144, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/de/dhbw/horb/antlr/DecafLexer.java b/src/main/java/de/dhbw/horb/antlr/DecafLexer.java new file mode 100644 index 0000000..02a84e0 --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/DecafLexer.java @@ -0,0 +1,210 @@ +// Generated from /home/simon/dev/AntlrAssignment3Template/src/main/antlr4/de/dhbw/horb/Decaf.g4 by ANTLR 4.13.1 +package de.dhbw.horb.antlr; +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", "CheckReturnValue", "this-escape"}) +public class DecafLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, SUB=17, + ADD=18, MUL=19, INT=20, BOOL=21, VOID=22, IDENTIFIER=23, Number=24, WS=25; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "SUB", + "ADD", "MUL", "INT", "BOOL", "VOID", "IDENTIFIER", "Number", "WS" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "';'", "'def'", "'('", "')'", "','", "'{'", "'}'", "'='", "'if'", + "'else'", "'while'", "'return'", "'break'", "'continue'", "'true'", "'false'", + "'-'", "'+'", "'*'", "'int'", "'bool'", "'void'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, "SUB", "ADD", "MUL", "INT", "BOOL", "VOID", + "IDENTIFIER", "Number", "WS" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + 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 DecafLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "Decaf.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 = + "\u0004\u0000\u0019\u0096\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002"+ + "\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002"+ + "\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002"+ + "\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002"+ + "\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e"+ + "\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011"+ + "\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014"+ + "\u0002\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017"+ + "\u0002\u0018\u0007\u0018\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ + "\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006"+ + "\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001"+ + "\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001"+ + "\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001"+ + "\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\r\u0001\r"+ + "\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001"+ + "\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001"+ + "\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001"+ + "\u0011\u0001\u0011\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001"+ + "\u0013\u0001\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001"+ + "\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015\u0001"+ + "\u0016\u0004\u0016\u008a\b\u0016\u000b\u0016\f\u0016\u008b\u0001\u0017"+ + "\u0004\u0017\u008f\b\u0017\u000b\u0017\f\u0017\u0090\u0001\u0018\u0001"+ + "\u0018\u0001\u0018\u0001\u0018\u0000\u0000\u0019\u0001\u0001\u0003\u0002"+ + "\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f\b\u0011\t\u0013"+ + "\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d\u000f\u001f\u0010!\u0011"+ + "#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/\u00181\u0019\u0001\u0000"+ + "\u0003\u0002\u0000AZaz\u0001\u000009\u0003\u0000\t\n\r\r \u0097\u0000"+ + "\u0001\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000"+ + "\u0005\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000\u0000\u0000\u0000"+ + "\t\u0001\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r"+ + "\u0001\u0000\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000\u0000\u0011"+ + "\u0001\u0000\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000\u0000\u0015"+ + "\u0001\u0000\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000\u0000\u0019"+ + "\u0001\u0000\u0000\u0000\u0000\u001b\u0001\u0000\u0000\u0000\u0000\u001d"+ + "\u0001\u0000\u0000\u0000\u0000\u001f\u0001\u0000\u0000\u0000\u0000!\u0001"+ + "\u0000\u0000\u0000\u0000#\u0001\u0000\u0000\u0000\u0000%\u0001\u0000\u0000"+ + "\u0000\u0000\'\u0001\u0000\u0000\u0000\u0000)\u0001\u0000\u0000\u0000"+ + "\u0000+\u0001\u0000\u0000\u0000\u0000-\u0001\u0000\u0000\u0000\u0000/"+ + "\u0001\u0000\u0000\u0000\u00001\u0001\u0000\u0000\u0000\u00013\u0001\u0000"+ + "\u0000\u0000\u00035\u0001\u0000\u0000\u0000\u00059\u0001\u0000\u0000\u0000"+ + "\u0007;\u0001\u0000\u0000\u0000\t=\u0001\u0000\u0000\u0000\u000b?\u0001"+ + "\u0000\u0000\u0000\rA\u0001\u0000\u0000\u0000\u000fC\u0001\u0000\u0000"+ + "\u0000\u0011E\u0001\u0000\u0000\u0000\u0013H\u0001\u0000\u0000\u0000\u0015"+ + "M\u0001\u0000\u0000\u0000\u0017S\u0001\u0000\u0000\u0000\u0019Z\u0001"+ + "\u0000\u0000\u0000\u001b`\u0001\u0000\u0000\u0000\u001di\u0001\u0000\u0000"+ + "\u0000\u001fn\u0001\u0000\u0000\u0000!t\u0001\u0000\u0000\u0000#v\u0001"+ + "\u0000\u0000\u0000%x\u0001\u0000\u0000\u0000\'z\u0001\u0000\u0000\u0000"+ + ")~\u0001\u0000\u0000\u0000+\u0083\u0001\u0000\u0000\u0000-\u0089\u0001"+ + "\u0000\u0000\u0000/\u008e\u0001\u0000\u0000\u00001\u0092\u0001\u0000\u0000"+ + "\u000034\u0005;\u0000\u00004\u0002\u0001\u0000\u0000\u000056\u0005d\u0000"+ + "\u000067\u0005e\u0000\u000078\u0005f\u0000\u00008\u0004\u0001\u0000\u0000"+ + "\u00009:\u0005(\u0000\u0000:\u0006\u0001\u0000\u0000\u0000;<\u0005)\u0000"+ + "\u0000<\b\u0001\u0000\u0000\u0000=>\u0005,\u0000\u0000>\n\u0001\u0000"+ + "\u0000\u0000?@\u0005{\u0000\u0000@\f\u0001\u0000\u0000\u0000AB\u0005}"+ + "\u0000\u0000B\u000e\u0001\u0000\u0000\u0000CD\u0005=\u0000\u0000D\u0010"+ + "\u0001\u0000\u0000\u0000EF\u0005i\u0000\u0000FG\u0005f\u0000\u0000G\u0012"+ + "\u0001\u0000\u0000\u0000HI\u0005e\u0000\u0000IJ\u0005l\u0000\u0000JK\u0005"+ + "s\u0000\u0000KL\u0005e\u0000\u0000L\u0014\u0001\u0000\u0000\u0000MN\u0005"+ + "w\u0000\u0000NO\u0005h\u0000\u0000OP\u0005i\u0000\u0000PQ\u0005l\u0000"+ + "\u0000QR\u0005e\u0000\u0000R\u0016\u0001\u0000\u0000\u0000ST\u0005r\u0000"+ + "\u0000TU\u0005e\u0000\u0000UV\u0005t\u0000\u0000VW\u0005u\u0000\u0000"+ + "WX\u0005r\u0000\u0000XY\u0005n\u0000\u0000Y\u0018\u0001\u0000\u0000\u0000"+ + "Z[\u0005b\u0000\u0000[\\\u0005r\u0000\u0000\\]\u0005e\u0000\u0000]^\u0005"+ + "a\u0000\u0000^_\u0005k\u0000\u0000_\u001a\u0001\u0000\u0000\u0000`a\u0005"+ + "c\u0000\u0000ab\u0005o\u0000\u0000bc\u0005n\u0000\u0000cd\u0005t\u0000"+ + "\u0000de\u0005i\u0000\u0000ef\u0005n\u0000\u0000fg\u0005u\u0000\u0000"+ + "gh\u0005e\u0000\u0000h\u001c\u0001\u0000\u0000\u0000ij\u0005t\u0000\u0000"+ + "jk\u0005r\u0000\u0000kl\u0005u\u0000\u0000lm\u0005e\u0000\u0000m\u001e"+ + "\u0001\u0000\u0000\u0000no\u0005f\u0000\u0000op\u0005a\u0000\u0000pq\u0005"+ + "l\u0000\u0000qr\u0005s\u0000\u0000rs\u0005e\u0000\u0000s \u0001\u0000"+ + "\u0000\u0000tu\u0005-\u0000\u0000u\"\u0001\u0000\u0000\u0000vw\u0005+"+ + "\u0000\u0000w$\u0001\u0000\u0000\u0000xy\u0005*\u0000\u0000y&\u0001\u0000"+ + "\u0000\u0000z{\u0005i\u0000\u0000{|\u0005n\u0000\u0000|}\u0005t\u0000"+ + "\u0000}(\u0001\u0000\u0000\u0000~\u007f\u0005b\u0000\u0000\u007f\u0080"+ + "\u0005o\u0000\u0000\u0080\u0081\u0005o\u0000\u0000\u0081\u0082\u0005l"+ + "\u0000\u0000\u0082*\u0001\u0000\u0000\u0000\u0083\u0084\u0005v\u0000\u0000"+ + "\u0084\u0085\u0005o\u0000\u0000\u0085\u0086\u0005i\u0000\u0000\u0086\u0087"+ + "\u0005d\u0000\u0000\u0087,\u0001\u0000\u0000\u0000\u0088\u008a\u0007\u0000"+ + "\u0000\u0000\u0089\u0088\u0001\u0000\u0000\u0000\u008a\u008b\u0001\u0000"+ + "\u0000\u0000\u008b\u0089\u0001\u0000\u0000\u0000\u008b\u008c\u0001\u0000"+ + "\u0000\u0000\u008c.\u0001\u0000\u0000\u0000\u008d\u008f\u0007\u0001\u0000"+ + "\u0000\u008e\u008d\u0001\u0000\u0000\u0000\u008f\u0090\u0001\u0000\u0000"+ + "\u0000\u0090\u008e\u0001\u0000\u0000\u0000\u0090\u0091\u0001\u0000\u0000"+ + "\u0000\u00910\u0001\u0000\u0000\u0000\u0092\u0093\u0007\u0002\u0000\u0000"+ + "\u0093\u0094\u0001\u0000\u0000\u0000\u0094\u0095\u0006\u0018\u0000\u0000"+ + "\u00952\u0001\u0000\u0000\u0000\u0003\u0000\u008b\u0090\u0001\u0006\u0000"+ + "\u0000"; + 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/java/de/dhbw/horb/antlr/DecafLexer.tokens b/src/main/java/de/dhbw/horb/antlr/DecafLexer.tokens new file mode 100644 index 0000000..bb87b00 --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/DecafLexer.tokens @@ -0,0 +1,47 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +T__4=5 +T__5=6 +T__6=7 +T__7=8 +T__8=9 +T__9=10 +T__10=11 +T__11=12 +T__12=13 +T__13=14 +T__14=15 +T__15=16 +SUB=17 +ADD=18 +MUL=19 +INT=20 +BOOL=21 +VOID=22 +IDENTIFIER=23 +Number=24 +WS=25 +';'=1 +'def'=2 +'('=3 +')'=4 +','=5 +'{'=6 +'}'=7 +'='=8 +'if'=9 +'else'=10 +'while'=11 +'return'=12 +'break'=13 +'continue'=14 +'true'=15 +'false'=16 +'-'=17 +'+'=18 +'*'=19 +'int'=20 +'bool'=21 +'void'=22 diff --git a/src/main/java/de/dhbw/horb/antlr/DecafListener.java b/src/main/java/de/dhbw/horb/antlr/DecafListener.java new file mode 100644 index 0000000..5ce5f5b --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/DecafListener.java @@ -0,0 +1,316 @@ +// Generated from /home/simon/dev/AntlrAssignment3Template/src/main/antlr4/de/dhbw/horb/Decaf.g4 by ANTLR 4.13.1 +package de.dhbw.horb.antlr; +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link DecafParser}. + */ +public interface DecafListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link DecafParser#program}. + * @param ctx the parse tree + */ + void enterProgram(DecafParser.ProgramContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#program}. + * @param ctx the parse tree + */ + void exitProgram(DecafParser.ProgramContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#var}. + * @param ctx the parse tree + */ + void enterVar(DecafParser.VarContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#var}. + * @param ctx the parse tree + */ + void exitVar(DecafParser.VarContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#type}. + * @param ctx the parse tree + */ + void enterType(DecafParser.TypeContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#type}. + * @param ctx the parse tree + */ + void exitType(DecafParser.TypeContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#func}. + * @param ctx the parse tree + */ + void enterFunc(DecafParser.FuncContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#func}. + * @param ctx the parse tree + */ + void exitFunc(DecafParser.FuncContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#params}. + * @param ctx the parse tree + */ + void enterParams(DecafParser.ParamsContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#params}. + * @param ctx the parse tree + */ + void exitParams(DecafParser.ParamsContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#param}. + * @param ctx the parse tree + */ + void enterParam(DecafParser.ParamContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#param}. + * @param ctx the parse tree + */ + void exitParam(DecafParser.ParamContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#block}. + * @param ctx the parse tree + */ + void enterBlock(DecafParser.BlockContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#block}. + * @param ctx the parse tree + */ + void exitBlock(DecafParser.BlockContext ctx); + /** + * Enter a parse tree produced by the {@code Assign} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void enterAssign(DecafParser.AssignContext ctx); + /** + * Exit a parse tree produced by the {@code Assign} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void exitAssign(DecafParser.AssignContext ctx); + /** + * Enter a parse tree produced by the {@code FunctionCall} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void enterFunctionCall(DecafParser.FunctionCallContext ctx); + /** + * Exit a parse tree produced by the {@code FunctionCall} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void exitFunctionCall(DecafParser.FunctionCallContext ctx); + /** + * Enter a parse tree produced by the {@code If} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void enterIf(DecafParser.IfContext ctx); + /** + * Exit a parse tree produced by the {@code If} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void exitIf(DecafParser.IfContext ctx); + /** + * Enter a parse tree produced by the {@code While} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void enterWhile(DecafParser.WhileContext ctx); + /** + * Exit a parse tree produced by the {@code While} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void exitWhile(DecafParser.WhileContext ctx); + /** + * Enter a parse tree produced by the {@code Return} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void enterReturn(DecafParser.ReturnContext ctx); + /** + * Exit a parse tree produced by the {@code Return} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void exitReturn(DecafParser.ReturnContext ctx); + /** + * Enter a parse tree produced by the {@code ReturnVoid} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void enterReturnVoid(DecafParser.ReturnVoidContext ctx); + /** + * Exit a parse tree produced by the {@code ReturnVoid} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void exitReturnVoid(DecafParser.ReturnVoidContext ctx); + /** + * Enter a parse tree produced by the {@code Break} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void enterBreak(DecafParser.BreakContext ctx); + /** + * Exit a parse tree produced by the {@code Break} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void exitBreak(DecafParser.BreakContext ctx); + /** + * Enter a parse tree produced by the {@code Continue} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void enterContinue(DecafParser.ContinueContext ctx); + /** + * Exit a parse tree produced by the {@code Continue} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + */ + void exitContinue(DecafParser.ContinueContext ctx); + /** + * Enter a parse tree produced by the {@code Expression} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void enterExpression(DecafParser.ExpressionContext ctx); + /** + * Exit a parse tree produced by the {@code Expression} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void exitExpression(DecafParser.ExpressionContext ctx); + /** + * Enter a parse tree produced by the {@code FunCallExpression} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void enterFunCallExpression(DecafParser.FunCallExpressionContext ctx); + /** + * Exit a parse tree produced by the {@code FunCallExpression} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void exitFunCallExpression(DecafParser.FunCallExpressionContext ctx); + /** + * Enter a parse tree produced by the {@code Constant} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void enterConstant(DecafParser.ConstantContext ctx); + /** + * Exit a parse tree produced by the {@code Constant} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void exitConstant(DecafParser.ConstantContext ctx); + /** + * Enter a parse tree produced by the {@code BinaryOperation} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void enterBinaryOperation(DecafParser.BinaryOperationContext ctx); + /** + * Exit a parse tree produced by the {@code BinaryOperation} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void exitBinaryOperation(DecafParser.BinaryOperationContext ctx); + /** + * Enter a parse tree produced by the {@code Location} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void enterLocation(DecafParser.LocationContext ctx); + /** + * Exit a parse tree produced by the {@code Location} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + */ + void exitLocation(DecafParser.LocationContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#binaryOp}. + * @param ctx the parse tree + */ + void enterBinaryOp(DecafParser.BinaryOpContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#binaryOp}. + * @param ctx the parse tree + */ + void exitBinaryOp(DecafParser.BinaryOpContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#loc}. + * @param ctx the parse tree + */ + void enterLoc(DecafParser.LocContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#loc}. + * @param ctx the parse tree + */ + void exitLoc(DecafParser.LocContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#funcCall}. + * @param ctx the parse tree + */ + void enterFuncCall(DecafParser.FuncCallContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#funcCall}. + * @param ctx the parse tree + */ + void exitFuncCall(DecafParser.FuncCallContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#args}. + * @param ctx the parse tree + */ + void enterArgs(DecafParser.ArgsContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#args}. + * @param ctx the parse tree + */ + void exitArgs(DecafParser.ArgsContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#literal}. + * @param ctx the parse tree + */ + void enterLiteral(DecafParser.LiteralContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#literal}. + * @param ctx the parse tree + */ + void exitLiteral(DecafParser.LiteralContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#boolean}. + * @param ctx the parse tree + */ + void enterBoolean(DecafParser.BooleanContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#boolean}. + * @param ctx the parse tree + */ + void exitBoolean(DecafParser.BooleanContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#number}. + * @param ctx the parse tree + */ + void enterNumber(DecafParser.NumberContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#number}. + * @param ctx the parse tree + */ + void exitNumber(DecafParser.NumberContext ctx); + /** + * Enter a parse tree produced by {@link DecafParser#id}. + * @param ctx the parse tree + */ + void enterId(DecafParser.IdContext ctx); + /** + * Exit a parse tree produced by {@link DecafParser#id}. + * @param ctx the parse tree + */ + void exitId(DecafParser.IdContext ctx); +} \ No newline at end of file diff --git a/src/main/java/de/dhbw/horb/antlr/DecafParser.java b/src/main/java/de/dhbw/horb/antlr/DecafParser.java new file mode 100644 index 0000000..99a80fb --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/DecafParser.java @@ -0,0 +1,1639 @@ +// Generated from /home/simon/dev/AntlrAssignment3Template/src/main/antlr4/de/dhbw/horb/Decaf.g4 by ANTLR 4.13.1 +package de.dhbw.horb.antlr; +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", "CheckReturnValue"}) +public class DecafParser extends Parser { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, SUB=17, + ADD=18, MUL=19, INT=20, BOOL=21, VOID=22, IDENTIFIER=23, Number=24, WS=25; + public static final int + RULE_program = 0, RULE_var = 1, RULE_type = 2, RULE_func = 3, RULE_params = 4, + RULE_param = 5, RULE_block = 6, RULE_stmt = 7, RULE_expr = 8, RULE_binaryOp = 9, + RULE_loc = 10, RULE_funcCall = 11, RULE_args = 12, RULE_literal = 13, + RULE_boolean = 14, RULE_number = 15, RULE_id = 16; + private static String[] makeRuleNames() { + return new String[] { + "program", "var", "type", "func", "params", "param", "block", "stmt", + "expr", "binaryOp", "loc", "funcCall", "args", "literal", "boolean", + "number", "id" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "';'", "'def'", "'('", "')'", "','", "'{'", "'}'", "'='", "'if'", + "'else'", "'while'", "'return'", "'break'", "'continue'", "'true'", "'false'", + "'-'", "'+'", "'*'", "'int'", "'bool'", "'void'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, "SUB", "ADD", "MUL", "INT", "BOOL", "VOID", + "IDENTIFIER", "Number", "WS" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + 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 "Decaf.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public DecafParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class ProgramContext extends ParserRuleContext { + public List var() { + return getRuleContexts(VarContext.class); + } + public VarContext var(int i) { + return getRuleContext(VarContext.class,i); + } + public List func() { + return getRuleContexts(FuncContext.class); + } + public FuncContext func(int i) { + return getRuleContext(FuncContext.class,i); + } + public ProgramContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_program; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterProgram(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitProgram(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitProgram(this); + else return visitor.visitChildren(this); + } + } + + public final ProgramContext program() throws RecognitionException { + ProgramContext _localctx = new ProgramContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_program); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(38); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 7340036L) != 0)) { + { + setState(36); + _errHandler.sync(this); + switch (_input.LA(1)) { + case INT: + case BOOL: + case VOID: + { + setState(34); + var(); + } + break; + case T__1: + { + setState(35); + func(); + } + break; + default: + throw new NoViableAltException(this); + } + } + setState(40); + _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; + } + + @SuppressWarnings("CheckReturnValue") + public static class VarContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public IdContext id() { + return getRuleContext(IdContext.class,0); + } + public VarContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_var; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterVar(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitVar(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitVar(this); + else return visitor.visitChildren(this); + } + } + + public final VarContext var() throws RecognitionException { + VarContext _localctx = new VarContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_var); + try { + enterOuterAlt(_localctx, 1); + { + setState(41); + type(); + setState(42); + id(); + setState(43); + match(T__0); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TypeContext extends ParserRuleContext { + public TerminalNode INT() { return getToken(DecafParser.INT, 0); } + public TerminalNode BOOL() { return getToken(DecafParser.BOOL, 0); } + public TerminalNode VOID() { return getToken(DecafParser.VOID, 0); } + public TypeContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_type; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterType(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitType(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitType(this); + else return visitor.visitChildren(this); + } + } + + public final TypeContext type() throws RecognitionException { + TypeContext _localctx = new TypeContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_type); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(45); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 7340032L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FuncContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public IdContext id() { + return getRuleContext(IdContext.class,0); + } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public ParamsContext params() { + return getRuleContext(ParamsContext.class,0); + } + public FuncContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_func; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterFunc(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitFunc(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitFunc(this); + else return visitor.visitChildren(this); + } + } + + public final FuncContext func() throws RecognitionException { + FuncContext _localctx = new FuncContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_func); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(47); + match(T__1); + setState(48); + type(); + setState(49); + id(); + setState(50); + match(T__2); + setState(52); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 7340032L) != 0)) { + { + setState(51); + params(); + } + } + + setState(54); + match(T__3); + setState(55); + block(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ParamsContext extends ParserRuleContext { + public List param() { + return getRuleContexts(ParamContext.class); + } + public ParamContext param(int i) { + return getRuleContext(ParamContext.class,i); + } + public ParamsContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_params; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterParams(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitParams(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitParams(this); + else return visitor.visitChildren(this); + } + } + + public final ParamsContext params() throws RecognitionException { + ParamsContext _localctx = new ParamsContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_params); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(57); + param(); + setState(62); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(58); + match(T__4); + setState(59); + param(); + } + } + setState(64); + _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; + } + + @SuppressWarnings("CheckReturnValue") + public static class ParamContext extends ParserRuleContext { + public TypeContext type() { + return getRuleContext(TypeContext.class,0); + } + public IdContext id() { + return getRuleContext(IdContext.class,0); + } + public ParamContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_param; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterParam(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitParam(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitParam(this); + else return visitor.visitChildren(this); + } + } + + public final ParamContext param() throws RecognitionException { + ParamContext _localctx = new ParamContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_param); + try { + enterOuterAlt(_localctx, 1); + { + setState(65); + type(); + setState(66); + id(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BlockContext extends ParserRuleContext { + public List var() { + return getRuleContexts(VarContext.class); + } + public VarContext var(int i) { + return getRuleContext(VarContext.class,i); + } + public List stmt() { + return getRuleContexts(StmtContext.class); + } + public StmtContext stmt(int i) { + return getRuleContext(StmtContext.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 DecafListener ) ((DecafListener)listener).enterBlock(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBlock(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBlock(this); + else return visitor.visitChildren(this); + } + } + + public final BlockContext block() throws RecognitionException { + BlockContext _localctx = new BlockContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_block); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(68); + match(T__5); + setState(72); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 7340032L) != 0)) { + { + { + setState(69); + var(); + } + } + setState(74); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(78); + _errHandler.sync(this); + _la = _input.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 8419840L) != 0)) { + { + { + setState(75); + stmt(); + } + } + setState(80); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(81); + match(T__6); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class StmtContext extends ParserRuleContext { + public StmtContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_stmt; } + + public StmtContext() { } + public void copyFrom(StmtContext ctx) { + super.copyFrom(ctx); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ReturnVoidContext extends StmtContext { + public ReturnVoidContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterReturnVoid(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitReturnVoid(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitReturnVoid(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ReturnContext extends StmtContext { + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public ReturnContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterReturn(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitReturn(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitReturn(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class BreakContext extends StmtContext { + public BreakContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterBreak(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBreak(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBreak(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class AssignContext extends StmtContext { + public LocContext loc() { + return getRuleContext(LocContext.class,0); + } + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public AssignContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterAssign(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitAssign(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitAssign(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class FunctionCallContext extends StmtContext { + public FuncCallContext funcCall() { + return getRuleContext(FuncCallContext.class,0); + } + public FunctionCallContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterFunctionCall(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitFunctionCall(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitFunctionCall(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class WhileContext extends StmtContext { + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public BlockContext block() { + return getRuleContext(BlockContext.class,0); + } + public WhileContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterWhile(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitWhile(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitWhile(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ContinueContext extends StmtContext { + public ContinueContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterContinue(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitContinue(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitContinue(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class IfContext extends StmtContext { + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public List block() { + return getRuleContexts(BlockContext.class); + } + public BlockContext block(int i) { + return getRuleContext(BlockContext.class,i); + } + public IfContext(StmtContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterIf(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitIf(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitIf(this); + else return visitor.visitChildren(this); + } + } + + public final StmtContext stmt() throws RecognitionException { + StmtContext _localctx = new StmtContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_stmt); + int _la; + try { + setState(116); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,7,_ctx) ) { + case 1: + _localctx = new AssignContext(_localctx); + enterOuterAlt(_localctx, 1); + { + setState(83); + loc(); + setState(84); + match(T__7); + setState(85); + expr(0); + setState(86); + match(T__0); + } + break; + case 2: + _localctx = new FunctionCallContext(_localctx); + enterOuterAlt(_localctx, 2); + { + setState(88); + funcCall(); + setState(89); + match(T__0); + } + break; + case 3: + _localctx = new IfContext(_localctx); + enterOuterAlt(_localctx, 3); + { + setState(91); + match(T__8); + setState(92); + match(T__2); + setState(93); + expr(0); + setState(94); + match(T__3); + setState(95); + block(); + setState(98); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__9) { + { + setState(96); + match(T__9); + setState(97); + block(); + } + } + + } + break; + case 4: + _localctx = new WhileContext(_localctx); + enterOuterAlt(_localctx, 4); + { + setState(100); + match(T__10); + setState(101); + match(T__2); + setState(102); + expr(0); + setState(103); + match(T__3); + setState(104); + block(); + } + break; + case 5: + _localctx = new ReturnContext(_localctx); + enterOuterAlt(_localctx, 5); + { + setState(106); + match(T__11); + setState(107); + expr(0); + setState(108); + match(T__0); + } + break; + case 6: + _localctx = new ReturnVoidContext(_localctx); + enterOuterAlt(_localctx, 6); + { + setState(110); + match(T__11); + setState(111); + match(T__0); + } + break; + case 7: + _localctx = new BreakContext(_localctx); + enterOuterAlt(_localctx, 7); + { + setState(112); + match(T__12); + setState(113); + match(T__0); + } + break; + case 8: + _localctx = new ContinueContext(_localctx); + enterOuterAlt(_localctx, 8); + { + setState(114); + match(T__13); + setState(115); + match(T__0); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + 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); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ExpressionContext extends ExprContext { + public ExprContext expr() { + return getRuleContext(ExprContext.class,0); + } + public ExpressionContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class FunCallExpressionContext extends ExprContext { + public FuncCallContext funcCall() { + return getRuleContext(FuncCallContext.class,0); + } + public FunCallExpressionContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterFunCallExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitFunCallExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitFunCallExpression(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class ConstantContext extends ExprContext { + public LiteralContext literal() { + return getRuleContext(LiteralContext.class,0); + } + public ConstantContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterConstant(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitConstant(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitConstant(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class BinaryOperationContext extends ExprContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public BinaryOpContext binaryOp() { + return getRuleContext(BinaryOpContext.class,0); + } + public BinaryOperationContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterBinaryOperation(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBinaryOperation(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBinaryOperation(this); + else return visitor.visitChildren(this); + } + } + @SuppressWarnings("CheckReturnValue") + public static class LocationContext extends ExprContext { + public LocContext loc() { + return getRuleContext(LocContext.class,0); + } + public LocationContext(ExprContext ctx) { copyFrom(ctx); } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterLocation(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitLocation(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitLocation(this); + else return visitor.visitChildren(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 = 16; + enterRecursionRule(_localctx, 16, RULE_expr, _p); + try { + int _alt; + enterOuterAlt(_localctx, 1); + { + setState(126); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,8,_ctx) ) { + case 1: + { + _localctx = new ConstantContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + + setState(119); + literal(); + } + break; + case 2: + { + _localctx = new ExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(120); + match(T__2); + setState(121); + expr(0); + setState(122); + match(T__3); + } + break; + case 3: + { + _localctx = new FunCallExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(124); + funcCall(); + } + break; + case 4: + { + _localctx = new LocationContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(125); + loc(); + } + break; + } + _ctx.stop = _input.LT(-1); + setState(134); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,9,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + { + _localctx = new BinaryOperationContext(new ExprContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expr); + setState(128); + if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); + setState(129); + binaryOp(); + setState(130); + expr(6); + } + } + } + setState(136); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,9,_ctx); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + unrollRecursionContexts(_parentctx); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BinaryOpContext extends ParserRuleContext { + public TerminalNode ADD() { return getToken(DecafParser.ADD, 0); } + public TerminalNode SUB() { return getToken(DecafParser.SUB, 0); } + public TerminalNode MUL() { return getToken(DecafParser.MUL, 0); } + public BinaryOpContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_binaryOp; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterBinaryOp(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBinaryOp(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBinaryOp(this); + else return visitor.visitChildren(this); + } + } + + public final BinaryOpContext binaryOp() throws RecognitionException { + BinaryOpContext _localctx = new BinaryOpContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_binaryOp); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(137); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 917504L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class LocContext extends ParserRuleContext { + public IdContext id() { + return getRuleContext(IdContext.class,0); + } + public LocContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_loc; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterLoc(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitLoc(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitLoc(this); + else return visitor.visitChildren(this); + } + } + + public final LocContext loc() throws RecognitionException { + LocContext _localctx = new LocContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_loc); + try { + enterOuterAlt(_localctx, 1); + { + setState(139); + id(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FuncCallContext extends ParserRuleContext { + public IdContext id() { + return getRuleContext(IdContext.class,0); + } + public ArgsContext args() { + return getRuleContext(ArgsContext.class,0); + } + public FuncCallContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_funcCall; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterFuncCall(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitFuncCall(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitFuncCall(this); + else return visitor.visitChildren(this); + } + } + + public final FuncCallContext funcCall() throws RecognitionException { + FuncCallContext _localctx = new FuncCallContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_funcCall); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(141); + id(); + setState(142); + match(T__2); + setState(144); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 25264136L) != 0)) { + { + setState(143); + args(); + } + } + + setState(146); + match(T__3); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ArgsContext extends ParserRuleContext { + public List expr() { + return getRuleContexts(ExprContext.class); + } + public ExprContext expr(int i) { + return getRuleContext(ExprContext.class,i); + } + public ArgsContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_args; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterArgs(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitArgs(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitArgs(this); + else return visitor.visitChildren(this); + } + } + + public final ArgsContext args() throws RecognitionException { + ArgsContext _localctx = new ArgsContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_args); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(148); + expr(0); + setState(153); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(149); + match(T__4); + setState(150); + expr(0); + } + } + setState(155); + _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; + } + + @SuppressWarnings("CheckReturnValue") + public static class LiteralContext extends ParserRuleContext { + public NumberContext number() { + return getRuleContext(NumberContext.class,0); + } + public BooleanContext boolean_() { + return getRuleContext(BooleanContext.class,0); + } + public LiteralContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_literal; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterLiteral(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitLiteral(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitLiteral(this); + else return visitor.visitChildren(this); + } + } + + public final LiteralContext literal() throws RecognitionException { + LiteralContext _localctx = new LiteralContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_literal); + try { + setState(158); + _errHandler.sync(this); + switch (_input.LA(1)) { + case Number: + enterOuterAlt(_localctx, 1); + { + setState(156); + number(); + } + break; + case T__14: + case T__15: + enterOuterAlt(_localctx, 2); + { + setState(157); + boolean_(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class BooleanContext extends ParserRuleContext { + public BooleanContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_boolean; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterBoolean(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitBoolean(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitBoolean(this); + else return visitor.visitChildren(this); + } + } + + public final BooleanContext boolean_() throws RecognitionException { + BooleanContext _localctx = new BooleanContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_boolean); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(160); + _la = _input.LA(1); + if ( !(_la==T__14 || _la==T__15) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class NumberContext extends ParserRuleContext { + public TerminalNode Number() { return getToken(DecafParser.Number, 0); } + public NumberContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_number; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterNumber(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitNumber(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitNumber(this); + else return visitor.visitChildren(this); + } + } + + public final NumberContext number() throws RecognitionException { + NumberContext _localctx = new NumberContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_number); + try { + enterOuterAlt(_localctx, 1); + { + setState(162); + match(Number); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class IdContext extends ParserRuleContext { + public TerminalNode IDENTIFIER() { return getToken(DecafParser.IDENTIFIER, 0); } + public IdContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_id; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).enterId(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof DecafListener ) ((DecafListener)listener).exitId(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof DecafVisitor ) return ((DecafVisitor)visitor).visitId(this); + else return visitor.visitChildren(this); + } + } + + public final IdContext id() throws RecognitionException { + IdContext _localctx = new IdContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_id); + try { + enterOuterAlt(_localctx, 1); + { + setState(164); + match(IDENTIFIER); + } + } + 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 8: + return expr_sempred((ExprContext)_localctx, predIndex); + } + return true; + } + private boolean expr_sempred(ExprContext _localctx, int predIndex) { + switch (predIndex) { + case 0: + return precpred(_ctx, 5); + } + return true; + } + + public static final String _serializedATN = + "\u0004\u0001\u0019\u00a7\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001"+ + "\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004"+ + "\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007"+ + "\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b"+ + "\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002\u000f\u0007"+ + "\u000f\u0002\u0010\u0007\u0010\u0001\u0000\u0001\u0000\u0005\u0000%\b"+ + "\u0000\n\u0000\f\u0000(\t\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0001"+ + "\u0003\u0001\u0003\u0003\u00035\b\u0003\u0001\u0003\u0001\u0003\u0001"+ + "\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0005\u0004=\b\u0004\n\u0004"+ + "\f\u0004@\t\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001"+ + "\u0006\u0005\u0006G\b\u0006\n\u0006\f\u0006J\t\u0006\u0001\u0006\u0005"+ + "\u0006M\b\u0006\n\u0006\f\u0006P\t\u0006\u0001\u0006\u0001\u0006\u0001"+ + "\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001"+ + "\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001"+ + "\u0007\u0001\u0007\u0001\u0007\u0003\u0007c\b\u0007\u0001\u0007\u0001"+ + "\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001"+ + "\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001"+ + "\u0007\u0001\u0007\u0001\u0007\u0003\u0007u\b\u0007\u0001\b\u0001\b\u0001"+ + "\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0003\b\u007f\b\b\u0001\b\u0001"+ + "\b\u0001\b\u0001\b\u0005\b\u0085\b\b\n\b\f\b\u0088\t\b\u0001\t\u0001\t"+ + "\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001\u000b\u0003\u000b\u0091"+ + "\b\u000b\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001\f\u0005\f\u0098"+ + "\b\f\n\f\f\f\u009b\t\f\u0001\r\u0001\r\u0003\r\u009f\b\r\u0001\u000e\u0001"+ + "\u000e\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0000"+ + "\u0001\u0010\u0011\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014"+ + "\u0016\u0018\u001a\u001c\u001e \u0000\u0003\u0001\u0000\u0014\u0016\u0001"+ + "\u0000\u0011\u0013\u0001\u0000\u000f\u0010\u00aa\u0000&\u0001\u0000\u0000"+ + "\u0000\u0002)\u0001\u0000\u0000\u0000\u0004-\u0001\u0000\u0000\u0000\u0006"+ + "/\u0001\u0000\u0000\u0000\b9\u0001\u0000\u0000\u0000\nA\u0001\u0000\u0000"+ + "\u0000\fD\u0001\u0000\u0000\u0000\u000et\u0001\u0000\u0000\u0000\u0010"+ + "~\u0001\u0000\u0000\u0000\u0012\u0089\u0001\u0000\u0000\u0000\u0014\u008b"+ + "\u0001\u0000\u0000\u0000\u0016\u008d\u0001\u0000\u0000\u0000\u0018\u0094"+ + "\u0001\u0000\u0000\u0000\u001a\u009e\u0001\u0000\u0000\u0000\u001c\u00a0"+ + "\u0001\u0000\u0000\u0000\u001e\u00a2\u0001\u0000\u0000\u0000 \u00a4\u0001"+ + "\u0000\u0000\u0000\"%\u0003\u0002\u0001\u0000#%\u0003\u0006\u0003\u0000"+ + "$\"\u0001\u0000\u0000\u0000$#\u0001\u0000\u0000\u0000%(\u0001\u0000\u0000"+ + "\u0000&$\u0001\u0000\u0000\u0000&\'\u0001\u0000\u0000\u0000\'\u0001\u0001"+ + "\u0000\u0000\u0000(&\u0001\u0000\u0000\u0000)*\u0003\u0004\u0002\u0000"+ + "*+\u0003 \u0010\u0000+,\u0005\u0001\u0000\u0000,\u0003\u0001\u0000\u0000"+ + "\u0000-.\u0007\u0000\u0000\u0000.\u0005\u0001\u0000\u0000\u0000/0\u0005"+ + "\u0002\u0000\u000001\u0003\u0004\u0002\u000012\u0003 \u0010\u000024\u0005"+ + "\u0003\u0000\u000035\u0003\b\u0004\u000043\u0001\u0000\u0000\u000045\u0001"+ + "\u0000\u0000\u000056\u0001\u0000\u0000\u000067\u0005\u0004\u0000\u0000"+ + "78\u0003\f\u0006\u00008\u0007\u0001\u0000\u0000\u00009>\u0003\n\u0005"+ + "\u0000:;\u0005\u0005\u0000\u0000;=\u0003\n\u0005\u0000<:\u0001\u0000\u0000"+ + "\u0000=@\u0001\u0000\u0000\u0000><\u0001\u0000\u0000\u0000>?\u0001\u0000"+ + "\u0000\u0000?\t\u0001\u0000\u0000\u0000@>\u0001\u0000\u0000\u0000AB\u0003"+ + "\u0004\u0002\u0000BC\u0003 \u0010\u0000C\u000b\u0001\u0000\u0000\u0000"+ + "DH\u0005\u0006\u0000\u0000EG\u0003\u0002\u0001\u0000FE\u0001\u0000\u0000"+ + "\u0000GJ\u0001\u0000\u0000\u0000HF\u0001\u0000\u0000\u0000HI\u0001\u0000"+ + "\u0000\u0000IN\u0001\u0000\u0000\u0000JH\u0001\u0000\u0000\u0000KM\u0003"+ + "\u000e\u0007\u0000LK\u0001\u0000\u0000\u0000MP\u0001\u0000\u0000\u0000"+ + "NL\u0001\u0000\u0000\u0000NO\u0001\u0000\u0000\u0000OQ\u0001\u0000\u0000"+ + "\u0000PN\u0001\u0000\u0000\u0000QR\u0005\u0007\u0000\u0000R\r\u0001\u0000"+ + "\u0000\u0000ST\u0003\u0014\n\u0000TU\u0005\b\u0000\u0000UV\u0003\u0010"+ + "\b\u0000VW\u0005\u0001\u0000\u0000Wu\u0001\u0000\u0000\u0000XY\u0003\u0016"+ + "\u000b\u0000YZ\u0005\u0001\u0000\u0000Zu\u0001\u0000\u0000\u0000[\\\u0005"+ + "\t\u0000\u0000\\]\u0005\u0003\u0000\u0000]^\u0003\u0010\b\u0000^_\u0005"+ + "\u0004\u0000\u0000_b\u0003\f\u0006\u0000`a\u0005\n\u0000\u0000ac\u0003"+ + "\f\u0006\u0000b`\u0001\u0000\u0000\u0000bc\u0001\u0000\u0000\u0000cu\u0001"+ + "\u0000\u0000\u0000de\u0005\u000b\u0000\u0000ef\u0005\u0003\u0000\u0000"+ + "fg\u0003\u0010\b\u0000gh\u0005\u0004\u0000\u0000hi\u0003\f\u0006\u0000"+ + "iu\u0001\u0000\u0000\u0000jk\u0005\f\u0000\u0000kl\u0003\u0010\b\u0000"+ + "lm\u0005\u0001\u0000\u0000mu\u0001\u0000\u0000\u0000no\u0005\f\u0000\u0000"+ + "ou\u0005\u0001\u0000\u0000pq\u0005\r\u0000\u0000qu\u0005\u0001\u0000\u0000"+ + "rs\u0005\u000e\u0000\u0000su\u0005\u0001\u0000\u0000tS\u0001\u0000\u0000"+ + "\u0000tX\u0001\u0000\u0000\u0000t[\u0001\u0000\u0000\u0000td\u0001\u0000"+ + "\u0000\u0000tj\u0001\u0000\u0000\u0000tn\u0001\u0000\u0000\u0000tp\u0001"+ + "\u0000\u0000\u0000tr\u0001\u0000\u0000\u0000u\u000f\u0001\u0000\u0000"+ + "\u0000vw\u0006\b\uffff\uffff\u0000w\u007f\u0003\u001a\r\u0000xy\u0005"+ + "\u0003\u0000\u0000yz\u0003\u0010\b\u0000z{\u0005\u0004\u0000\u0000{\u007f"+ + "\u0001\u0000\u0000\u0000|\u007f\u0003\u0016\u000b\u0000}\u007f\u0003\u0014"+ + "\n\u0000~v\u0001\u0000\u0000\u0000~x\u0001\u0000\u0000\u0000~|\u0001\u0000"+ + "\u0000\u0000~}\u0001\u0000\u0000\u0000\u007f\u0086\u0001\u0000\u0000\u0000"+ + "\u0080\u0081\n\u0005\u0000\u0000\u0081\u0082\u0003\u0012\t\u0000\u0082"+ + "\u0083\u0003\u0010\b\u0006\u0083\u0085\u0001\u0000\u0000\u0000\u0084\u0080"+ + "\u0001\u0000\u0000\u0000\u0085\u0088\u0001\u0000\u0000\u0000\u0086\u0084"+ + "\u0001\u0000\u0000\u0000\u0086\u0087\u0001\u0000\u0000\u0000\u0087\u0011"+ + "\u0001\u0000\u0000\u0000\u0088\u0086\u0001\u0000\u0000\u0000\u0089\u008a"+ + "\u0007\u0001\u0000\u0000\u008a\u0013\u0001\u0000\u0000\u0000\u008b\u008c"+ + "\u0003 \u0010\u0000\u008c\u0015\u0001\u0000\u0000\u0000\u008d\u008e\u0003"+ + " \u0010\u0000\u008e\u0090\u0005\u0003\u0000\u0000\u008f\u0091\u0003\u0018"+ + "\f\u0000\u0090\u008f\u0001\u0000\u0000\u0000\u0090\u0091\u0001\u0000\u0000"+ + "\u0000\u0091\u0092\u0001\u0000\u0000\u0000\u0092\u0093\u0005\u0004\u0000"+ + "\u0000\u0093\u0017\u0001\u0000\u0000\u0000\u0094\u0099\u0003\u0010\b\u0000"+ + "\u0095\u0096\u0005\u0005\u0000\u0000\u0096\u0098\u0003\u0010\b\u0000\u0097"+ + "\u0095\u0001\u0000\u0000\u0000\u0098\u009b\u0001\u0000\u0000\u0000\u0099"+ + "\u0097\u0001\u0000\u0000\u0000\u0099\u009a\u0001\u0000\u0000\u0000\u009a"+ + "\u0019\u0001\u0000\u0000\u0000\u009b\u0099\u0001\u0000\u0000\u0000\u009c"+ + "\u009f\u0003\u001e\u000f\u0000\u009d\u009f\u0003\u001c\u000e\u0000\u009e"+ + "\u009c\u0001\u0000\u0000\u0000\u009e\u009d\u0001\u0000\u0000\u0000\u009f"+ + "\u001b\u0001\u0000\u0000\u0000\u00a0\u00a1\u0007\u0002\u0000\u0000\u00a1"+ + "\u001d\u0001\u0000\u0000\u0000\u00a2\u00a3\u0005\u0018\u0000\u0000\u00a3"+ + "\u001f\u0001\u0000\u0000\u0000\u00a4\u00a5\u0005\u0017\u0000\u0000\u00a5"+ + "!\u0001\u0000\u0000\u0000\r$&4>HNbt~\u0086\u0090\u0099\u009e"; + 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/java/de/dhbw/horb/antlr/DecafVisitor.java b/src/main/java/de/dhbw/horb/antlr/DecafVisitor.java new file mode 100644 index 0000000..ac99833 --- /dev/null +++ b/src/main/java/de/dhbw/horb/antlr/DecafVisitor.java @@ -0,0 +1,194 @@ +// Generated from /home/simon/dev/AntlrAssignment3Template/src/main/antlr4/de/dhbw/horb/Decaf.g4 by ANTLR 4.13.1 +package de.dhbw.horb.antlr; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link DecafParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface DecafVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link DecafParser#program}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitProgram(DecafParser.ProgramContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#var}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVar(DecafParser.VarContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#type}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitType(DecafParser.TypeContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#func}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunc(DecafParser.FuncContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#params}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParams(DecafParser.ParamsContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#param}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParam(DecafParser.ParamContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#block}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBlock(DecafParser.BlockContext ctx); + /** + * Visit a parse tree produced by the {@code Assign} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitAssign(DecafParser.AssignContext ctx); + /** + * Visit a parse tree produced by the {@code FunctionCall} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionCall(DecafParser.FunctionCallContext ctx); + /** + * Visit a parse tree produced by the {@code If} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIf(DecafParser.IfContext ctx); + /** + * Visit a parse tree produced by the {@code While} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhile(DecafParser.WhileContext ctx); + /** + * Visit a parse tree produced by the {@code Return} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReturn(DecafParser.ReturnContext ctx); + /** + * Visit a parse tree produced by the {@code ReturnVoid} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitReturnVoid(DecafParser.ReturnVoidContext ctx); + /** + * Visit a parse tree produced by the {@code Break} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBreak(DecafParser.BreakContext ctx); + /** + * Visit a parse tree produced by the {@code Continue} + * labeled alternative in {@link DecafParser#stmt}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitContinue(DecafParser.ContinueContext ctx); + /** + * Visit a parse tree produced by the {@code Expression} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression(DecafParser.ExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code FunCallExpression} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunCallExpression(DecafParser.FunCallExpressionContext ctx); + /** + * Visit a parse tree produced by the {@code Constant} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitConstant(DecafParser.ConstantContext ctx); + /** + * Visit a parse tree produced by the {@code BinaryOperation} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBinaryOperation(DecafParser.BinaryOperationContext ctx); + /** + * Visit a parse tree produced by the {@code Location} + * labeled alternative in {@link DecafParser#expr}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLocation(DecafParser.LocationContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#binaryOp}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBinaryOp(DecafParser.BinaryOpContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#loc}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLoc(DecafParser.LocContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#funcCall}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFuncCall(DecafParser.FuncCallContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#args}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArgs(DecafParser.ArgsContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLiteral(DecafParser.LiteralContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#boolean}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBoolean(DecafParser.BooleanContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#number}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitNumber(DecafParser.NumberContext ctx); + /** + * Visit a parse tree produced by {@link DecafParser#id}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitId(DecafParser.IdContext ctx); +} \ No newline at end of file diff --git a/src/main/java/de/dhbw/horb/ast/Assignment.java b/src/main/java/de/dhbw/horb/ast/Assignment.java index 75ed1da..93ee339 100644 --- a/src/main/java/de/dhbw/horb/ast/Assignment.java +++ b/src/main/java/de/dhbw/horb/ast/Assignment.java @@ -1,6 +1,5 @@ package de.dhbw.horb.ast; -import java.util.List; public record Assignment(Location loc, Expression value) implements Statement { } diff --git a/src/main/java/de/dhbw/horb/ast/Binary.java b/src/main/java/de/dhbw/horb/ast/Binary.java index 7603b07..8afeea2 100644 --- a/src/main/java/de/dhbw/horb/ast/Binary.java +++ b/src/main/java/de/dhbw/horb/ast/Binary.java @@ -1,8 +1,4 @@ package de.dhbw.horb.ast; -import de.dhbw.horb.ExpressionGenerator; - -import java.util.List; - public record Binary(Expression left, Operator op, Expression right) implements Expression{ } diff --git a/src/main/java/de/dhbw/horb/ast/Block.java b/src/main/java/de/dhbw/horb/ast/Block.java index 4e0d96c..b918220 100644 --- a/src/main/java/de/dhbw/horb/ast/Block.java +++ b/src/main/java/de/dhbw/horb/ast/Block.java @@ -1,6 +1,5 @@ package de.dhbw.horb.ast; -import java.util.ArrayList; import java.util.List; public record Block(List vars, List stmts) implements Node { diff --git a/src/main/java/de/dhbw/horb/ast/BoolConstant.java b/src/main/java/de/dhbw/horb/ast/BoolConstant.java index f27b21d..d58e170 100644 --- a/src/main/java/de/dhbw/horb/ast/BoolConstant.java +++ b/src/main/java/de/dhbw/horb/ast/BoolConstant.java @@ -1,6 +1,5 @@ package de.dhbw.horb.ast; -import java.util.List; public record BoolConstant(Boolean value) implements Expression { } diff --git a/src/main/java/de/dhbw/horb/ast/Break.java b/src/main/java/de/dhbw/horb/ast/Break.java index ff06254..fff86ea 100644 --- a/src/main/java/de/dhbw/horb/ast/Break.java +++ b/src/main/java/de/dhbw/horb/ast/Break.java @@ -1,6 +1,4 @@ package de.dhbw.horb.ast; -import java.util.List; - public record Break() implements Statement { } diff --git a/src/main/java/de/dhbw/horb/ast/Continue.java b/src/main/java/de/dhbw/horb/ast/Continue.java index aa1a499..ed80a6b 100644 --- a/src/main/java/de/dhbw/horb/ast/Continue.java +++ b/src/main/java/de/dhbw/horb/ast/Continue.java @@ -1,6 +1,4 @@ package de.dhbw.horb.ast; -import java.util.List; - public record Continue() implements Statement { } diff --git a/src/main/java/de/dhbw/horb/ast/IfElse.java b/src/main/java/de/dhbw/horb/ast/IfElse.java index aba94d0..d851a92 100644 --- a/src/main/java/de/dhbw/horb/ast/IfElse.java +++ b/src/main/java/de/dhbw/horb/ast/IfElse.java @@ -1,6 +1,5 @@ package de.dhbw.horb.ast; -import java.util.List; public record IfElse(Expression cond, Block ifBlock, Block elseBlock) implements Statement { } diff --git a/src/main/java/de/dhbw/horb/ast/IntConstant.java b/src/main/java/de/dhbw/horb/ast/IntConstant.java index 887e583..e7b7594 100644 --- a/src/main/java/de/dhbw/horb/ast/IntConstant.java +++ b/src/main/java/de/dhbw/horb/ast/IntConstant.java @@ -1,6 +1,5 @@ package de.dhbw.horb.ast; -import java.util.List; public record IntConstant(Integer value) implements Expression { } diff --git a/src/main/java/de/dhbw/horb/ast/Location.java b/src/main/java/de/dhbw/horb/ast/Location.java index f96125c..dfd66e1 100644 --- a/src/main/java/de/dhbw/horb/ast/Location.java +++ b/src/main/java/de/dhbw/horb/ast/Location.java @@ -1,6 +1,4 @@ package de.dhbw.horb.ast; -import java.util.List; - public record Location(String name) implements Expression { } diff --git a/src/main/java/de/dhbw/horb/ast/Node.java b/src/main/java/de/dhbw/horb/ast/Node.java index 9d46901..5206e6e 100644 --- a/src/main/java/de/dhbw/horb/ast/Node.java +++ b/src/main/java/de/dhbw/horb/ast/Node.java @@ -1,6 +1,4 @@ package de.dhbw.horb.ast; -import java.util.List; - public interface Node { } diff --git a/src/main/java/de/dhbw/horb/ast/Return.java b/src/main/java/de/dhbw/horb/ast/Return.java index 6d24a86..367bec5 100644 --- a/src/main/java/de/dhbw/horb/ast/Return.java +++ b/src/main/java/de/dhbw/horb/ast/Return.java @@ -1,7 +1,4 @@ package de.dhbw.horb.ast; -import java.util.ArrayList; -import java.util.List; - public record Return(Expression ret) implements Statement { } diff --git a/src/main/java/de/dhbw/horb/ast/ReturnVoid.java b/src/main/java/de/dhbw/horb/ast/ReturnVoid.java index 1f7326e..371a33e 100644 --- a/src/main/java/de/dhbw/horb/ast/ReturnVoid.java +++ b/src/main/java/de/dhbw/horb/ast/ReturnVoid.java @@ -1,6 +1,4 @@ package de.dhbw.horb.ast; -import java.util.List; - public record ReturnVoid() implements Statement { } diff --git a/src/main/java/de/dhbw/horb/ast/Variable.java b/src/main/java/de/dhbw/horb/ast/Variable.java index 0785857..8dedd49 100644 --- a/src/main/java/de/dhbw/horb/ast/Variable.java +++ b/src/main/java/de/dhbw/horb/ast/Variable.java @@ -1,6 +1,4 @@ package de.dhbw.horb.ast; -import java.util.List; - public record Variable(String name, Type type) implements Node{ } diff --git a/src/main/java/de/dhbw/horb/ast/While.java b/src/main/java/de/dhbw/horb/ast/While.java index e3fa76c..9c02732 100644 --- a/src/main/java/de/dhbw/horb/ast/While.java +++ b/src/main/java/de/dhbw/horb/ast/While.java @@ -1,6 +1,4 @@ package de.dhbw.horb.ast; -import java.util.List; - public record While(Expression cond, Block block) implements Statement { } diff --git a/src/test/java/de/dhbw/horb/ExpressionGeneratorTest.java b/src/test/java/de/dhbw/horb/ExpressionGeneratorTest.java index 3c252cf..eaf7de5 100644 --- a/src/test/java/de/dhbw/horb/ExpressionGeneratorTest.java +++ b/src/test/java/de/dhbw/horb/ExpressionGeneratorTest.java @@ -1,5 +1,7 @@ package de.dhbw.horb; +import de.dhbw.horb.antlr.DecafLexer; +import de.dhbw.horb.antlr.DecafParser; import de.dhbw.horb.ast.*; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; diff --git a/src/test/java/de/dhbw/horb/StatementGeneratorTest.java b/src/test/java/de/dhbw/horb/StatementGeneratorTest.java index 4229bf1..2a659bb 100644 --- a/src/test/java/de/dhbw/horb/StatementGeneratorTest.java +++ b/src/test/java/de/dhbw/horb/StatementGeneratorTest.java @@ -1,5 +1,7 @@ package de.dhbw.horb; +import de.dhbw.horb.antlr.DecafLexer; +import de.dhbw.horb.antlr.DecafParser; import de.dhbw.horb.ast.*; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams;