From a1497660076bcd50aa17548610d057fea5c404ff Mon Sep 17 00:00:00 2001 From: ProgramSnail Date: Sun, 16 Feb 2025 17:04:11 +0300 Subject: [PATCH] init, parser generation (without attributes), attempts to build basic lang class --- .idea/encodings.xml | 7 + README.md | 9 + pom.xml | 37 + src/main/java/org/programsnail/Main.java | 17 - .../truffle_lama/LamaContext.java | 47 + .../truffle_lama/LamaFileDetector.java | 23 + .../truffle_lama/LamaLanguage.java | 226 ++ .../programsnail/truffle_lama/LamaMain.java | 55 + .../programsnail/truffle_lama/LamaTypes.java | 7 + .../builtins/LamaBuiltinNode.java | 38 + .../nodes/LamaExpressionNode.java | 67 + .../programsnail/truffle_lama/parser/Lama.g4 | 246 ++ .../truffle_lama/parser/Lama.interp | 161 + .../truffle_lama/parser/Lama.tokens | 102 + .../truffle_lama/parser/LamaBaseListener.java | 496 +++ .../truffle_lama/parser/LamaBaseVisitor.java | 281 ++ .../truffle_lama/parser/LamaLexer.interp | 188 + .../truffle_lama/parser/LamaLexer.java | 372 ++ .../truffle_lama/parser/LamaLexer.tokens | 102 + .../truffle_lama/parser/LamaListener.java | 390 ++ .../truffle_lama/parser/LamaParser.java | 3268 +++++++++++++++++ .../truffle_lama/parser/LamaVisitor.java | 241 ++ 22 files changed, 6363 insertions(+), 17 deletions(-) create mode 100644 .idea/encodings.xml create mode 100644 README.md delete mode 100644 src/main/java/org/programsnail/Main.java create mode 100644 src/main/java/org/programsnail/truffle_lama/LamaContext.java create mode 100644 src/main/java/org/programsnail/truffle_lama/LamaFileDetector.java create mode 100644 src/main/java/org/programsnail/truffle_lama/LamaLanguage.java create mode 100644 src/main/java/org/programsnail/truffle_lama/LamaMain.java create mode 100644 src/main/java/org/programsnail/truffle_lama/LamaTypes.java create mode 100644 src/main/java/org/programsnail/truffle_lama/builtins/LamaBuiltinNode.java create mode 100644 src/main/java/org/programsnail/truffle_lama/nodes/LamaExpressionNode.java create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/Lama.interp create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/Lama.tokens create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/LamaBaseListener.java create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/LamaBaseVisitor.java create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.interp create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.java create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.tokens create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/LamaListener.java create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/LamaParser.java create mode 100644 src/main/java/org/programsnail/truffle_lama/parser/LamaVisitor.java 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/README.md b/README.md new file mode 100644 index 0000000..920818d --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +### Lama + +This is an attempt to implement the LaMa language (https://github.com/PLTools/Lama) with GraalVM and Truffle. + +Code is based on: +- https://github.com/graalvm/simplelanguage +- https://github.com/cesquivias/mumbler + +--- diff --git a/pom.xml b/pom.xml index 083dff8..0b167f8 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,43 @@ 23 23 UTF-8 + 23.1.0 + 4.12.0 + + + org.graalvm.polyglot + polyglot + ${graalvm.version} + + + org.graalvm.truffle + truffle-api + ${graalvm.version} + + + org.graalvm.truffle + truffle-runtime + ${graalvm.version} + runtime + + + org.graalvm.truffle + truffle-tck + ${graalvm.version} + test + + + junit + junit + 4.13.2 + test + + + org.antlr + antlr4-runtime + ${antlr.version} + + \ No newline at end of file diff --git a/src/main/java/org/programsnail/Main.java b/src/main/java/org/programsnail/Main.java deleted file mode 100644 index b25e4c4..0000000 --- a/src/main/java/org/programsnail/Main.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.programsnail; - -//TIP To Run code, press or -// click the icon in the gutter. -public class Main { - public static void main(String[] args) { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); - - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - System.out.println("i = " + i); - } - } -} \ No newline at end of file diff --git a/src/main/java/org/programsnail/truffle_lama/LamaContext.java b/src/main/java/org/programsnail/truffle_lama/LamaContext.java new file mode 100644 index 0000000..2d0a5ff --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/LamaContext.java @@ -0,0 +1,47 @@ +package org.programsnail.truffle_lama; + +import com.oracle.truffle.api.Truffle; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.frame.MaterializedFrame; +import com.oracle.truffle.api.frame.VirtualFrame; + +import java.awt.*; + +// TODO +public class LamaContext { + private final FrameDescriptor globalFrameDescriptor; + private final Namespace globalNamespace; + private final MaterializedFrame globalFrame; + private final LamaLanguage language; + + public LamaContext() { this(null); } + + public LamaContext(LamaLanguage language) { + this.globalFrameDescriptor = new FrameDescriptor(); + this.globalNamespace = new Namespace(this.globalFrameDescriptor); + this.globalFrame = this.initGlobalFrame(language); + this.language = language; + } + + private MaterializedFrame initGlobalFrame(LamaLanguage language) { + VirtualFrame frame = Truffle.getRuntime().createVirtualFrame(null, this.globalFrameDescriptor); + addGlobalFunctions(language, frame); + return frame.materialize(); + } + + private static void addGlobalFunctions(LamaLanguage language, VirtualFrame virtualFrame) { + // TODO + } + + /** + * @return A {@link MaterializedFrame} on the heap that contains all global + * values. + */ + public MaterializedFrame getGlobalFrame() { + return this.globalFrame; + } + + public Namespace getGlobalNamespace() { + return this.globalNamespace; + } +} diff --git a/src/main/java/org/programsnail/truffle_lama/LamaFileDetector.java b/src/main/java/org/programsnail/truffle_lama/LamaFileDetector.java new file mode 100644 index 0000000..2da25db --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/LamaFileDetector.java @@ -0,0 +1,23 @@ +package org.programsnail.truffle_lama; + +import com.oracle.truffle.api.TruffleFile; + +import java.io.IOException; +import java.nio.charset.Charset; + +public class LamaFileDetector implements TruffleFile.FileTypeDetector { + + @Override + public String findMimeType(TruffleFile file) { + String name = file.getName(); + if (name != null && name.endsWith(".lama")) { + return LamaLanguage.MIME_TYPE; + } + return null; + } + + @Override + public Charset findEncoding(TruffleFile file) throws IOException { + return null; + } +} diff --git a/src/main/java/org/programsnail/truffle_lama/LamaLanguage.java b/src/main/java/org/programsnail/truffle_lama/LamaLanguage.java new file mode 100644 index 0000000..eb8aa62 --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/LamaLanguage.java @@ -0,0 +1,226 @@ +package org.programsnail.truffle_lama; + +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.debug.DebuggerTags; +import com.oracle.truffle.api.dsl.NodeFactory; +import com.oracle.truffle.api.frame.FrameDescriptor; +import com.oracle.truffle.api.instrumentation.AllocationReporter; +import com.oracle.truffle.api.instrumentation.ProvidedTags; +import com.oracle.truffle.api.instrumentation.StandardTags; +import com.oracle.truffle.api.interop.InteropLibrary; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeInfo; +import com.oracle.truffle.api.nodes.RootNode; +import com.oracle.truffle.api.object.Shape; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; +import org.programsnail.truffle_lama.parser.LamaParser; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@TruffleLanguage.Registration(id = LamaLanguage.ID, name = "Lama", defaultMimeType = LamaLanguage.MIME_TYPE, characterMimeTypes = LamaLanguage.MIME_TYPE, contextPolicy = TruffleLanguage.ContextPolicy.SHARED, fileTypeDetectors = LamaFileDetector.class) +@ProvidedTags({StandardTags.CallTag.class, StandardTags.StatementTag.class, StandardTags.RootTag.class, StandardTags.RootBodyTag.class, StandardTags.ExpressionTag.class, DebuggerTags.AlwaysHalt.class, + StandardTags.ReadVariableTag.class, StandardTags.WriteVariableTag.class}) +public class LamaLanguage extends TruffleLanguage { + public static volatile int counter; // count class instances + + public static final String ID = "lama"; + public static final String MIME_TYPE = "application/x-lama"; + + private static final Source BUILTIN_SOURCE = Source.newBuilder(ID, "", "LaMa builtin").build(); + private static final LanguageReference REFERENCE = LanguageReference.create(LamaLanguage.class); + private static final List> EXTERNAL_BUILTINS = Collections.synchronizedList(new ArrayList<>()); + + public static final TruffleString.Encoding STRING_ENCODING = TruffleString.Encoding.UTF_16; + + private final Assumption singleContext = Truffle.getRuntime().createAssumption("Single Lama context."); + + private final Map, RootCallTarget> builtinTargets = new ConcurrentHashMap<>(); + private final Map undefinedFunctions = new ConcurrentHashMap<>(); + + private final Shape rootShape; + + // + + public LamaLanguage() { + counter++; + this.rootShape = Shape.newBuilder().layout(LamaObject.class).build(); + } + + @Override + protected LamaContext createContext(Env env) { + return new LamaContext(this, env, new ArrayList<>(EXTERNAL_BUILTINS)); + } + + @Override + protected boolean patchContext(LamaContext context, Env newEnv) { + context.patchContext(newEnv); + return true; + } + + // + + public RootCallTarget getOrCreateUndefinedFunction(TruffleString name) { + RootCallTarget target = undefinedFunctions.get(name); + if (target == null) { + target = new LamaUndefinedFunctionRootNode(this, name).getCallTarget(); + RootCallTarget other = undefinedFunctions.putIfAbsent(name, target); + if (other != null) { + target = other; + } + } + return target; + } + + public RootCallTarget lookupBuiltin(NodeFactory factory) { + RootCallTarget target = builtinTargets.get(factory); + if (target != null) { + return target; + } + + /* + * The builtin node factory is a class that is automatically generated by the Truffle DSL. + * The signature returned by the factory reflects the signature of the @Specialization + * + * methods in the builtin classes. + */ + int argumentCount = factory.getExecutionSignature().size(); + LamaExpressionNode[] argumentNodes = new LamaExpressionNode[argumentCount]; + /* + * Builtin functions are like normal functions, i.e., the arguments are passed in as an + * Object[] array encapsulated in SLArguments. A SLReadArgumentNode extracts a parameter + * from this array. + */ + for (int i = 0; i < argumentCount; i++) { + argumentNodes[i] = new LamaReadArgumentNode(i); + } + /* Instantiate the builtin node. This node performs the actual functionality. */ + LamaBuiltinNode builtinBodyNode = factory.createNode((Object) argumentNodes); + builtinBodyNode.addRootTag(); + /* The name of the builtin function is specified via an annotation on the node class. */ + TruffleString name = LamaStrings.fromJavaString(lookupNodeInfo(builtinBodyNode.getClass()).shortName()); + builtinBodyNode.setUnavailableSourceSection(); + + /* Wrap the builtin in a RootNode. Truffle requires all AST to start with a RootNode. */ + LamamRootNode rootNode = new LammaRootNode(this, new FrameDescriptor(), builtinBodyNode, BUILTIN_SOURCE.createUnavailableSection(), name); + + /* + * Register the builtin function in the builtin registry. Call targets for builtins may be + * reused across multiple contexts. + */ + RootCallTarget newTarget = rootNode.getCallTarget(); + RootCallTarget oldTarget = builtinTargets.putIfAbsent(factory, newTarget); + if (oldTarget != null) { + return oldTarget; + } + return newTarget; + } + + public static NodeInfo lookupNodeInfo(Class c) { + if (c == null) { + return null; + } + NodeInfo info = c.getAnnotation(NodeInfo.class); + if (info != null) { + return info; + } else { + return lookupNodeInfo(c.getSuperclass()); + } + } + + @Override + protected CallTarget parse(ParsingRequest request) throws Exception { + Source source = request.getSource(); + Map functions; + /* + * Parse the provided source. At this point, we do not have a SLContext yet. Registration of + * the functions with the SLContext happens lazily in SLEvalRootNode. + */ + if (request.getArgumentNames().isEmpty()) { + functions = LamaParser.parseLama(this, source); + } else { + StringBuilder sb = new StringBuilder(); + sb.append("function main("); + String sep = ""; + for (String argumentName : request.getArgumentNames()) { + sb.append(sep); + sb.append(argumentName); + sep = ","; + } + sb.append(") { return "); + sb.append(source.getCharacters()); + sb.append(";}"); + String language = source.getLanguage() == null ? ID : source.getLanguage(); + Source decoratedSource = Source.newBuilder(language, sb.toString(), source.getName()).build(); + functions = LamaParser.parseLama(this, decoratedSource); + } + + // TODO: execute source itself, not main function + + return ; + } + + @Override + protected void initializeMultipleContexts() { + singleContext.invalidate(); + } + + public boolean isSingleContext() { + return singleContext.isValid(); + } + + @Override + protected Object getLanguageView(LamaContext context, Object value) { + return LamaLanguageView.create(value); + } + + @Override + protected boolean isVisible(LamaContext context, Object value) { + return !InteropLibrary.getFactory().getUncached(value).isNull(value); + } + + @Override + protected Object getScope(LamaContext context) { + return context.getFunctionRegistry().getFunctionsObject(); + } + + public Shape getRootShape() { + return rootShape; + } + + /** + * Allocate an empty object. All new objects initially have no properties. Properties are added + * when they are first stored, i.e., the store triggers a shape change of the object. + */ + public LamaObject createObject(AllocationReporter reporter) { + reporter.onEnter(null, 0, AllocationReporter.SIZE_UNKNOWN); + LamaObject object = new LamaObject(rootShape); + reporter.onReturnValue(object, 0, AllocationReporter.SIZE_UNKNOWN); + return object; + } + + // + + public static LamaLanguage get(Node node) { + return REFERENCE.get(node); + } + + // + + public static void installBuiltin(NodeFactory builtin) { + EXTERNAL_BUILTINS.add(builtin); + } + + @Override + protected void exitContext(LamaContext context, ExitMode exitMode, int exitCode) { + /* + * Runs shutdown hooks during explicit exit triggered by TruffleContext#closeExit(Node, int) + * or natural exit triggered during natural context close. + */ + context.runShutdownHooks(); + } +} diff --git a/src/main/java/org/programsnail/truffle_lama/LamaMain.java b/src/main/java/org/programsnail/truffle_lama/LamaMain.java new file mode 100644 index 0000000..102a268 --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/LamaMain.java @@ -0,0 +1,55 @@ +package org.programsnail.truffle_lama; + +import java.io.*; + +import org.graalvm.polyglot.Context; +import org.graalvm.polyglot.PolyglotException; +import org.graalvm.polyglot.Source; +import org.graalvm.polyglot.Value; + +import static org.programsnail.truffle_lama.LamaLanguage.ID; + +public class LamaMain { + public static void main(String[] args) throws IOException { + assert args.length != 1 : "Exactly one file should be provided as argument"; + + String filename = args[0]; + + Source source = Source.newBuilder(ID, new File(filename)).build(); + + System.exit(run(source, System.in, System.out, true)); + } + + private static int run(Source source, InputStream in, PrintStream out, boolean printOutput) throws IOException { + Context context; + PrintStream error = System.err; + + try { + context = Context.newBuilder(ID).in(in).out(out).allowAllAccess(true).build(); // TODO: options (?) + } catch (IllegalArgumentException e) { + error.println(e.getMessage()); + return 1; + } + + if (printOutput) { + out.println("== running on " + context.getEngine()); + } + + try { + Value result = context.eval(source); + if (printOutput) { + out.println(result.toString()); + } + return 0; + } catch(PolyglotException e) { + if (e.isInternalError()) { + e.printStackTrace(error); + } else { + error.println(e.getMessage()); + } + return 1; + } finally { + context.close(); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/programsnail/truffle_lama/LamaTypes.java b/src/main/java/org/programsnail/truffle_lama/LamaTypes.java new file mode 100644 index 0000000..b01afab --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/LamaTypes.java @@ -0,0 +1,7 @@ +package org.programsnail.truffle_lama; + +import com.oracle.truffle.api.dsl.ImplicitCast; +import com.oracle.truffle.api.dsl.TypeSystem; + +@TypeSystem({long.class, boolean.class, String.class}) +public class LamaTypes {} diff --git a/src/main/java/org/programsnail/truffle_lama/builtins/LamaBuiltinNode.java b/src/main/java/org/programsnail/truffle_lama/builtins/LamaBuiltinNode.java new file mode 100644 index 0000000..d508dca --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/builtins/LamaBuiltinNode.java @@ -0,0 +1,38 @@ +package org.programsnail.truffle_lama.builtins; + +import com.oracle.truffle.api.dsl.GenerateNodeFactory; +import com.oracle.truffle.api.dsl.NodeChild; +import com.oracle.truffle.api.dsl.UnsupportedSpecializationException; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.nodes.UnexpectedResultException; + +@NodeChild(value = "arguments", type = LamaExpressionNode[].class) +@GenerateNodeFactory +public abstract class LamaBuiltinNode extends LamaExpressionNode { + + @Override + public final Object executeGeneric(VirtualFrame frame) { + try { + return execute(frame); + } catch (UnsupportedSpecializationException e) { + throw LamaException.typeError(e.getNode(), e.getSuppliedValues()); + } + } + + @Override + public final boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException { + return super.executeBoolean(frame); + } + + @Override + public final long executeLong(VirtualFrame frame) throws UnexpectedResultException { + return super.executeLong(frame); + } + + @Override + public final void executeVoid(VirtualFrame frame) { + super.executeVoid(frame); + } + + protected abstract Object execute(VirtualFrame frame); +} diff --git a/src/main/java/org/programsnail/truffle_lama/nodes/LamaExpressionNode.java b/src/main/java/org/programsnail/truffle_lama/nodes/LamaExpressionNode.java new file mode 100644 index 0000000..fb3af8e --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/nodes/LamaExpressionNode.java @@ -0,0 +1,67 @@ +package org.programsnail.truffle_lama.nodes; + +import com.oracle.truffle.api.dsl.TypeSystemReference; +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.*; +import com.oracle.truffle.api.nodes.NodeInfo; +import com.oracle.truffle.api.nodes.UnexpectedResultException; + +@TypeSystemReference(SLTypes.class) +@NodeInfo(description = "The abstract base node for all expressions") +@GenerateWrapper +public abstract class LamaExpressionNode extends LamaStatementNode { + + private boolean hasExpressionTag; + + /** + * The execute method when no specialization is possible. This is the most general case, + * therefore it must be provided by all subclasses. + */ + public abstract Object executeGeneric(VirtualFrame frame); + + /** + * When we use an expression at places where a {@link LamaStatementNode statement} is already + * sufficient, the return value is just discarded. + */ + @Override + public void executeVoid(VirtualFrame frame) { + executeGeneric(frame); + } + + // LamaExpressionNodeWrapper is generated (?) + @Override + public InstrumentableNode.WrapperNode createWrapper(ProbeNode probe) { + return new LamaExpressionNodeWrapper(this, probe); + } + + @Override + public boolean hasTag(Class tag) { + if (tag == StandardTags.ExpressionTag.class) { + return hasExpressionTag; + } + return super.hasTag(tag); + } + + /** + * Marks this node as being a {@link StandardTags.ExpressionTag} for instrumentation purposes. + */ + public final void addExpressionTag() { + hasExpressionTag = true; + } + + /* + * Execute methods for specialized types. They all follow the same pattern: they call the + * generic execution method and then expect a result of their return type. Type-specialized + * subclasses overwrite the appropriate methods. + */ + + // LamaTypesGen is generated from LamaTypes + + public long executeLong(VirtualFrame frame) throws UnexpectedResultException { + return LamaTypesGen.expectLong(executeGeneric(frame)); + } + + public boolean executeBoolean(VirtualFrame frame) throws UnexpectedResultException { + return LamaTypesGen.expectBoolean(executeGeneric(frame)); + } +} diff --git a/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 b/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 new file mode 100644 index 0000000..3b912d2 --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * The Universal Permissive License (UPL), Version 1.0 + * + * Subject to the condition set forth below, permission is hereby granted to any + * person obtaining a copy of this software, associated documentation and/or + * data (collectively the "Software"), free of charge and under any and all + * copyright rights in the Software, and any and all patent rights owned or + * freely licensable by each licensor hereunder covering either (i) the + * unmodified Software as contributed to or provided by such licensor, or (ii) + * the Larger Works (as defined below), to deal in both + * + * (a) the Software, and + * + * (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if + * one is included with the Software each a "Larger Work" to which the Software + * is contributed by such licensors), + * + * without restriction, including without limitation the rights to copy, create + * derivative works of, display, perform, and distribute the Software and make, + * use, sell, offer for sale, import, export, have made, and have sold the + * Software and the Larger Work(s), and to sublicense the foregoing rights on + * either these or other terms. + * + * This license is subject to the following condition: + * + * The above copyright notice and either this complete permission notice or at a + * minimum a reference to the UPL must be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * The parser and lexer need to be generated using "mx create-sl-parser". + */ + +grammar Lama; + +@parser::header +{ +// DO NOT MODIFY - generated from Lama.g4 + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; +import org.programsnail.truffle_lama.LamaLanguage; +import org.programsnail.truffle_lama.nodes.LamaExpressionNode; +import org.programsnail.truffle_lama.nodes.LamaStatementNode; +} + +@lexer::header +{ +// DO NOT MODIFY - generated from Lama.g4 +} + +@parser::members +{ +private LamaNodeFactory factory; +private Source source; + +private static final class BailoutErrorListener extends BaseErrorListener { + private final Source source; + BailoutErrorListener(Source source) { + this.source = source; + } + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { + throwParseError(source, line, charPositionInLine, (Token) offendingSymbol, msg); + } +} + +public void SemErr(Token token, String message) { + assert token != null; + throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message); +} + +private static void throwParseError(Source source, int line, int charPositionInLine, Token token, String message) { + int col = charPositionInLine + 1; + String location = "-- line " + line + " col " + col + ": "; + int length = token == null ? 1 : Math.max(token.getStopIndex() - token.getStartIndex(), 0); + throw new SLParseError(source, line, col, length, String.format("Error(s) parsing script:%n" + location + message)); +} + +public static Map parseLama(LamaLanguage language, Source source) { + LamaLexer lexer = new LamamLexer(CharStreams.fromString(source.getCharacters().toString())); + LamaParser parser = new LamaParser(new CommonTokenStream(lexer)); + lexer.removeErrorListeners(); + parser.removeErrorListeners(); + BailoutErrorListener listener = new BailoutErrorListener(source); + lexer.addErrorListener(listener); + parser.addErrorListener(listener); + parser.factory = new LamaNodeFactory(language, source); + parser.source = source; + parser.lama(); + return parser.factory.getAllFunctions(); +} +} + +// parser + +lama : (import_expression)* scope_expression EOF; + +import_expression : 'import' UIDENT ';'; + +scope_expression : + definition+ (expression)? + | expression; + +definition : + variable_definition + | function_definition + | infix_definition; + +// + +variable_definition : ('var' | 'public') variable_definition_sequence; +variable_definition_sequence : variable_definition_item (',' variable_definition_item)* ';'; +variable_definition_item : LIDENT ('=' basic_expression)?; +function_definition : ('public')? 'fun' LIDENT '(' (function_arguments)? ')' function_body; +function_arguments : LIDENT (',' LIDENT)*; +function_body : '{' scope_expression '}'; + +// + +infix_definition : infix_head '(' function_arguments ')' function_body; +infix_head : ('public')? infixity INFIX level; +infixity : 'infix' | 'infixl' | 'infixr'; +level : ('at' | 'before' | 'after') INFIX; + +// + +expression returns [SLExpressionNode result]: basic_expression (';' expression)?; +basic_expression returns [SLExpressionNode result]: binary_expression; +binary_expression returns [SLExpressionNode result]: postfix_expression (INFIX postfix_expression)*; +postfix_expression returns [SLExpressionNode result]: ('-')? primary (postfix)*; +postfix : + '(' expression (',' expression)* ')' + | '[' expression ']'; + +primary returns [SLExpressionNode result]: + DECIMAL_LITERAL + | STRING_LITERAL + | CHAR_LITERAL + | LIDENT + | 'true' + | 'false' + | 'infix' INFIX + | 'fun' '(' function_arguments ')' function_body + | 'skip' + | '(' scope_expression ')' + | list_expression + | array_expression + | s_expression + | if_expression + | while_do_expression + | do_while_expression + | for_expression + | case_expression +; + +// + +array_expression : '[' (expression (',' expression)* )? ']'; +list_expression : '{' (expression (',' expression)* )? '}'; +s_expression : /*TODO */ UIDENT ('(' (expression (',' expression)* )? ')')?; + +// + +if_expression : 'if' expression 'then' scope_expression (else_part)? 'fi'; +else_part : + 'elif' expression 'then' scope_expression (else_part)? + | 'else' scope_expression; + +// + +while_do_expression : 'while' expression 'do' scope_expression 'od'; +do_while_expression : 'do' scope_expression 'while' expression 'od'; +for_expression : 'for' scope_expression ',' expression ',' expression 'do' scope_expression 'od'; + +// + +pattern: cons_pattern '|' simple_pattern; +cons_pattern : simple_pattern ':' pattern; +simple_pattern : + wildcard_pattern + | s_expr_pattern + | array_pattern + | list_pattern + | LIDENT ('@' pattern)? + | ('-')? DECIMAL_LITERAL + | STRING_LITERAL + | CHAR_LITERAL + | 'true' + | 'false' + | '#' 'box' + | '#' 'val' + | '#' 'str' + | '#' 'array' + | '#''sexp' + | '#' 'fun' + | '(' pattern ')' +; + +wildcard_pattern : '_'; +s_expr_pattern : UIDENT ('(' (pattern (',' pattern)*)? ')')?; +array_pattern : '[' (pattern (',' pattern)*)? ']'; +list_pattern : '{' (pattern (',' pattern)*)? '}'; + +// + +case_expression : 'case' expression 'of' case_branches 'esac'; +case_branches : case_branch ('|' case_branch)*; +case_branch : pattern '->' scope_expression; + +// lexer + +WS : [ \t\r\n\u000C]+ -> skip; +COMMENT : '/*' .*? '*/' -> skip; +LINE_COMMENT : '//' ~[\r\n]* -> skip; + +fragment NON_ZERO_DIGIT : [1-9]; +fragment DIGIT : [0-9]; +fragment STRING_CHAR : ~('"' | '\r' | '\n'); + +WORD : [a-zA-Z_0-9]+; + +INFIX : [+*/%$#@!|&^?<>.:=\-]+; +UIDENT : [A-Z][a-zA-Z_0-9]*; +LIDENT : [a-z][a-zA-Z_0-9]*; + +CHAR_LITERAL : '\'' STRING_CHAR '\''; +STRING_LITERAL : '"' STRING_CHAR* '"'; +DECIMAL_LITERAL : '0' | ('-'?) NON_ZERO_DIGIT DIGIT*; \ No newline at end of file diff --git a/src/main/java/org/programsnail/truffle_lama/parser/Lama.interp b/src/main/java/org/programsnail/truffle_lama/parser/Lama.interp new file mode 100644 index 0000000..b8dd464 --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/Lama.interp @@ -0,0 +1,161 @@ +token literal names: +null +'import' +';' +'var' +'public' +',' +'=' +'fun' +'(' +')' +'{' +'}' +'infix' +'infixl' +'infixr' +'at' +'before' +'after' +'-' +'[' +']' +'true' +'false' +'skip' +'if' +'then' +'fi' +'elif' +'else' +'while' +'do' +'od' +'for' +'|' +':' +'@' +'#' +'box' +'val' +'str' +'array' +'sexp' +'_' +'case' +'of' +'esac' +'->' +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +WS +COMMENT +LINE_COMMENT +WORD +INFIX +UIDENT +LIDENT +CHAR_LITERAL +STRING_LITERAL +DECIMAL_LITERAL + +rule names: +lama +import_expression +scope_expression +definition +variable_definition +variable_definition_sequence +variable_definition_item +function_definition +function_arguments +function_body +infix_definition +infix_head +infixity +level +expression +basic_expression +binary_expression +postfix_expression +postfix +primary +array_expression +list_expression +s_expression +if_expression +else_part +while_do_expression +do_while_expression +for_expression +pattern +cons_pattern +simple_pattern +wildcard_pattern +s_expr_pattern +array_pattern +list_pattern +case_expression +case_branches +case_branch + + +atn: +[4, 1, 56, 424, 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, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 1, 0, 5, 0, 78, 8, 0, 10, 0, 12, 0, 81, 9, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 91, 8, 2, 11, 2, 12, 2, 92, 1, 2, 3, 2, 96, 8, 2, 1, 2, 3, 2, 99, 8, 2, 1, 3, 1, 3, 1, 3, 3, 3, 104, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 5, 5, 112, 8, 5, 10, 5, 12, 5, 115, 9, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 3, 6, 122, 8, 6, 1, 7, 3, 7, 125, 8, 7, 1, 7, 1, 7, 1, 7, 1, 7, 3, 7, 131, 8, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 5, 8, 139, 8, 8, 10, 8, 12, 8, 142, 9, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 3, 11, 155, 8, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 3, 14, 169, 8, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 5, 16, 176, 8, 16, 10, 16, 12, 16, 179, 9, 16, 1, 17, 3, 17, 182, 8, 17, 1, 17, 1, 17, 5, 17, 186, 8, 17, 10, 17, 12, 17, 189, 9, 17, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 195, 8, 18, 10, 18, 12, 18, 198, 9, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 206, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 235, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 5, 20, 241, 8, 20, 10, 20, 12, 20, 244, 9, 20, 3, 20, 246, 8, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 1, 21, 5, 21, 254, 8, 21, 10, 21, 12, 21, 257, 9, 21, 3, 21, 259, 8, 21, 1, 21, 1, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 5, 22, 268, 8, 22, 10, 22, 12, 22, 271, 9, 22, 3, 22, 273, 8, 22, 1, 22, 3, 22, 276, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 283, 8, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 3, 24, 292, 8, 24, 1, 24, 1, 24, 3, 24, 296, 8, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 3, 30, 335, 8, 30, 1, 30, 3, 30, 338, 8, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 1, 30, 3, 30, 361, 8, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 5, 32, 370, 8, 32, 10, 32, 12, 32, 373, 9, 32, 3, 32, 375, 8, 32, 1, 32, 3, 32, 378, 8, 32, 1, 33, 1, 33, 1, 33, 1, 33, 5, 33, 384, 8, 33, 10, 33, 12, 33, 387, 9, 33, 3, 33, 389, 8, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 5, 34, 397, 8, 34, 10, 34, 12, 34, 400, 9, 34, 3, 34, 402, 8, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 5, 36, 415, 8, 36, 10, 36, 12, 36, 418, 9, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 0, 0, 38, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 0, 3, 1, 0, 3, 4, 1, 0, 12, 14, 1, 0, 15, 17, 456, 0, 79, 1, 0, 0, 0, 2, 85, 1, 0, 0, 0, 4, 98, 1, 0, 0, 0, 6, 103, 1, 0, 0, 0, 8, 105, 1, 0, 0, 0, 10, 108, 1, 0, 0, 0, 12, 118, 1, 0, 0, 0, 14, 124, 1, 0, 0, 0, 16, 135, 1, 0, 0, 0, 18, 143, 1, 0, 0, 0, 20, 147, 1, 0, 0, 0, 22, 154, 1, 0, 0, 0, 24, 160, 1, 0, 0, 0, 26, 162, 1, 0, 0, 0, 28, 165, 1, 0, 0, 0, 30, 170, 1, 0, 0, 0, 32, 172, 1, 0, 0, 0, 34, 181, 1, 0, 0, 0, 36, 205, 1, 0, 0, 0, 38, 234, 1, 0, 0, 0, 40, 236, 1, 0, 0, 0, 42, 249, 1, 0, 0, 0, 44, 262, 1, 0, 0, 0, 46, 277, 1, 0, 0, 0, 48, 295, 1, 0, 0, 0, 50, 297, 1, 0, 0, 0, 52, 303, 1, 0, 0, 0, 54, 309, 1, 0, 0, 0, 56, 319, 1, 0, 0, 0, 58, 323, 1, 0, 0, 0, 60, 360, 1, 0, 0, 0, 62, 362, 1, 0, 0, 0, 64, 364, 1, 0, 0, 0, 66, 379, 1, 0, 0, 0, 68, 392, 1, 0, 0, 0, 70, 405, 1, 0, 0, 0, 72, 411, 1, 0, 0, 0, 74, 419, 1, 0, 0, 0, 76, 78, 3, 2, 1, 0, 77, 76, 1, 0, 0, 0, 78, 81, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 82, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 82, 83, 3, 4, 2, 0, 83, 84, 5, 0, 0, 1, 84, 1, 1, 0, 0, 0, 85, 86, 5, 1, 0, 0, 86, 87, 5, 52, 0, 0, 87, 88, 5, 2, 0, 0, 88, 3, 1, 0, 0, 0, 89, 91, 3, 6, 3, 0, 90, 89, 1, 0, 0, 0, 91, 92, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 95, 1, 0, 0, 0, 94, 96, 3, 28, 14, 0, 95, 94, 1, 0, 0, 0, 95, 96, 1, 0, 0, 0, 96, 99, 1, 0, 0, 0, 97, 99, 3, 28, 14, 0, 98, 90, 1, 0, 0, 0, 98, 97, 1, 0, 0, 0, 99, 5, 1, 0, 0, 0, 100, 104, 3, 8, 4, 0, 101, 104, 3, 14, 7, 0, 102, 104, 3, 20, 10, 0, 103, 100, 1, 0, 0, 0, 103, 101, 1, 0, 0, 0, 103, 102, 1, 0, 0, 0, 104, 7, 1, 0, 0, 0, 105, 106, 7, 0, 0, 0, 106, 107, 3, 10, 5, 0, 107, 9, 1, 0, 0, 0, 108, 113, 3, 12, 6, 0, 109, 110, 5, 5, 0, 0, 110, 112, 3, 12, 6, 0, 111, 109, 1, 0, 0, 0, 112, 115, 1, 0, 0, 0, 113, 111, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 116, 1, 0, 0, 0, 115, 113, 1, 0, 0, 0, 116, 117, 5, 2, 0, 0, 117, 11, 1, 0, 0, 0, 118, 121, 5, 53, 0, 0, 119, 120, 5, 6, 0, 0, 120, 122, 3, 30, 15, 0, 121, 119, 1, 0, 0, 0, 121, 122, 1, 0, 0, 0, 122, 13, 1, 0, 0, 0, 123, 125, 5, 4, 0, 0, 124, 123, 1, 0, 0, 0, 124, 125, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 127, 5, 7, 0, 0, 127, 128, 5, 53, 0, 0, 128, 130, 5, 8, 0, 0, 129, 131, 3, 16, 8, 0, 130, 129, 1, 0, 0, 0, 130, 131, 1, 0, 0, 0, 131, 132, 1, 0, 0, 0, 132, 133, 5, 9, 0, 0, 133, 134, 3, 18, 9, 0, 134, 15, 1, 0, 0, 0, 135, 140, 5, 53, 0, 0, 136, 137, 5, 5, 0, 0, 137, 139, 5, 53, 0, 0, 138, 136, 1, 0, 0, 0, 139, 142, 1, 0, 0, 0, 140, 138, 1, 0, 0, 0, 140, 141, 1, 0, 0, 0, 141, 17, 1, 0, 0, 0, 142, 140, 1, 0, 0, 0, 143, 144, 5, 10, 0, 0, 144, 145, 3, 4, 2, 0, 145, 146, 5, 11, 0, 0, 146, 19, 1, 0, 0, 0, 147, 148, 3, 22, 11, 0, 148, 149, 5, 8, 0, 0, 149, 150, 3, 16, 8, 0, 150, 151, 5, 9, 0, 0, 151, 152, 3, 18, 9, 0, 152, 21, 1, 0, 0, 0, 153, 155, 5, 4, 0, 0, 154, 153, 1, 0, 0, 0, 154, 155, 1, 0, 0, 0, 155, 156, 1, 0, 0, 0, 156, 157, 3, 24, 12, 0, 157, 158, 5, 51, 0, 0, 158, 159, 3, 26, 13, 0, 159, 23, 1, 0, 0, 0, 160, 161, 7, 1, 0, 0, 161, 25, 1, 0, 0, 0, 162, 163, 7, 2, 0, 0, 163, 164, 5, 51, 0, 0, 164, 27, 1, 0, 0, 0, 165, 168, 3, 30, 15, 0, 166, 167, 5, 2, 0, 0, 167, 169, 3, 28, 14, 0, 168, 166, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 29, 1, 0, 0, 0, 170, 171, 3, 32, 16, 0, 171, 31, 1, 0, 0, 0, 172, 177, 3, 34, 17, 0, 173, 174, 5, 51, 0, 0, 174, 176, 3, 34, 17, 0, 175, 173, 1, 0, 0, 0, 176, 179, 1, 0, 0, 0, 177, 175, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 33, 1, 0, 0, 0, 179, 177, 1, 0, 0, 0, 180, 182, 5, 18, 0, 0, 181, 180, 1, 0, 0, 0, 181, 182, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 187, 3, 38, 19, 0, 184, 186, 3, 36, 18, 0, 185, 184, 1, 0, 0, 0, 186, 189, 1, 0, 0, 0, 187, 185, 1, 0, 0, 0, 187, 188, 1, 0, 0, 0, 188, 35, 1, 0, 0, 0, 189, 187, 1, 0, 0, 0, 190, 191, 5, 8, 0, 0, 191, 196, 3, 28, 14, 0, 192, 193, 5, 5, 0, 0, 193, 195, 3, 28, 14, 0, 194, 192, 1, 0, 0, 0, 195, 198, 1, 0, 0, 0, 196, 194, 1, 0, 0, 0, 196, 197, 1, 0, 0, 0, 197, 199, 1, 0, 0, 0, 198, 196, 1, 0, 0, 0, 199, 200, 5, 9, 0, 0, 200, 206, 1, 0, 0, 0, 201, 202, 5, 19, 0, 0, 202, 203, 3, 28, 14, 0, 203, 204, 5, 20, 0, 0, 204, 206, 1, 0, 0, 0, 205, 190, 1, 0, 0, 0, 205, 201, 1, 0, 0, 0, 206, 37, 1, 0, 0, 0, 207, 235, 5, 56, 0, 0, 208, 235, 5, 55, 0, 0, 209, 235, 5, 54, 0, 0, 210, 235, 5, 53, 0, 0, 211, 235, 5, 21, 0, 0, 212, 235, 5, 22, 0, 0, 213, 214, 5, 12, 0, 0, 214, 235, 5, 51, 0, 0, 215, 216, 5, 7, 0, 0, 216, 217, 5, 8, 0, 0, 217, 218, 3, 16, 8, 0, 218, 219, 5, 9, 0, 0, 219, 220, 3, 18, 9, 0, 220, 235, 1, 0, 0, 0, 221, 235, 5, 23, 0, 0, 222, 223, 5, 8, 0, 0, 223, 224, 3, 4, 2, 0, 224, 225, 5, 9, 0, 0, 225, 235, 1, 0, 0, 0, 226, 235, 3, 42, 21, 0, 227, 235, 3, 40, 20, 0, 228, 235, 3, 44, 22, 0, 229, 235, 3, 46, 23, 0, 230, 235, 3, 50, 25, 0, 231, 235, 3, 52, 26, 0, 232, 235, 3, 54, 27, 0, 233, 235, 3, 70, 35, 0, 234, 207, 1, 0, 0, 0, 234, 208, 1, 0, 0, 0, 234, 209, 1, 0, 0, 0, 234, 210, 1, 0, 0, 0, 234, 211, 1, 0, 0, 0, 234, 212, 1, 0, 0, 0, 234, 213, 1, 0, 0, 0, 234, 215, 1, 0, 0, 0, 234, 221, 1, 0, 0, 0, 234, 222, 1, 0, 0, 0, 234, 226, 1, 0, 0, 0, 234, 227, 1, 0, 0, 0, 234, 228, 1, 0, 0, 0, 234, 229, 1, 0, 0, 0, 234, 230, 1, 0, 0, 0, 234, 231, 1, 0, 0, 0, 234, 232, 1, 0, 0, 0, 234, 233, 1, 0, 0, 0, 235, 39, 1, 0, 0, 0, 236, 245, 5, 19, 0, 0, 237, 242, 3, 28, 14, 0, 238, 239, 5, 5, 0, 0, 239, 241, 3, 28, 14, 0, 240, 238, 1, 0, 0, 0, 241, 244, 1, 0, 0, 0, 242, 240, 1, 0, 0, 0, 242, 243, 1, 0, 0, 0, 243, 246, 1, 0, 0, 0, 244, 242, 1, 0, 0, 0, 245, 237, 1, 0, 0, 0, 245, 246, 1, 0, 0, 0, 246, 247, 1, 0, 0, 0, 247, 248, 5, 20, 0, 0, 248, 41, 1, 0, 0, 0, 249, 258, 5, 10, 0, 0, 250, 255, 3, 28, 14, 0, 251, 252, 5, 5, 0, 0, 252, 254, 3, 28, 14, 0, 253, 251, 1, 0, 0, 0, 254, 257, 1, 0, 0, 0, 255, 253, 1, 0, 0, 0, 255, 256, 1, 0, 0, 0, 256, 259, 1, 0, 0, 0, 257, 255, 1, 0, 0, 0, 258, 250, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 260, 1, 0, 0, 0, 260, 261, 5, 11, 0, 0, 261, 43, 1, 0, 0, 0, 262, 275, 5, 52, 0, 0, 263, 272, 5, 8, 0, 0, 264, 269, 3, 28, 14, 0, 265, 266, 5, 5, 0, 0, 266, 268, 3, 28, 14, 0, 267, 265, 1, 0, 0, 0, 268, 271, 1, 0, 0, 0, 269, 267, 1, 0, 0, 0, 269, 270, 1, 0, 0, 0, 270, 273, 1, 0, 0, 0, 271, 269, 1, 0, 0, 0, 272, 264, 1, 0, 0, 0, 272, 273, 1, 0, 0, 0, 273, 274, 1, 0, 0, 0, 274, 276, 5, 9, 0, 0, 275, 263, 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 45, 1, 0, 0, 0, 277, 278, 5, 24, 0, 0, 278, 279, 3, 28, 14, 0, 279, 280, 5, 25, 0, 0, 280, 282, 3, 4, 2, 0, 281, 283, 3, 48, 24, 0, 282, 281, 1, 0, 0, 0, 282, 283, 1, 0, 0, 0, 283, 284, 1, 0, 0, 0, 284, 285, 5, 26, 0, 0, 285, 47, 1, 0, 0, 0, 286, 287, 5, 27, 0, 0, 287, 288, 3, 28, 14, 0, 288, 289, 5, 25, 0, 0, 289, 291, 3, 4, 2, 0, 290, 292, 3, 48, 24, 0, 291, 290, 1, 0, 0, 0, 291, 292, 1, 0, 0, 0, 292, 296, 1, 0, 0, 0, 293, 294, 5, 28, 0, 0, 294, 296, 3, 4, 2, 0, 295, 286, 1, 0, 0, 0, 295, 293, 1, 0, 0, 0, 296, 49, 1, 0, 0, 0, 297, 298, 5, 29, 0, 0, 298, 299, 3, 28, 14, 0, 299, 300, 5, 30, 0, 0, 300, 301, 3, 4, 2, 0, 301, 302, 5, 31, 0, 0, 302, 51, 1, 0, 0, 0, 303, 304, 5, 30, 0, 0, 304, 305, 3, 4, 2, 0, 305, 306, 5, 29, 0, 0, 306, 307, 3, 28, 14, 0, 307, 308, 5, 31, 0, 0, 308, 53, 1, 0, 0, 0, 309, 310, 5, 32, 0, 0, 310, 311, 3, 4, 2, 0, 311, 312, 5, 5, 0, 0, 312, 313, 3, 28, 14, 0, 313, 314, 5, 5, 0, 0, 314, 315, 3, 28, 14, 0, 315, 316, 5, 30, 0, 0, 316, 317, 3, 4, 2, 0, 317, 318, 5, 31, 0, 0, 318, 55, 1, 0, 0, 0, 319, 320, 3, 58, 29, 0, 320, 321, 5, 33, 0, 0, 321, 322, 3, 60, 30, 0, 322, 57, 1, 0, 0, 0, 323, 324, 3, 60, 30, 0, 324, 325, 5, 34, 0, 0, 325, 326, 3, 56, 28, 0, 326, 59, 1, 0, 0, 0, 327, 361, 3, 62, 31, 0, 328, 361, 3, 64, 32, 0, 329, 361, 3, 66, 33, 0, 330, 361, 3, 68, 34, 0, 331, 334, 5, 53, 0, 0, 332, 333, 5, 35, 0, 0, 333, 335, 3, 56, 28, 0, 334, 332, 1, 0, 0, 0, 334, 335, 1, 0, 0, 0, 335, 361, 1, 0, 0, 0, 336, 338, 5, 18, 0, 0, 337, 336, 1, 0, 0, 0, 337, 338, 1, 0, 0, 0, 338, 339, 1, 0, 0, 0, 339, 361, 5, 56, 0, 0, 340, 361, 5, 55, 0, 0, 341, 361, 5, 54, 0, 0, 342, 361, 5, 21, 0, 0, 343, 361, 5, 22, 0, 0, 344, 345, 5, 36, 0, 0, 345, 361, 5, 37, 0, 0, 346, 347, 5, 36, 0, 0, 347, 361, 5, 38, 0, 0, 348, 349, 5, 36, 0, 0, 349, 361, 5, 39, 0, 0, 350, 351, 5, 36, 0, 0, 351, 361, 5, 40, 0, 0, 352, 353, 5, 36, 0, 0, 353, 361, 5, 41, 0, 0, 354, 355, 5, 36, 0, 0, 355, 361, 5, 7, 0, 0, 356, 357, 5, 8, 0, 0, 357, 358, 3, 56, 28, 0, 358, 359, 5, 9, 0, 0, 359, 361, 1, 0, 0, 0, 360, 327, 1, 0, 0, 0, 360, 328, 1, 0, 0, 0, 360, 329, 1, 0, 0, 0, 360, 330, 1, 0, 0, 0, 360, 331, 1, 0, 0, 0, 360, 337, 1, 0, 0, 0, 360, 340, 1, 0, 0, 0, 360, 341, 1, 0, 0, 0, 360, 342, 1, 0, 0, 0, 360, 343, 1, 0, 0, 0, 360, 344, 1, 0, 0, 0, 360, 346, 1, 0, 0, 0, 360, 348, 1, 0, 0, 0, 360, 350, 1, 0, 0, 0, 360, 352, 1, 0, 0, 0, 360, 354, 1, 0, 0, 0, 360, 356, 1, 0, 0, 0, 361, 61, 1, 0, 0, 0, 362, 363, 5, 42, 0, 0, 363, 63, 1, 0, 0, 0, 364, 377, 5, 52, 0, 0, 365, 374, 5, 8, 0, 0, 366, 371, 3, 56, 28, 0, 367, 368, 5, 5, 0, 0, 368, 370, 3, 56, 28, 0, 369, 367, 1, 0, 0, 0, 370, 373, 1, 0, 0, 0, 371, 369, 1, 0, 0, 0, 371, 372, 1, 0, 0, 0, 372, 375, 1, 0, 0, 0, 373, 371, 1, 0, 0, 0, 374, 366, 1, 0, 0, 0, 374, 375, 1, 0, 0, 0, 375, 376, 1, 0, 0, 0, 376, 378, 5, 9, 0, 0, 377, 365, 1, 0, 0, 0, 377, 378, 1, 0, 0, 0, 378, 65, 1, 0, 0, 0, 379, 388, 5, 19, 0, 0, 380, 385, 3, 56, 28, 0, 381, 382, 5, 5, 0, 0, 382, 384, 3, 56, 28, 0, 383, 381, 1, 0, 0, 0, 384, 387, 1, 0, 0, 0, 385, 383, 1, 0, 0, 0, 385, 386, 1, 0, 0, 0, 386, 389, 1, 0, 0, 0, 387, 385, 1, 0, 0, 0, 388, 380, 1, 0, 0, 0, 388, 389, 1, 0, 0, 0, 389, 390, 1, 0, 0, 0, 390, 391, 5, 20, 0, 0, 391, 67, 1, 0, 0, 0, 392, 401, 5, 10, 0, 0, 393, 398, 3, 56, 28, 0, 394, 395, 5, 5, 0, 0, 395, 397, 3, 56, 28, 0, 396, 394, 1, 0, 0, 0, 397, 400, 1, 0, 0, 0, 398, 396, 1, 0, 0, 0, 398, 399, 1, 0, 0, 0, 399, 402, 1, 0, 0, 0, 400, 398, 1, 0, 0, 0, 401, 393, 1, 0, 0, 0, 401, 402, 1, 0, 0, 0, 402, 403, 1, 0, 0, 0, 403, 404, 5, 11, 0, 0, 404, 69, 1, 0, 0, 0, 405, 406, 5, 43, 0, 0, 406, 407, 3, 28, 14, 0, 407, 408, 5, 44, 0, 0, 408, 409, 3, 72, 36, 0, 409, 410, 5, 45, 0, 0, 410, 71, 1, 0, 0, 0, 411, 416, 3, 74, 37, 0, 412, 413, 5, 33, 0, 0, 413, 415, 3, 74, 37, 0, 414, 412, 1, 0, 0, 0, 415, 418, 1, 0, 0, 0, 416, 414, 1, 0, 0, 0, 416, 417, 1, 0, 0, 0, 417, 73, 1, 0, 0, 0, 418, 416, 1, 0, 0, 0, 419, 420, 3, 56, 28, 0, 420, 421, 5, 46, 0, 0, 421, 422, 3, 4, 2, 0, 422, 75, 1, 0, 0, 0, 39, 79, 92, 95, 98, 103, 113, 121, 124, 130, 140, 154, 168, 177, 181, 187, 196, 205, 234, 242, 245, 255, 258, 269, 272, 275, 282, 291, 295, 334, 337, 360, 371, 374, 377, 385, 388, 398, 401, 416] \ No newline at end of file diff --git a/src/main/java/org/programsnail/truffle_lama/parser/Lama.tokens b/src/main/java/org/programsnail/truffle_lama/parser/Lama.tokens new file mode 100644 index 0000000..ae67504 --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/Lama.tokens @@ -0,0 +1,102 @@ +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 +T__16=17 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +T__21=22 +T__22=23 +T__23=24 +T__24=25 +T__25=26 +T__26=27 +T__27=28 +T__28=29 +T__29=30 +T__30=31 +T__31=32 +T__32=33 +T__33=34 +T__34=35 +T__35=36 +T__36=37 +T__37=38 +T__38=39 +T__39=40 +T__40=41 +T__41=42 +T__42=43 +T__43=44 +T__44=45 +T__45=46 +WS=47 +COMMENT=48 +LINE_COMMENT=49 +WORD=50 +INFIX=51 +UIDENT=52 +LIDENT=53 +CHAR_LITERAL=54 +STRING_LITERAL=55 +DECIMAL_LITERAL=56 +'import'=1 +';'=2 +'var'=3 +'public'=4 +','=5 +'='=6 +'fun'=7 +'('=8 +')'=9 +'{'=10 +'}'=11 +'infix'=12 +'infixl'=13 +'infixr'=14 +'at'=15 +'before'=16 +'after'=17 +'-'=18 +'['=19 +']'=20 +'true'=21 +'false'=22 +'skip'=23 +'if'=24 +'then'=25 +'fi'=26 +'elif'=27 +'else'=28 +'while'=29 +'do'=30 +'od'=31 +'for'=32 +'|'=33 +':'=34 +'@'=35 +'#'=36 +'box'=37 +'val'=38 +'str'=39 +'array'=40 +'sexp'=41 +'_'=42 +'case'=43 +'of'=44 +'esac'=45 +'->'=46 diff --git a/src/main/java/org/programsnail/truffle_lama/parser/LamaBaseListener.java b/src/main/java/org/programsnail/truffle_lama/parser/LamaBaseListener.java new file mode 100644 index 0000000..98d45cd --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/LamaBaseListener.java @@ -0,0 +1,496 @@ +// Generated from /home/dragon/Containers/DevGraalVM/src/truffle-lama-from-scratch/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 by ANTLR 4.13.2 +package org.programsnail.truffle_lama.parser; + +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 LamaListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class LamaBaseListener implements LamaListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLama(LamaParser.LamaContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLama(LamaParser.LamaContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterImport_expression(LamaParser.Import_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitImport_expression(LamaParser.Import_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterScope_expression(LamaParser.Scope_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitScope_expression(LamaParser.Scope_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDefinition(LamaParser.DefinitionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDefinition(LamaParser.DefinitionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterVariable_definition(LamaParser.Variable_definitionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitVariable_definition(LamaParser.Variable_definitionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterVariable_definition_item(LamaParser.Variable_definition_itemContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitVariable_definition_item(LamaParser.Variable_definition_itemContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunction_definition(LamaParser.Function_definitionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunction_definition(LamaParser.Function_definitionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunction_arguments(LamaParser.Function_argumentsContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunction_arguments(LamaParser.Function_argumentsContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunction_body(LamaParser.Function_bodyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunction_body(LamaParser.Function_bodyContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInfix_definition(LamaParser.Infix_definitionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInfix_definition(LamaParser.Infix_definitionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInfix_head(LamaParser.Infix_headContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInfix_head(LamaParser.Infix_headContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterInfixity(LamaParser.InfixityContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitInfixity(LamaParser.InfixityContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLevel(LamaParser.LevelContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLevel(LamaParser.LevelContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

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

The default implementation does nothing.

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

The default implementation does nothing.

+ */ + @Override public void enterBasic_expression(LamaParser.Basic_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBasic_expression(LamaParser.Basic_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterBinary_expression(LamaParser.Binary_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitBinary_expression(LamaParser.Binary_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPostfix_expression(LamaParser.Postfix_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPostfix_expression(LamaParser.Postfix_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPostfix(LamaParser.PostfixContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPostfix(LamaParser.PostfixContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPrimary(LamaParser.PrimaryContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPrimary(LamaParser.PrimaryContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArray_expression(LamaParser.Array_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArray_expression(LamaParser.Array_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterList_expression(LamaParser.List_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitList_expression(LamaParser.List_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterS_expression(LamaParser.S_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitS_expression(LamaParser.S_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterIf_expression(LamaParser.If_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitIf_expression(LamaParser.If_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterElse_part(LamaParser.Else_partContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitElse_part(LamaParser.Else_partContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterWhile_do_expression(LamaParser.While_do_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitWhile_do_expression(LamaParser.While_do_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterDo_while_expression(LamaParser.Do_while_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitDo_while_expression(LamaParser.Do_while_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFor_expression(LamaParser.For_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFor_expression(LamaParser.For_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPattern(LamaParser.PatternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPattern(LamaParser.PatternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCons_pattern(LamaParser.Cons_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCons_pattern(LamaParser.Cons_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterSimple_pattern(LamaParser.Simple_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitSimple_pattern(LamaParser.Simple_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterWildcard_pattern(LamaParser.Wildcard_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitWildcard_pattern(LamaParser.Wildcard_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterS_expr_pattern(LamaParser.S_expr_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitS_expr_pattern(LamaParser.S_expr_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterArray_pattern(LamaParser.Array_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitArray_pattern(LamaParser.Array_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterList_pattern(LamaParser.List_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitList_pattern(LamaParser.List_patternContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCase_expression(LamaParser.Case_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCase_expression(LamaParser.Case_expressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCase_branches(LamaParser.Case_branchesContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCase_branches(LamaParser.Case_branchesContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterCase_branch(LamaParser.Case_branchContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitCase_branch(LamaParser.Case_branchContext 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/org/programsnail/truffle_lama/parser/LamaBaseVisitor.java b/src/main/java/org/programsnail/truffle_lama/parser/LamaBaseVisitor.java new file mode 100644 index 0000000..41d14c8 --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/LamaBaseVisitor.java @@ -0,0 +1,281 @@ +// Generated from /home/dragon/Containers/DevGraalVM/src/truffle-lama-from-scratch/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 by ANTLR 4.13.2 +package org.programsnail.truffle_lama.parser; +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link LamaVisitor}, + * 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 LamaBaseVisitor extends AbstractParseTreeVisitor implements LamaVisitor { + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitLama(LamaParser.LamaContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitImport_expression(LamaParser.Import_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitScope_expression(LamaParser.Scope_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDefinition(LamaParser.DefinitionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitVariable_definition(LamaParser.Variable_definitionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitVariable_definition_item(LamaParser.Variable_definition_itemContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitFunction_definition(LamaParser.Function_definitionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitFunction_arguments(LamaParser.Function_argumentsContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitFunction_body(LamaParser.Function_bodyContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInfix_definition(LamaParser.Infix_definitionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInfix_head(LamaParser.Infix_headContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitInfixity(LamaParser.InfixityContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitLevel(LamaParser.LevelContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

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

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

+ */ + @Override public T visitBasic_expression(LamaParser.Basic_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitBinary_expression(LamaParser.Binary_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPostfix_expression(LamaParser.Postfix_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPostfix(LamaParser.PostfixContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPrimary(LamaParser.PrimaryContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitArray_expression(LamaParser.Array_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitList_expression(LamaParser.List_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitS_expression(LamaParser.S_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitIf_expression(LamaParser.If_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitElse_part(LamaParser.Else_partContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitWhile_do_expression(LamaParser.While_do_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitDo_while_expression(LamaParser.Do_while_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitFor_expression(LamaParser.For_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitPattern(LamaParser.PatternContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitCons_pattern(LamaParser.Cons_patternContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitSimple_pattern(LamaParser.Simple_patternContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitWildcard_pattern(LamaParser.Wildcard_patternContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitS_expr_pattern(LamaParser.S_expr_patternContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitArray_pattern(LamaParser.Array_patternContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitList_pattern(LamaParser.List_patternContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitCase_expression(LamaParser.Case_expressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitCase_branches(LamaParser.Case_branchesContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

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

+ */ + @Override public T visitCase_branch(LamaParser.Case_branchContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.interp b/src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.interp new file mode 100644 index 0000000..1171b41 --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.interp @@ -0,0 +1,188 @@ +token literal names: +null +'import' +';' +'var' +'public' +',' +'=' +'fun' +'(' +')' +'{' +'}' +'infix' +'infixl' +'infixr' +'at' +'before' +'after' +'-' +'[' +']' +'true' +'false' +'skip' +'if' +'then' +'fi' +'elif' +'else' +'while' +'do' +'od' +'for' +'|' +':' +'@' +'#' +'box' +'val' +'str' +'array' +'sexp' +'_' +'case' +'of' +'esac' +'->' +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +WS +COMMENT +LINE_COMMENT +WORD +INFIX +UIDENT +LIDENT +CHAR_LITERAL +STRING_LITERAL +DECIMAL_LITERAL + +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 +T__16 +T__17 +T__18 +T__19 +T__20 +T__21 +T__22 +T__23 +T__24 +T__25 +T__26 +T__27 +T__28 +T__29 +T__30 +T__31 +T__32 +T__33 +T__34 +T__35 +T__36 +T__37 +T__38 +T__39 +T__40 +T__41 +T__42 +T__43 +T__44 +T__45 +WS +COMMENT +LINE_COMMENT +NON_ZERO_DIGIT +DIGIT +STRING_CHAR +WORD +INFIX +UIDENT +LIDENT +CHAR_LITERAL +STRING_LITERAL +DECIMAL_LITERAL + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 56, 387, 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, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 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, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 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, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 23, 1, 23, 1, 23, 1, 24, 1, 24, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 1, 46, 4, 46, 301, 8, 46, 11, 46, 12, 46, 302, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 1, 47, 5, 47, 311, 8, 47, 10, 47, 12, 47, 314, 9, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 48, 5, 48, 325, 8, 48, 10, 48, 12, 48, 328, 9, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 50, 1, 50, 1, 51, 1, 51, 1, 52, 4, 52, 339, 8, 52, 11, 52, 12, 52, 340, 1, 53, 4, 53, 344, 8, 53, 11, 53, 12, 53, 345, 1, 54, 1, 54, 5, 54, 350, 8, 54, 10, 54, 12, 54, 353, 9, 54, 1, 55, 1, 55, 5, 55, 357, 8, 55, 10, 55, 12, 55, 360, 9, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 5, 57, 368, 8, 57, 10, 57, 12, 57, 371, 9, 57, 1, 57, 1, 57, 1, 58, 1, 58, 3, 58, 377, 8, 58, 1, 58, 1, 58, 5, 58, 381, 8, 58, 10, 58, 12, 58, 384, 9, 58, 3, 58, 386, 8, 58, 1, 312, 0, 59, 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, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 47, 95, 48, 97, 49, 99, 0, 101, 0, 103, 0, 105, 50, 107, 51, 109, 52, 111, 53, 113, 54, 115, 55, 117, 56, 1, 0, 9, 3, 0, 9, 10, 12, 13, 32, 32, 2, 0, 10, 10, 13, 13, 1, 0, 49, 57, 1, 0, 48, 57, 3, 0, 10, 10, 13, 13, 34, 34, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 8, 0, 33, 33, 35, 38, 42, 43, 45, 47, 58, 58, 60, 64, 94, 94, 124, 124, 1, 0, 65, 90, 1, 0, 97, 122, 394, 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, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 0, 95, 1, 0, 0, 0, 0, 97, 1, 0, 0, 0, 0, 105, 1, 0, 0, 0, 0, 107, 1, 0, 0, 0, 0, 109, 1, 0, 0, 0, 0, 111, 1, 0, 0, 0, 0, 113, 1, 0, 0, 0, 0, 115, 1, 0, 0, 0, 0, 117, 1, 0, 0, 0, 1, 119, 1, 0, 0, 0, 3, 126, 1, 0, 0, 0, 5, 128, 1, 0, 0, 0, 7, 132, 1, 0, 0, 0, 9, 139, 1, 0, 0, 0, 11, 141, 1, 0, 0, 0, 13, 143, 1, 0, 0, 0, 15, 147, 1, 0, 0, 0, 17, 149, 1, 0, 0, 0, 19, 151, 1, 0, 0, 0, 21, 153, 1, 0, 0, 0, 23, 155, 1, 0, 0, 0, 25, 161, 1, 0, 0, 0, 27, 168, 1, 0, 0, 0, 29, 175, 1, 0, 0, 0, 31, 178, 1, 0, 0, 0, 33, 185, 1, 0, 0, 0, 35, 191, 1, 0, 0, 0, 37, 193, 1, 0, 0, 0, 39, 195, 1, 0, 0, 0, 41, 197, 1, 0, 0, 0, 43, 202, 1, 0, 0, 0, 45, 208, 1, 0, 0, 0, 47, 213, 1, 0, 0, 0, 49, 216, 1, 0, 0, 0, 51, 221, 1, 0, 0, 0, 53, 224, 1, 0, 0, 0, 55, 229, 1, 0, 0, 0, 57, 234, 1, 0, 0, 0, 59, 240, 1, 0, 0, 0, 61, 243, 1, 0, 0, 0, 63, 246, 1, 0, 0, 0, 65, 250, 1, 0, 0, 0, 67, 252, 1, 0, 0, 0, 69, 254, 1, 0, 0, 0, 71, 256, 1, 0, 0, 0, 73, 258, 1, 0, 0, 0, 75, 262, 1, 0, 0, 0, 77, 266, 1, 0, 0, 0, 79, 270, 1, 0, 0, 0, 81, 276, 1, 0, 0, 0, 83, 281, 1, 0, 0, 0, 85, 283, 1, 0, 0, 0, 87, 288, 1, 0, 0, 0, 89, 291, 1, 0, 0, 0, 91, 296, 1, 0, 0, 0, 93, 300, 1, 0, 0, 0, 95, 306, 1, 0, 0, 0, 97, 320, 1, 0, 0, 0, 99, 331, 1, 0, 0, 0, 101, 333, 1, 0, 0, 0, 103, 335, 1, 0, 0, 0, 105, 338, 1, 0, 0, 0, 107, 343, 1, 0, 0, 0, 109, 347, 1, 0, 0, 0, 111, 354, 1, 0, 0, 0, 113, 361, 1, 0, 0, 0, 115, 365, 1, 0, 0, 0, 117, 385, 1, 0, 0, 0, 119, 120, 5, 105, 0, 0, 120, 121, 5, 109, 0, 0, 121, 122, 5, 112, 0, 0, 122, 123, 5, 111, 0, 0, 123, 124, 5, 114, 0, 0, 124, 125, 5, 116, 0, 0, 125, 2, 1, 0, 0, 0, 126, 127, 5, 59, 0, 0, 127, 4, 1, 0, 0, 0, 128, 129, 5, 118, 0, 0, 129, 130, 5, 97, 0, 0, 130, 131, 5, 114, 0, 0, 131, 6, 1, 0, 0, 0, 132, 133, 5, 112, 0, 0, 133, 134, 5, 117, 0, 0, 134, 135, 5, 98, 0, 0, 135, 136, 5, 108, 0, 0, 136, 137, 5, 105, 0, 0, 137, 138, 5, 99, 0, 0, 138, 8, 1, 0, 0, 0, 139, 140, 5, 44, 0, 0, 140, 10, 1, 0, 0, 0, 141, 142, 5, 61, 0, 0, 142, 12, 1, 0, 0, 0, 143, 144, 5, 102, 0, 0, 144, 145, 5, 117, 0, 0, 145, 146, 5, 110, 0, 0, 146, 14, 1, 0, 0, 0, 147, 148, 5, 40, 0, 0, 148, 16, 1, 0, 0, 0, 149, 150, 5, 41, 0, 0, 150, 18, 1, 0, 0, 0, 151, 152, 5, 123, 0, 0, 152, 20, 1, 0, 0, 0, 153, 154, 5, 125, 0, 0, 154, 22, 1, 0, 0, 0, 155, 156, 5, 105, 0, 0, 156, 157, 5, 110, 0, 0, 157, 158, 5, 102, 0, 0, 158, 159, 5, 105, 0, 0, 159, 160, 5, 120, 0, 0, 160, 24, 1, 0, 0, 0, 161, 162, 5, 105, 0, 0, 162, 163, 5, 110, 0, 0, 163, 164, 5, 102, 0, 0, 164, 165, 5, 105, 0, 0, 165, 166, 5, 120, 0, 0, 166, 167, 5, 108, 0, 0, 167, 26, 1, 0, 0, 0, 168, 169, 5, 105, 0, 0, 169, 170, 5, 110, 0, 0, 170, 171, 5, 102, 0, 0, 171, 172, 5, 105, 0, 0, 172, 173, 5, 120, 0, 0, 173, 174, 5, 114, 0, 0, 174, 28, 1, 0, 0, 0, 175, 176, 5, 97, 0, 0, 176, 177, 5, 116, 0, 0, 177, 30, 1, 0, 0, 0, 178, 179, 5, 98, 0, 0, 179, 180, 5, 101, 0, 0, 180, 181, 5, 102, 0, 0, 181, 182, 5, 111, 0, 0, 182, 183, 5, 114, 0, 0, 183, 184, 5, 101, 0, 0, 184, 32, 1, 0, 0, 0, 185, 186, 5, 97, 0, 0, 186, 187, 5, 102, 0, 0, 187, 188, 5, 116, 0, 0, 188, 189, 5, 101, 0, 0, 189, 190, 5, 114, 0, 0, 190, 34, 1, 0, 0, 0, 191, 192, 5, 45, 0, 0, 192, 36, 1, 0, 0, 0, 193, 194, 5, 91, 0, 0, 194, 38, 1, 0, 0, 0, 195, 196, 5, 93, 0, 0, 196, 40, 1, 0, 0, 0, 197, 198, 5, 116, 0, 0, 198, 199, 5, 114, 0, 0, 199, 200, 5, 117, 0, 0, 200, 201, 5, 101, 0, 0, 201, 42, 1, 0, 0, 0, 202, 203, 5, 102, 0, 0, 203, 204, 5, 97, 0, 0, 204, 205, 5, 108, 0, 0, 205, 206, 5, 115, 0, 0, 206, 207, 5, 101, 0, 0, 207, 44, 1, 0, 0, 0, 208, 209, 5, 115, 0, 0, 209, 210, 5, 107, 0, 0, 210, 211, 5, 105, 0, 0, 211, 212, 5, 112, 0, 0, 212, 46, 1, 0, 0, 0, 213, 214, 5, 105, 0, 0, 214, 215, 5, 102, 0, 0, 215, 48, 1, 0, 0, 0, 216, 217, 5, 116, 0, 0, 217, 218, 5, 104, 0, 0, 218, 219, 5, 101, 0, 0, 219, 220, 5, 110, 0, 0, 220, 50, 1, 0, 0, 0, 221, 222, 5, 102, 0, 0, 222, 223, 5, 105, 0, 0, 223, 52, 1, 0, 0, 0, 224, 225, 5, 101, 0, 0, 225, 226, 5, 108, 0, 0, 226, 227, 5, 105, 0, 0, 227, 228, 5, 102, 0, 0, 228, 54, 1, 0, 0, 0, 229, 230, 5, 101, 0, 0, 230, 231, 5, 108, 0, 0, 231, 232, 5, 115, 0, 0, 232, 233, 5, 101, 0, 0, 233, 56, 1, 0, 0, 0, 234, 235, 5, 119, 0, 0, 235, 236, 5, 104, 0, 0, 236, 237, 5, 105, 0, 0, 237, 238, 5, 108, 0, 0, 238, 239, 5, 101, 0, 0, 239, 58, 1, 0, 0, 0, 240, 241, 5, 100, 0, 0, 241, 242, 5, 111, 0, 0, 242, 60, 1, 0, 0, 0, 243, 244, 5, 111, 0, 0, 244, 245, 5, 100, 0, 0, 245, 62, 1, 0, 0, 0, 246, 247, 5, 102, 0, 0, 247, 248, 5, 111, 0, 0, 248, 249, 5, 114, 0, 0, 249, 64, 1, 0, 0, 0, 250, 251, 5, 124, 0, 0, 251, 66, 1, 0, 0, 0, 252, 253, 5, 58, 0, 0, 253, 68, 1, 0, 0, 0, 254, 255, 5, 64, 0, 0, 255, 70, 1, 0, 0, 0, 256, 257, 5, 35, 0, 0, 257, 72, 1, 0, 0, 0, 258, 259, 5, 98, 0, 0, 259, 260, 5, 111, 0, 0, 260, 261, 5, 120, 0, 0, 261, 74, 1, 0, 0, 0, 262, 263, 5, 118, 0, 0, 263, 264, 5, 97, 0, 0, 264, 265, 5, 108, 0, 0, 265, 76, 1, 0, 0, 0, 266, 267, 5, 115, 0, 0, 267, 268, 5, 116, 0, 0, 268, 269, 5, 114, 0, 0, 269, 78, 1, 0, 0, 0, 270, 271, 5, 97, 0, 0, 271, 272, 5, 114, 0, 0, 272, 273, 5, 114, 0, 0, 273, 274, 5, 97, 0, 0, 274, 275, 5, 121, 0, 0, 275, 80, 1, 0, 0, 0, 276, 277, 5, 115, 0, 0, 277, 278, 5, 101, 0, 0, 278, 279, 5, 120, 0, 0, 279, 280, 5, 112, 0, 0, 280, 82, 1, 0, 0, 0, 281, 282, 5, 95, 0, 0, 282, 84, 1, 0, 0, 0, 283, 284, 5, 99, 0, 0, 284, 285, 5, 97, 0, 0, 285, 286, 5, 115, 0, 0, 286, 287, 5, 101, 0, 0, 287, 86, 1, 0, 0, 0, 288, 289, 5, 111, 0, 0, 289, 290, 5, 102, 0, 0, 290, 88, 1, 0, 0, 0, 291, 292, 5, 101, 0, 0, 292, 293, 5, 115, 0, 0, 293, 294, 5, 97, 0, 0, 294, 295, 5, 99, 0, 0, 295, 90, 1, 0, 0, 0, 296, 297, 5, 45, 0, 0, 297, 298, 5, 62, 0, 0, 298, 92, 1, 0, 0, 0, 299, 301, 7, 0, 0, 0, 300, 299, 1, 0, 0, 0, 301, 302, 1, 0, 0, 0, 302, 300, 1, 0, 0, 0, 302, 303, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 305, 6, 46, 0, 0, 305, 94, 1, 0, 0, 0, 306, 307, 5, 47, 0, 0, 307, 308, 5, 42, 0, 0, 308, 312, 1, 0, 0, 0, 309, 311, 9, 0, 0, 0, 310, 309, 1, 0, 0, 0, 311, 314, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 312, 310, 1, 0, 0, 0, 313, 315, 1, 0, 0, 0, 314, 312, 1, 0, 0, 0, 315, 316, 5, 42, 0, 0, 316, 317, 5, 47, 0, 0, 317, 318, 1, 0, 0, 0, 318, 319, 6, 47, 0, 0, 319, 96, 1, 0, 0, 0, 320, 321, 5, 47, 0, 0, 321, 322, 5, 47, 0, 0, 322, 326, 1, 0, 0, 0, 323, 325, 8, 1, 0, 0, 324, 323, 1, 0, 0, 0, 325, 328, 1, 0, 0, 0, 326, 324, 1, 0, 0, 0, 326, 327, 1, 0, 0, 0, 327, 329, 1, 0, 0, 0, 328, 326, 1, 0, 0, 0, 329, 330, 6, 48, 0, 0, 330, 98, 1, 0, 0, 0, 331, 332, 7, 2, 0, 0, 332, 100, 1, 0, 0, 0, 333, 334, 7, 3, 0, 0, 334, 102, 1, 0, 0, 0, 335, 336, 8, 4, 0, 0, 336, 104, 1, 0, 0, 0, 337, 339, 7, 5, 0, 0, 338, 337, 1, 0, 0, 0, 339, 340, 1, 0, 0, 0, 340, 338, 1, 0, 0, 0, 340, 341, 1, 0, 0, 0, 341, 106, 1, 0, 0, 0, 342, 344, 7, 6, 0, 0, 343, 342, 1, 0, 0, 0, 344, 345, 1, 0, 0, 0, 345, 343, 1, 0, 0, 0, 345, 346, 1, 0, 0, 0, 346, 108, 1, 0, 0, 0, 347, 351, 7, 7, 0, 0, 348, 350, 7, 5, 0, 0, 349, 348, 1, 0, 0, 0, 350, 353, 1, 0, 0, 0, 351, 349, 1, 0, 0, 0, 351, 352, 1, 0, 0, 0, 352, 110, 1, 0, 0, 0, 353, 351, 1, 0, 0, 0, 354, 358, 7, 8, 0, 0, 355, 357, 7, 5, 0, 0, 356, 355, 1, 0, 0, 0, 357, 360, 1, 0, 0, 0, 358, 356, 1, 0, 0, 0, 358, 359, 1, 0, 0, 0, 359, 112, 1, 0, 0, 0, 360, 358, 1, 0, 0, 0, 361, 362, 5, 39, 0, 0, 362, 363, 3, 103, 51, 0, 363, 364, 5, 39, 0, 0, 364, 114, 1, 0, 0, 0, 365, 369, 5, 34, 0, 0, 366, 368, 3, 103, 51, 0, 367, 366, 1, 0, 0, 0, 368, 371, 1, 0, 0, 0, 369, 367, 1, 0, 0, 0, 369, 370, 1, 0, 0, 0, 370, 372, 1, 0, 0, 0, 371, 369, 1, 0, 0, 0, 372, 373, 5, 34, 0, 0, 373, 116, 1, 0, 0, 0, 374, 386, 5, 48, 0, 0, 375, 377, 5, 45, 0, 0, 376, 375, 1, 0, 0, 0, 376, 377, 1, 0, 0, 0, 377, 378, 1, 0, 0, 0, 378, 382, 3, 99, 49, 0, 379, 381, 3, 101, 50, 0, 380, 379, 1, 0, 0, 0, 381, 384, 1, 0, 0, 0, 382, 380, 1, 0, 0, 0, 382, 383, 1, 0, 0, 0, 383, 386, 1, 0, 0, 0, 384, 382, 1, 0, 0, 0, 385, 374, 1, 0, 0, 0, 385, 376, 1, 0, 0, 0, 386, 118, 1, 0, 0, 0, 12, 0, 302, 312, 326, 340, 345, 351, 358, 369, 376, 382, 385, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.java b/src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.java new file mode 100644 index 0000000..54c19db --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.java @@ -0,0 +1,372 @@ +// Generated from /home/dragon/Containers/DevGraalVM/src/truffle-lama-from-scratch/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 by ANTLR 4.13.2 +package org.programsnail.truffle_lama.parser; + +// DO NOT MODIFY - generated from Lama.g4 + +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class LamaLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.2", 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, T__16=17, + T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, + T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, + T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, + T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, + T__45=46, WS=47, COMMENT=48, LINE_COMMENT=49, WORD=50, INFIX=51, UIDENT=52, + LIDENT=53, CHAR_LITERAL=54, STRING_LITERAL=55, DECIMAL_LITERAL=56; + 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", "T__16", + "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", + "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", + "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", + "T__41", "T__42", "T__43", "T__44", "T__45", "WS", "COMMENT", "LINE_COMMENT", + "NON_ZERO_DIGIT", "DIGIT", "STRING_CHAR", "WORD", "INFIX", "UIDENT", + "LIDENT", "CHAR_LITERAL", "STRING_LITERAL", "DECIMAL_LITERAL" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'import'", "';'", "'var'", "'public'", "','", "'='", "'fun'", + "'('", "')'", "'{'", "'}'", "'infix'", "'infixl'", "'infixr'", "'at'", + "'before'", "'after'", "'-'", "'['", "']'", "'true'", "'false'", "'skip'", + "'if'", "'then'", "'fi'", "'elif'", "'else'", "'while'", "'do'", "'od'", + "'for'", "'|'", "':'", "'@'", "'#'", "'box'", "'val'", "'str'", "'array'", + "'sexp'", "'_'", "'case'", "'of'", "'esac'", "'->'" + }; + } + 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, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, "WS", + "COMMENT", "LINE_COMMENT", "WORD", "INFIX", "UIDENT", "LIDENT", "CHAR_LITERAL", + "STRING_LITERAL", "DECIMAL_LITERAL" + }; + } + 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 LamaLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "Lama.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\u00008\u0183\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\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+ + "\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+ + "\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+ + "!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+ + "&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+ + "+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u00020\u0007"+ + "0\u00021\u00071\u00022\u00072\u00023\u00073\u00024\u00074\u00025\u0007"+ + "5\u00026\u00076\u00027\u00077\u00028\u00078\u00029\u00079\u0002:\u0007"+ + ":\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+ + "\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002"+ + "\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007"+ + "\u0001\b\u0001\b\u0001\t\u0001\t\u0001\n\u0001\n\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\f\u0001\r\u0001\r\u0001\r\u0001\r\u0001"+ + "\r\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001"+ + "\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f\u0001"+ + "\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001"+ + "\u0011\u0001\u0011\u0001\u0012\u0001\u0012\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\u0015\u0001\u0016\u0001"+ + "\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0017\u0001\u0017\u0001"+ + "\u0017\u0001\u0018\u0001\u0018\u0001\u0018\u0001\u0018\u0001\u0018\u0001"+ + "\u0019\u0001\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001"+ + "\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001"+ + "\u001b\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001"+ + "\u001c\u0001\u001d\u0001\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001"+ + "\u001e\u0001\u001f\u0001\u001f\u0001\u001f\u0001\u001f\u0001 \u0001 \u0001"+ + "!\u0001!\u0001\"\u0001\"\u0001#\u0001#\u0001$\u0001$\u0001$\u0001$\u0001"+ + "%\u0001%\u0001%\u0001%\u0001&\u0001&\u0001&\u0001&\u0001\'\u0001\'\u0001"+ + "\'\u0001\'\u0001\'\u0001\'\u0001(\u0001(\u0001(\u0001(\u0001(\u0001)\u0001"+ + ")\u0001*\u0001*\u0001*\u0001*\u0001*\u0001+\u0001+\u0001+\u0001,\u0001"+ + ",\u0001,\u0001,\u0001,\u0001-\u0001-\u0001-\u0001.\u0004.\u012d\b.\u000b"+ + ".\f.\u012e\u0001.\u0001.\u0001/\u0001/\u0001/\u0001/\u0005/\u0137\b/\n"+ + "/\f/\u013a\t/\u0001/\u0001/\u0001/\u0001/\u0001/\u00010\u00010\u00010"+ + "\u00010\u00050\u0145\b0\n0\f0\u0148\t0\u00010\u00010\u00011\u00011\u0001"+ + "2\u00012\u00013\u00013\u00014\u00044\u0153\b4\u000b4\f4\u0154\u00015\u0004"+ + "5\u0158\b5\u000b5\f5\u0159\u00016\u00016\u00056\u015e\b6\n6\f6\u0161\t"+ + "6\u00017\u00017\u00057\u0165\b7\n7\f7\u0168\t7\u00018\u00018\u00018\u0001"+ + "8\u00019\u00019\u00059\u0170\b9\n9\f9\u0173\t9\u00019\u00019\u0001:\u0001"+ + ":\u0003:\u0179\b:\u0001:\u0001:\u0005:\u017d\b:\n:\f:\u0180\t:\u0003:"+ + "\u0182\b:\u0001\u0138\u0000;\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\u00193\u001a5\u001b7\u001c9\u001d"+ + ";\u001e=\u001f? A!C\"E#G$I%K&M\'O(Q)S*U+W,Y-[.]/_0a1c\u0000e\u0000g\u0000"+ + "i2k3m4o5q6s7u8\u0001\u0000\t\u0003\u0000\t\n\f\r \u0002\u0000\n\n\r\r"+ + "\u0001\u000019\u0001\u000009\u0003\u0000\n\n\r\r\"\"\u0004\u000009AZ_"+ + "_az\b\u0000!!#&*+-/::<@^^||\u0001\u0000AZ\u0001\u0000az\u018a\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\u00003\u0001\u0000\u0000\u0000\u0000"+ + "5\u0001\u0000\u0000\u0000\u00007\u0001\u0000\u0000\u0000\u00009\u0001"+ + "\u0000\u0000\u0000\u0000;\u0001\u0000\u0000\u0000\u0000=\u0001\u0000\u0000"+ + "\u0000\u0000?\u0001\u0000\u0000\u0000\u0000A\u0001\u0000\u0000\u0000\u0000"+ + "C\u0001\u0000\u0000\u0000\u0000E\u0001\u0000\u0000\u0000\u0000G\u0001"+ + "\u0000\u0000\u0000\u0000I\u0001\u0000\u0000\u0000\u0000K\u0001\u0000\u0000"+ + "\u0000\u0000M\u0001\u0000\u0000\u0000\u0000O\u0001\u0000\u0000\u0000\u0000"+ + "Q\u0001\u0000\u0000\u0000\u0000S\u0001\u0000\u0000\u0000\u0000U\u0001"+ + "\u0000\u0000\u0000\u0000W\u0001\u0000\u0000\u0000\u0000Y\u0001\u0000\u0000"+ + "\u0000\u0000[\u0001\u0000\u0000\u0000\u0000]\u0001\u0000\u0000\u0000\u0000"+ + "_\u0001\u0000\u0000\u0000\u0000a\u0001\u0000\u0000\u0000\u0000i\u0001"+ + "\u0000\u0000\u0000\u0000k\u0001\u0000\u0000\u0000\u0000m\u0001\u0000\u0000"+ + "\u0000\u0000o\u0001\u0000\u0000\u0000\u0000q\u0001\u0000\u0000\u0000\u0000"+ + "s\u0001\u0000\u0000\u0000\u0000u\u0001\u0000\u0000\u0000\u0001w\u0001"+ + "\u0000\u0000\u0000\u0003~\u0001\u0000\u0000\u0000\u0005\u0080\u0001\u0000"+ + "\u0000\u0000\u0007\u0084\u0001\u0000\u0000\u0000\t\u008b\u0001\u0000\u0000"+ + "\u0000\u000b\u008d\u0001\u0000\u0000\u0000\r\u008f\u0001\u0000\u0000\u0000"+ + "\u000f\u0093\u0001\u0000\u0000\u0000\u0011\u0095\u0001\u0000\u0000\u0000"+ + "\u0013\u0097\u0001\u0000\u0000\u0000\u0015\u0099\u0001\u0000\u0000\u0000"+ + "\u0017\u009b\u0001\u0000\u0000\u0000\u0019\u00a1\u0001\u0000\u0000\u0000"+ + "\u001b\u00a8\u0001\u0000\u0000\u0000\u001d\u00af\u0001\u0000\u0000\u0000"+ + "\u001f\u00b2\u0001\u0000\u0000\u0000!\u00b9\u0001\u0000\u0000\u0000#\u00bf"+ + "\u0001\u0000\u0000\u0000%\u00c1\u0001\u0000\u0000\u0000\'\u00c3\u0001"+ + "\u0000\u0000\u0000)\u00c5\u0001\u0000\u0000\u0000+\u00ca\u0001\u0000\u0000"+ + "\u0000-\u00d0\u0001\u0000\u0000\u0000/\u00d5\u0001\u0000\u0000\u00001"+ + "\u00d8\u0001\u0000\u0000\u00003\u00dd\u0001\u0000\u0000\u00005\u00e0\u0001"+ + "\u0000\u0000\u00007\u00e5\u0001\u0000\u0000\u00009\u00ea\u0001\u0000\u0000"+ + "\u0000;\u00f0\u0001\u0000\u0000\u0000=\u00f3\u0001\u0000\u0000\u0000?"+ + "\u00f6\u0001\u0000\u0000\u0000A\u00fa\u0001\u0000\u0000\u0000C\u00fc\u0001"+ + "\u0000\u0000\u0000E\u00fe\u0001\u0000\u0000\u0000G\u0100\u0001\u0000\u0000"+ + "\u0000I\u0102\u0001\u0000\u0000\u0000K\u0106\u0001\u0000\u0000\u0000M"+ + "\u010a\u0001\u0000\u0000\u0000O\u010e\u0001\u0000\u0000\u0000Q\u0114\u0001"+ + "\u0000\u0000\u0000S\u0119\u0001\u0000\u0000\u0000U\u011b\u0001\u0000\u0000"+ + "\u0000W\u0120\u0001\u0000\u0000\u0000Y\u0123\u0001\u0000\u0000\u0000["+ + "\u0128\u0001\u0000\u0000\u0000]\u012c\u0001\u0000\u0000\u0000_\u0132\u0001"+ + "\u0000\u0000\u0000a\u0140\u0001\u0000\u0000\u0000c\u014b\u0001\u0000\u0000"+ + "\u0000e\u014d\u0001\u0000\u0000\u0000g\u014f\u0001\u0000\u0000\u0000i"+ + "\u0152\u0001\u0000\u0000\u0000k\u0157\u0001\u0000\u0000\u0000m\u015b\u0001"+ + "\u0000\u0000\u0000o\u0162\u0001\u0000\u0000\u0000q\u0169\u0001\u0000\u0000"+ + "\u0000s\u016d\u0001\u0000\u0000\u0000u\u0181\u0001\u0000\u0000\u0000w"+ + "x\u0005i\u0000\u0000xy\u0005m\u0000\u0000yz\u0005p\u0000\u0000z{\u0005"+ + "o\u0000\u0000{|\u0005r\u0000\u0000|}\u0005t\u0000\u0000}\u0002\u0001\u0000"+ + "\u0000\u0000~\u007f\u0005;\u0000\u0000\u007f\u0004\u0001\u0000\u0000\u0000"+ + "\u0080\u0081\u0005v\u0000\u0000\u0081\u0082\u0005a\u0000\u0000\u0082\u0083"+ + "\u0005r\u0000\u0000\u0083\u0006\u0001\u0000\u0000\u0000\u0084\u0085\u0005"+ + "p\u0000\u0000\u0085\u0086\u0005u\u0000\u0000\u0086\u0087\u0005b\u0000"+ + "\u0000\u0087\u0088\u0005l\u0000\u0000\u0088\u0089\u0005i\u0000\u0000\u0089"+ + "\u008a\u0005c\u0000\u0000\u008a\b\u0001\u0000\u0000\u0000\u008b\u008c"+ + "\u0005,\u0000\u0000\u008c\n\u0001\u0000\u0000\u0000\u008d\u008e\u0005"+ + "=\u0000\u0000\u008e\f\u0001\u0000\u0000\u0000\u008f\u0090\u0005f\u0000"+ + "\u0000\u0090\u0091\u0005u\u0000\u0000\u0091\u0092\u0005n\u0000\u0000\u0092"+ + "\u000e\u0001\u0000\u0000\u0000\u0093\u0094\u0005(\u0000\u0000\u0094\u0010"+ + "\u0001\u0000\u0000\u0000\u0095\u0096\u0005)\u0000\u0000\u0096\u0012\u0001"+ + "\u0000\u0000\u0000\u0097\u0098\u0005{\u0000\u0000\u0098\u0014\u0001\u0000"+ + "\u0000\u0000\u0099\u009a\u0005}\u0000\u0000\u009a\u0016\u0001\u0000\u0000"+ + "\u0000\u009b\u009c\u0005i\u0000\u0000\u009c\u009d\u0005n\u0000\u0000\u009d"+ + "\u009e\u0005f\u0000\u0000\u009e\u009f\u0005i\u0000\u0000\u009f\u00a0\u0005"+ + "x\u0000\u0000\u00a0\u0018\u0001\u0000\u0000\u0000\u00a1\u00a2\u0005i\u0000"+ + "\u0000\u00a2\u00a3\u0005n\u0000\u0000\u00a3\u00a4\u0005f\u0000\u0000\u00a4"+ + "\u00a5\u0005i\u0000\u0000\u00a5\u00a6\u0005x\u0000\u0000\u00a6\u00a7\u0005"+ + "l\u0000\u0000\u00a7\u001a\u0001\u0000\u0000\u0000\u00a8\u00a9\u0005i\u0000"+ + "\u0000\u00a9\u00aa\u0005n\u0000\u0000\u00aa\u00ab\u0005f\u0000\u0000\u00ab"+ + "\u00ac\u0005i\u0000\u0000\u00ac\u00ad\u0005x\u0000\u0000\u00ad\u00ae\u0005"+ + "r\u0000\u0000\u00ae\u001c\u0001\u0000\u0000\u0000\u00af\u00b0\u0005a\u0000"+ + "\u0000\u00b0\u00b1\u0005t\u0000\u0000\u00b1\u001e\u0001\u0000\u0000\u0000"+ + "\u00b2\u00b3\u0005b\u0000\u0000\u00b3\u00b4\u0005e\u0000\u0000\u00b4\u00b5"+ + "\u0005f\u0000\u0000\u00b5\u00b6\u0005o\u0000\u0000\u00b6\u00b7\u0005r"+ + "\u0000\u0000\u00b7\u00b8\u0005e\u0000\u0000\u00b8 \u0001\u0000\u0000\u0000"+ + "\u00b9\u00ba\u0005a\u0000\u0000\u00ba\u00bb\u0005f\u0000\u0000\u00bb\u00bc"+ + "\u0005t\u0000\u0000\u00bc\u00bd\u0005e\u0000\u0000\u00bd\u00be\u0005r"+ + "\u0000\u0000\u00be\"\u0001\u0000\u0000\u0000\u00bf\u00c0\u0005-\u0000"+ + "\u0000\u00c0$\u0001\u0000\u0000\u0000\u00c1\u00c2\u0005[\u0000\u0000\u00c2"+ + "&\u0001\u0000\u0000\u0000\u00c3\u00c4\u0005]\u0000\u0000\u00c4(\u0001"+ + "\u0000\u0000\u0000\u00c5\u00c6\u0005t\u0000\u0000\u00c6\u00c7\u0005r\u0000"+ + "\u0000\u00c7\u00c8\u0005u\u0000\u0000\u00c8\u00c9\u0005e\u0000\u0000\u00c9"+ + "*\u0001\u0000\u0000\u0000\u00ca\u00cb\u0005f\u0000\u0000\u00cb\u00cc\u0005"+ + "a\u0000\u0000\u00cc\u00cd\u0005l\u0000\u0000\u00cd\u00ce\u0005s\u0000"+ + "\u0000\u00ce\u00cf\u0005e\u0000\u0000\u00cf,\u0001\u0000\u0000\u0000\u00d0"+ + "\u00d1\u0005s\u0000\u0000\u00d1\u00d2\u0005k\u0000\u0000\u00d2\u00d3\u0005"+ + "i\u0000\u0000\u00d3\u00d4\u0005p\u0000\u0000\u00d4.\u0001\u0000\u0000"+ + "\u0000\u00d5\u00d6\u0005i\u0000\u0000\u00d6\u00d7\u0005f\u0000\u0000\u00d7"+ + "0\u0001\u0000\u0000\u0000\u00d8\u00d9\u0005t\u0000\u0000\u00d9\u00da\u0005"+ + "h\u0000\u0000\u00da\u00db\u0005e\u0000\u0000\u00db\u00dc\u0005n\u0000"+ + "\u0000\u00dc2\u0001\u0000\u0000\u0000\u00dd\u00de\u0005f\u0000\u0000\u00de"+ + "\u00df\u0005i\u0000\u0000\u00df4\u0001\u0000\u0000\u0000\u00e0\u00e1\u0005"+ + "e\u0000\u0000\u00e1\u00e2\u0005l\u0000\u0000\u00e2\u00e3\u0005i\u0000"+ + "\u0000\u00e3\u00e4\u0005f\u0000\u0000\u00e46\u0001\u0000\u0000\u0000\u00e5"+ + "\u00e6\u0005e\u0000\u0000\u00e6\u00e7\u0005l\u0000\u0000\u00e7\u00e8\u0005"+ + "s\u0000\u0000\u00e8\u00e9\u0005e\u0000\u0000\u00e98\u0001\u0000\u0000"+ + "\u0000\u00ea\u00eb\u0005w\u0000\u0000\u00eb\u00ec\u0005h\u0000\u0000\u00ec"+ + "\u00ed\u0005i\u0000\u0000\u00ed\u00ee\u0005l\u0000\u0000\u00ee\u00ef\u0005"+ + "e\u0000\u0000\u00ef:\u0001\u0000\u0000\u0000\u00f0\u00f1\u0005d\u0000"+ + "\u0000\u00f1\u00f2\u0005o\u0000\u0000\u00f2<\u0001\u0000\u0000\u0000\u00f3"+ + "\u00f4\u0005o\u0000\u0000\u00f4\u00f5\u0005d\u0000\u0000\u00f5>\u0001"+ + "\u0000\u0000\u0000\u00f6\u00f7\u0005f\u0000\u0000\u00f7\u00f8\u0005o\u0000"+ + "\u0000\u00f8\u00f9\u0005r\u0000\u0000\u00f9@\u0001\u0000\u0000\u0000\u00fa"+ + "\u00fb\u0005|\u0000\u0000\u00fbB\u0001\u0000\u0000\u0000\u00fc\u00fd\u0005"+ + ":\u0000\u0000\u00fdD\u0001\u0000\u0000\u0000\u00fe\u00ff\u0005@\u0000"+ + "\u0000\u00ffF\u0001\u0000\u0000\u0000\u0100\u0101\u0005#\u0000\u0000\u0101"+ + "H\u0001\u0000\u0000\u0000\u0102\u0103\u0005b\u0000\u0000\u0103\u0104\u0005"+ + "o\u0000\u0000\u0104\u0105\u0005x\u0000\u0000\u0105J\u0001\u0000\u0000"+ + "\u0000\u0106\u0107\u0005v\u0000\u0000\u0107\u0108\u0005a\u0000\u0000\u0108"+ + "\u0109\u0005l\u0000\u0000\u0109L\u0001\u0000\u0000\u0000\u010a\u010b\u0005"+ + "s\u0000\u0000\u010b\u010c\u0005t\u0000\u0000\u010c\u010d\u0005r\u0000"+ + "\u0000\u010dN\u0001\u0000\u0000\u0000\u010e\u010f\u0005a\u0000\u0000\u010f"+ + "\u0110\u0005r\u0000\u0000\u0110\u0111\u0005r\u0000\u0000\u0111\u0112\u0005"+ + "a\u0000\u0000\u0112\u0113\u0005y\u0000\u0000\u0113P\u0001\u0000\u0000"+ + "\u0000\u0114\u0115\u0005s\u0000\u0000\u0115\u0116\u0005e\u0000\u0000\u0116"+ + "\u0117\u0005x\u0000\u0000\u0117\u0118\u0005p\u0000\u0000\u0118R\u0001"+ + "\u0000\u0000\u0000\u0119\u011a\u0005_\u0000\u0000\u011aT\u0001\u0000\u0000"+ + "\u0000\u011b\u011c\u0005c\u0000\u0000\u011c\u011d\u0005a\u0000\u0000\u011d"+ + "\u011e\u0005s\u0000\u0000\u011e\u011f\u0005e\u0000\u0000\u011fV\u0001"+ + "\u0000\u0000\u0000\u0120\u0121\u0005o\u0000\u0000\u0121\u0122\u0005f\u0000"+ + "\u0000\u0122X\u0001\u0000\u0000\u0000\u0123\u0124\u0005e\u0000\u0000\u0124"+ + "\u0125\u0005s\u0000\u0000\u0125\u0126\u0005a\u0000\u0000\u0126\u0127\u0005"+ + "c\u0000\u0000\u0127Z\u0001\u0000\u0000\u0000\u0128\u0129\u0005-\u0000"+ + "\u0000\u0129\u012a\u0005>\u0000\u0000\u012a\\\u0001\u0000\u0000\u0000"+ + "\u012b\u012d\u0007\u0000\u0000\u0000\u012c\u012b\u0001\u0000\u0000\u0000"+ + "\u012d\u012e\u0001\u0000\u0000\u0000\u012e\u012c\u0001\u0000\u0000\u0000"+ + "\u012e\u012f\u0001\u0000\u0000\u0000\u012f\u0130\u0001\u0000\u0000\u0000"+ + "\u0130\u0131\u0006.\u0000\u0000\u0131^\u0001\u0000\u0000\u0000\u0132\u0133"+ + "\u0005/\u0000\u0000\u0133\u0134\u0005*\u0000\u0000\u0134\u0138\u0001\u0000"+ + "\u0000\u0000\u0135\u0137\t\u0000\u0000\u0000\u0136\u0135\u0001\u0000\u0000"+ + "\u0000\u0137\u013a\u0001\u0000\u0000\u0000\u0138\u0139\u0001\u0000\u0000"+ + "\u0000\u0138\u0136\u0001\u0000\u0000\u0000\u0139\u013b\u0001\u0000\u0000"+ + "\u0000\u013a\u0138\u0001\u0000\u0000\u0000\u013b\u013c\u0005*\u0000\u0000"+ + "\u013c\u013d\u0005/\u0000\u0000\u013d\u013e\u0001\u0000\u0000\u0000\u013e"+ + "\u013f\u0006/\u0000\u0000\u013f`\u0001\u0000\u0000\u0000\u0140\u0141\u0005"+ + "/\u0000\u0000\u0141\u0142\u0005/\u0000\u0000\u0142\u0146\u0001\u0000\u0000"+ + "\u0000\u0143\u0145\b\u0001\u0000\u0000\u0144\u0143\u0001\u0000\u0000\u0000"+ + "\u0145\u0148\u0001\u0000\u0000\u0000\u0146\u0144\u0001\u0000\u0000\u0000"+ + "\u0146\u0147\u0001\u0000\u0000\u0000\u0147\u0149\u0001\u0000\u0000\u0000"+ + "\u0148\u0146\u0001\u0000\u0000\u0000\u0149\u014a\u00060\u0000\u0000\u014a"+ + "b\u0001\u0000\u0000\u0000\u014b\u014c\u0007\u0002\u0000\u0000\u014cd\u0001"+ + "\u0000\u0000\u0000\u014d\u014e\u0007\u0003\u0000\u0000\u014ef\u0001\u0000"+ + "\u0000\u0000\u014f\u0150\b\u0004\u0000\u0000\u0150h\u0001\u0000\u0000"+ + "\u0000\u0151\u0153\u0007\u0005\u0000\u0000\u0152\u0151\u0001\u0000\u0000"+ + "\u0000\u0153\u0154\u0001\u0000\u0000\u0000\u0154\u0152\u0001\u0000\u0000"+ + "\u0000\u0154\u0155\u0001\u0000\u0000\u0000\u0155j\u0001\u0000\u0000\u0000"+ + "\u0156\u0158\u0007\u0006\u0000\u0000\u0157\u0156\u0001\u0000\u0000\u0000"+ + "\u0158\u0159\u0001\u0000\u0000\u0000\u0159\u0157\u0001\u0000\u0000\u0000"+ + "\u0159\u015a\u0001\u0000\u0000\u0000\u015al\u0001\u0000\u0000\u0000\u015b"+ + "\u015f\u0007\u0007\u0000\u0000\u015c\u015e\u0007\u0005\u0000\u0000\u015d"+ + "\u015c\u0001\u0000\u0000\u0000\u015e\u0161\u0001\u0000\u0000\u0000\u015f"+ + "\u015d\u0001\u0000\u0000\u0000\u015f\u0160\u0001\u0000\u0000\u0000\u0160"+ + "n\u0001\u0000\u0000\u0000\u0161\u015f\u0001\u0000\u0000\u0000\u0162\u0166"+ + "\u0007\b\u0000\u0000\u0163\u0165\u0007\u0005\u0000\u0000\u0164\u0163\u0001"+ + "\u0000\u0000\u0000\u0165\u0168\u0001\u0000\u0000\u0000\u0166\u0164\u0001"+ + "\u0000\u0000\u0000\u0166\u0167\u0001\u0000\u0000\u0000\u0167p\u0001\u0000"+ + "\u0000\u0000\u0168\u0166\u0001\u0000\u0000\u0000\u0169\u016a\u0005\'\u0000"+ + "\u0000\u016a\u016b\u0003g3\u0000\u016b\u016c\u0005\'\u0000\u0000\u016c"+ + "r\u0001\u0000\u0000\u0000\u016d\u0171\u0005\"\u0000\u0000\u016e\u0170"+ + "\u0003g3\u0000\u016f\u016e\u0001\u0000\u0000\u0000\u0170\u0173\u0001\u0000"+ + "\u0000\u0000\u0171\u016f\u0001\u0000\u0000\u0000\u0171\u0172\u0001\u0000"+ + "\u0000\u0000\u0172\u0174\u0001\u0000\u0000\u0000\u0173\u0171\u0001\u0000"+ + "\u0000\u0000\u0174\u0175\u0005\"\u0000\u0000\u0175t\u0001\u0000\u0000"+ + "\u0000\u0176\u0182\u00050\u0000\u0000\u0177\u0179\u0005-\u0000\u0000\u0178"+ + "\u0177\u0001\u0000\u0000\u0000\u0178\u0179\u0001\u0000\u0000\u0000\u0179"+ + "\u017a\u0001\u0000\u0000\u0000\u017a\u017e\u0003c1\u0000\u017b\u017d\u0003"+ + "e2\u0000\u017c\u017b\u0001\u0000\u0000\u0000\u017d\u0180\u0001\u0000\u0000"+ + "\u0000\u017e\u017c\u0001\u0000\u0000\u0000\u017e\u017f\u0001\u0000\u0000"+ + "\u0000\u017f\u0182\u0001\u0000\u0000\u0000\u0180\u017e\u0001\u0000\u0000"+ + "\u0000\u0181\u0176\u0001\u0000\u0000\u0000\u0181\u0178\u0001\u0000\u0000"+ + "\u0000\u0182v\u0001\u0000\u0000\u0000\f\u0000\u012e\u0138\u0146\u0154"+ + "\u0159\u015f\u0166\u0171\u0178\u017e\u0181\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/org/programsnail/truffle_lama/parser/LamaLexer.tokens b/src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.tokens new file mode 100644 index 0000000..ae67504 --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/LamaLexer.tokens @@ -0,0 +1,102 @@ +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 +T__16=17 +T__17=18 +T__18=19 +T__19=20 +T__20=21 +T__21=22 +T__22=23 +T__23=24 +T__24=25 +T__25=26 +T__26=27 +T__27=28 +T__28=29 +T__29=30 +T__30=31 +T__31=32 +T__32=33 +T__33=34 +T__34=35 +T__35=36 +T__36=37 +T__37=38 +T__38=39 +T__39=40 +T__40=41 +T__41=42 +T__42=43 +T__43=44 +T__44=45 +T__45=46 +WS=47 +COMMENT=48 +LINE_COMMENT=49 +WORD=50 +INFIX=51 +UIDENT=52 +LIDENT=53 +CHAR_LITERAL=54 +STRING_LITERAL=55 +DECIMAL_LITERAL=56 +'import'=1 +';'=2 +'var'=3 +'public'=4 +','=5 +'='=6 +'fun'=7 +'('=8 +')'=9 +'{'=10 +'}'=11 +'infix'=12 +'infixl'=13 +'infixr'=14 +'at'=15 +'before'=16 +'after'=17 +'-'=18 +'['=19 +']'=20 +'true'=21 +'false'=22 +'skip'=23 +'if'=24 +'then'=25 +'fi'=26 +'elif'=27 +'else'=28 +'while'=29 +'do'=30 +'od'=31 +'for'=32 +'|'=33 +':'=34 +'@'=35 +'#'=36 +'box'=37 +'val'=38 +'str'=39 +'array'=40 +'sexp'=41 +'_'=42 +'case'=43 +'of'=44 +'esac'=45 +'->'=46 diff --git a/src/main/java/org/programsnail/truffle_lama/parser/LamaListener.java b/src/main/java/org/programsnail/truffle_lama/parser/LamaListener.java new file mode 100644 index 0000000..e326e5e --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/LamaListener.java @@ -0,0 +1,390 @@ +// Generated from /home/dragon/Containers/DevGraalVM/src/truffle-lama-from-scratch/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 by ANTLR 4.13.2 +package org.programsnail.truffle_lama.parser; +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link LamaParser}. + */ +public interface LamaListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link LamaParser#lama}. + * @param ctx the parse tree + */ + void enterLama(LamaParser.LamaContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#lama}. + * @param ctx the parse tree + */ + void exitLama(LamaParser.LamaContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#import_expression}. + * @param ctx the parse tree + */ + void enterImport_expression(LamaParser.Import_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#import_expression}. + * @param ctx the parse tree + */ + void exitImport_expression(LamaParser.Import_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#scope_expression}. + * @param ctx the parse tree + */ + void enterScope_expression(LamaParser.Scope_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#scope_expression}. + * @param ctx the parse tree + */ + void exitScope_expression(LamaParser.Scope_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#definition}. + * @param ctx the parse tree + */ + void enterDefinition(LamaParser.DefinitionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#definition}. + * @param ctx the parse tree + */ + void exitDefinition(LamaParser.DefinitionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#variable_definition}. + * @param ctx the parse tree + */ + void enterVariable_definition(LamaParser.Variable_definitionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#variable_definition}. + * @param ctx the parse tree + */ + void exitVariable_definition(LamaParser.Variable_definitionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#variable_definition_sequence}. + * @param ctx the parse tree + */ + void enterVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#variable_definition_sequence}. + * @param ctx the parse tree + */ + void exitVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#variable_definition_item}. + * @param ctx the parse tree + */ + void enterVariable_definition_item(LamaParser.Variable_definition_itemContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#variable_definition_item}. + * @param ctx the parse tree + */ + void exitVariable_definition_item(LamaParser.Variable_definition_itemContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#function_definition}. + * @param ctx the parse tree + */ + void enterFunction_definition(LamaParser.Function_definitionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#function_definition}. + * @param ctx the parse tree + */ + void exitFunction_definition(LamaParser.Function_definitionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#function_arguments}. + * @param ctx the parse tree + */ + void enterFunction_arguments(LamaParser.Function_argumentsContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#function_arguments}. + * @param ctx the parse tree + */ + void exitFunction_arguments(LamaParser.Function_argumentsContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#function_body}. + * @param ctx the parse tree + */ + void enterFunction_body(LamaParser.Function_bodyContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#function_body}. + * @param ctx the parse tree + */ + void exitFunction_body(LamaParser.Function_bodyContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#infix_definition}. + * @param ctx the parse tree + */ + void enterInfix_definition(LamaParser.Infix_definitionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#infix_definition}. + * @param ctx the parse tree + */ + void exitInfix_definition(LamaParser.Infix_definitionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#infix_head}. + * @param ctx the parse tree + */ + void enterInfix_head(LamaParser.Infix_headContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#infix_head}. + * @param ctx the parse tree + */ + void exitInfix_head(LamaParser.Infix_headContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#infixity}. + * @param ctx the parse tree + */ + void enterInfixity(LamaParser.InfixityContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#infixity}. + * @param ctx the parse tree + */ + void exitInfixity(LamaParser.InfixityContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#level}. + * @param ctx the parse tree + */ + void enterLevel(LamaParser.LevelContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#level}. + * @param ctx the parse tree + */ + void exitLevel(LamaParser.LevelContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#expression}. + * @param ctx the parse tree + */ + void enterExpression(LamaParser.ExpressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#expression}. + * @param ctx the parse tree + */ + void exitExpression(LamaParser.ExpressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#basic_expression}. + * @param ctx the parse tree + */ + void enterBasic_expression(LamaParser.Basic_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#basic_expression}. + * @param ctx the parse tree + */ + void exitBasic_expression(LamaParser.Basic_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#binary_expression}. + * @param ctx the parse tree + */ + void enterBinary_expression(LamaParser.Binary_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#binary_expression}. + * @param ctx the parse tree + */ + void exitBinary_expression(LamaParser.Binary_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#postfix_expression}. + * @param ctx the parse tree + */ + void enterPostfix_expression(LamaParser.Postfix_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#postfix_expression}. + * @param ctx the parse tree + */ + void exitPostfix_expression(LamaParser.Postfix_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#postfix}. + * @param ctx the parse tree + */ + void enterPostfix(LamaParser.PostfixContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#postfix}. + * @param ctx the parse tree + */ + void exitPostfix(LamaParser.PostfixContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#primary}. + * @param ctx the parse tree + */ + void enterPrimary(LamaParser.PrimaryContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#primary}. + * @param ctx the parse tree + */ + void exitPrimary(LamaParser.PrimaryContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#array_expression}. + * @param ctx the parse tree + */ + void enterArray_expression(LamaParser.Array_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#array_expression}. + * @param ctx the parse tree + */ + void exitArray_expression(LamaParser.Array_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#list_expression}. + * @param ctx the parse tree + */ + void enterList_expression(LamaParser.List_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#list_expression}. + * @param ctx the parse tree + */ + void exitList_expression(LamaParser.List_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#s_expression}. + * @param ctx the parse tree + */ + void enterS_expression(LamaParser.S_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#s_expression}. + * @param ctx the parse tree + */ + void exitS_expression(LamaParser.S_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#if_expression}. + * @param ctx the parse tree + */ + void enterIf_expression(LamaParser.If_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#if_expression}. + * @param ctx the parse tree + */ + void exitIf_expression(LamaParser.If_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#else_part}. + * @param ctx the parse tree + */ + void enterElse_part(LamaParser.Else_partContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#else_part}. + * @param ctx the parse tree + */ + void exitElse_part(LamaParser.Else_partContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#while_do_expression}. + * @param ctx the parse tree + */ + void enterWhile_do_expression(LamaParser.While_do_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#while_do_expression}. + * @param ctx the parse tree + */ + void exitWhile_do_expression(LamaParser.While_do_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#do_while_expression}. + * @param ctx the parse tree + */ + void enterDo_while_expression(LamaParser.Do_while_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#do_while_expression}. + * @param ctx the parse tree + */ + void exitDo_while_expression(LamaParser.Do_while_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#for_expression}. + * @param ctx the parse tree + */ + void enterFor_expression(LamaParser.For_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#for_expression}. + * @param ctx the parse tree + */ + void exitFor_expression(LamaParser.For_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#pattern}. + * @param ctx the parse tree + */ + void enterPattern(LamaParser.PatternContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#pattern}. + * @param ctx the parse tree + */ + void exitPattern(LamaParser.PatternContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#cons_pattern}. + * @param ctx the parse tree + */ + void enterCons_pattern(LamaParser.Cons_patternContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#cons_pattern}. + * @param ctx the parse tree + */ + void exitCons_pattern(LamaParser.Cons_patternContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#simple_pattern}. + * @param ctx the parse tree + */ + void enterSimple_pattern(LamaParser.Simple_patternContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#simple_pattern}. + * @param ctx the parse tree + */ + void exitSimple_pattern(LamaParser.Simple_patternContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#wildcard_pattern}. + * @param ctx the parse tree + */ + void enterWildcard_pattern(LamaParser.Wildcard_patternContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#wildcard_pattern}. + * @param ctx the parse tree + */ + void exitWildcard_pattern(LamaParser.Wildcard_patternContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#s_expr_pattern}. + * @param ctx the parse tree + */ + void enterS_expr_pattern(LamaParser.S_expr_patternContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#s_expr_pattern}. + * @param ctx the parse tree + */ + void exitS_expr_pattern(LamaParser.S_expr_patternContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#array_pattern}. + * @param ctx the parse tree + */ + void enterArray_pattern(LamaParser.Array_patternContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#array_pattern}. + * @param ctx the parse tree + */ + void exitArray_pattern(LamaParser.Array_patternContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#list_pattern}. + * @param ctx the parse tree + */ + void enterList_pattern(LamaParser.List_patternContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#list_pattern}. + * @param ctx the parse tree + */ + void exitList_pattern(LamaParser.List_patternContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#case_expression}. + * @param ctx the parse tree + */ + void enterCase_expression(LamaParser.Case_expressionContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#case_expression}. + * @param ctx the parse tree + */ + void exitCase_expression(LamaParser.Case_expressionContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#case_branches}. + * @param ctx the parse tree + */ + void enterCase_branches(LamaParser.Case_branchesContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#case_branches}. + * @param ctx the parse tree + */ + void exitCase_branches(LamaParser.Case_branchesContext ctx); + /** + * Enter a parse tree produced by {@link LamaParser#case_branch}. + * @param ctx the parse tree + */ + void enterCase_branch(LamaParser.Case_branchContext ctx); + /** + * Exit a parse tree produced by {@link LamaParser#case_branch}. + * @param ctx the parse tree + */ + void exitCase_branch(LamaParser.Case_branchContext ctx); +} \ No newline at end of file diff --git a/src/main/java/org/programsnail/truffle_lama/parser/LamaParser.java b/src/main/java/org/programsnail/truffle_lama/parser/LamaParser.java new file mode 100644 index 0000000..38a0a1d --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/LamaParser.java @@ -0,0 +1,3268 @@ +// Generated from /home/dragon/Containers/DevGraalVM/src/truffle-lama-from-scratch/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 by ANTLR 4.13.2 +package org.programsnail.truffle_lama.parser; + +// DO NOT MODIFY - generated from Lama.g4 + +import java.util.List; +import java.util.Map; + +import com.oracle.truffle.api.RootCallTarget; +import com.oracle.truffle.api.source.Source; +import com.oracle.truffle.api.strings.TruffleString; +import org.programsnail.truffle_lama.LamaLanguage; +import org.programsnail.truffle_lama.nodes.LamaExpressionNode; +import org.programsnail.truffle_lama.nodes.LamaStatementNode; + +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.tree.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class LamaParser extends Parser { + static { RuntimeMetaData.checkVersion("4.13.2", 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, T__16=17, + T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, + T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, + T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, + T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, + T__45=46, WS=47, COMMENT=48, LINE_COMMENT=49, WORD=50, INFIX=51, UIDENT=52, + LIDENT=53, CHAR_LITERAL=54, STRING_LITERAL=55, DECIMAL_LITERAL=56; + public static final int + RULE_lama = 0, RULE_import_expression = 1, RULE_scope_expression = 2, + RULE_definition = 3, RULE_variable_definition = 4, RULE_variable_definition_sequence = 5, + RULE_variable_definition_item = 6, RULE_function_definition = 7, RULE_function_arguments = 8, + RULE_function_body = 9, RULE_infix_definition = 10, RULE_infix_head = 11, + RULE_infixity = 12, RULE_level = 13, RULE_expression = 14, RULE_basic_expression = 15, + RULE_binary_expression = 16, RULE_postfix_expression = 17, RULE_postfix = 18, + RULE_primary = 19, RULE_array_expression = 20, RULE_list_expression = 21, + RULE_s_expression = 22, RULE_if_expression = 23, RULE_else_part = 24, + RULE_while_do_expression = 25, RULE_do_while_expression = 26, RULE_for_expression = 27, + RULE_pattern = 28, RULE_cons_pattern = 29, RULE_simple_pattern = 30, RULE_wildcard_pattern = 31, + RULE_s_expr_pattern = 32, RULE_array_pattern = 33, RULE_list_pattern = 34, + RULE_case_expression = 35, RULE_case_branches = 36, RULE_case_branch = 37; + private static String[] makeRuleNames() { + return new String[] { + "lama", "import_expression", "scope_expression", "definition", "variable_definition", + "variable_definition_sequence", "variable_definition_item", "function_definition", + "function_arguments", "function_body", "infix_definition", "infix_head", + "infixity", "level", "expression", "basic_expression", "binary_expression", + "postfix_expression", "postfix", "primary", "array_expression", "list_expression", + "s_expression", "if_expression", "else_part", "while_do_expression", + "do_while_expression", "for_expression", "pattern", "cons_pattern", "simple_pattern", + "wildcard_pattern", "s_expr_pattern", "array_pattern", "list_pattern", + "case_expression", "case_branches", "case_branch" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'import'", "';'", "'var'", "'public'", "','", "'='", "'fun'", + "'('", "')'", "'{'", "'}'", "'infix'", "'infixl'", "'infixr'", "'at'", + "'before'", "'after'", "'-'", "'['", "']'", "'true'", "'false'", "'skip'", + "'if'", "'then'", "'fi'", "'elif'", "'else'", "'while'", "'do'", "'od'", + "'for'", "'|'", "':'", "'@'", "'#'", "'box'", "'val'", "'str'", "'array'", + "'sexp'", "'_'", "'case'", "'of'", "'esac'", "'->'" + }; + } + 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, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, "WS", + "COMMENT", "LINE_COMMENT", "WORD", "INFIX", "UIDENT", "LIDENT", "CHAR_LITERAL", + "STRING_LITERAL", "DECIMAL_LITERAL" + }; + } + 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 "Lama.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + + private LamaNodeFactory factory; + private Source source; + + private static final class BailoutErrorListener extends BaseErrorListener { + private final Source source; + BailoutErrorListener(Source source) { + this.source = source; + } + @Override + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { + throwParseError(source, line, charPositionInLine, (Token) offendingSymbol, msg); + } + } + + public void SemErr(Token token, String message) { + assert token != null; + throwParseError(source, token.getLine(), token.getCharPositionInLine(), token, message); + } + + private static void throwParseError(Source source, int line, int charPositionInLine, Token token, String message) { + int col = charPositionInLine + 1; + String location = "-- line " + line + " col " + col + ": "; + int length = token == null ? 1 : Math.max(token.getStopIndex() - token.getStartIndex(), 0); + throw new SLParseError(source, line, col, length, String.format("Error(s) parsing script:%n" + location + message)); + } + + public static Map parseLama(LamaLanguage language, Source source) { + LamaLexer lexer = new LamamLexer(CharStreams.fromString(source.getCharacters().toString())); + LamaParser parser = new LamaParser(new CommonTokenStream(lexer)); + lexer.removeErrorListeners(); + parser.removeErrorListeners(); + BailoutErrorListener listener = new BailoutErrorListener(source); + lexer.addErrorListener(listener); + parser.addErrorListener(listener); + parser.factory = new LamaNodeFactory(language, source); + parser.source = source; + parser.lama(); + return parser.factory.getAllFunctions(); + } + + public LamaParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class LamaContext extends ParserRuleContext { + public Scope_expressionContext scope_expression() { + return getRuleContext(Scope_expressionContext.class,0); + } + public TerminalNode EOF() { return getToken(LamaParser.EOF, 0); } + public List import_expression() { + return getRuleContexts(Import_expressionContext.class); + } + public Import_expressionContext import_expression(int i) { + return getRuleContext(Import_expressionContext.class,i); + } + public LamaContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_lama; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterLama(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitLama(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitLama(this); + else return visitor.visitChildren(this); + } + } + + public final LamaContext lama() throws RecognitionException { + LamaContext _localctx = new LamaContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_lama); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(79); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__0) { + { + { + setState(76); + import_expression(); + } + } + setState(81); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(82); + scope_expression(); + setState(83); + match(EOF); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Import_expressionContext extends ParserRuleContext { + public TerminalNode UIDENT() { return getToken(LamaParser.UIDENT, 0); } + public Import_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_import_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterImport_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitImport_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitImport_expression(this); + else return visitor.visitChildren(this); + } + } + + public final Import_expressionContext import_expression() throws RecognitionException { + Import_expressionContext _localctx = new Import_expressionContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_import_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(85); + match(T__0); + setState(86); + match(UIDENT); + setState(87); + match(T__1); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Scope_expressionContext extends ParserRuleContext { + public List definition() { + return getRuleContexts(DefinitionContext.class); + } + public DefinitionContext definition(int i) { + return getRuleContext(DefinitionContext.class,i); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public Scope_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_scope_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterScope_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitScope_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitScope_expression(this); + else return visitor.visitChildren(this); + } + } + + public final Scope_expressionContext scope_expression() throws RecognitionException { + Scope_expressionContext _localctx = new Scope_expressionContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_scope_expression); + try { + int _alt; + setState(98); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(90); + _errHandler.sync(this); + _alt = 1; + do { + switch (_alt) { + case 1: + { + { + setState(89); + definition(); + } + } + break; + default: + throw new NoViableAltException(this); + } + setState(92); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,1,_ctx); + } while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); + setState(95); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) { + case 1: + { + setState(94); + expression(); + } + break; + } + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(97); + expression(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class DefinitionContext extends ParserRuleContext { + public Variable_definitionContext variable_definition() { + return getRuleContext(Variable_definitionContext.class,0); + } + public Function_definitionContext function_definition() { + return getRuleContext(Function_definitionContext.class,0); + } + public Infix_definitionContext infix_definition() { + return getRuleContext(Infix_definitionContext.class,0); + } + public DefinitionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_definition; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterDefinition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitDefinition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitDefinition(this); + else return visitor.visitChildren(this); + } + } + + public final DefinitionContext definition() throws RecognitionException { + DefinitionContext _localctx = new DefinitionContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_definition); + try { + setState(103); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(100); + variable_definition(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(101); + function_definition(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(102); + infix_definition(); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Variable_definitionContext extends ParserRuleContext { + public Variable_definition_sequenceContext variable_definition_sequence() { + return getRuleContext(Variable_definition_sequenceContext.class,0); + } + public Variable_definitionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_variable_definition; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterVariable_definition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitVariable_definition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitVariable_definition(this); + else return visitor.visitChildren(this); + } + } + + public final Variable_definitionContext variable_definition() throws RecognitionException { + Variable_definitionContext _localctx = new Variable_definitionContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_variable_definition); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(105); + _la = _input.LA(1); + if ( !(_la==T__2 || _la==T__3) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(106); + variable_definition_sequence(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Variable_definition_sequenceContext extends ParserRuleContext { + public List variable_definition_item() { + return getRuleContexts(Variable_definition_itemContext.class); + } + public Variable_definition_itemContext variable_definition_item(int i) { + return getRuleContext(Variable_definition_itemContext.class,i); + } + public Variable_definition_sequenceContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_variable_definition_sequence; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterVariable_definition_sequence(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitVariable_definition_sequence(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitVariable_definition_sequence(this); + else return visitor.visitChildren(this); + } + } + + public final Variable_definition_sequenceContext variable_definition_sequence() throws RecognitionException { + Variable_definition_sequenceContext _localctx = new Variable_definition_sequenceContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_variable_definition_sequence); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(108); + variable_definition_item(); + setState(113); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(109); + match(T__4); + setState(110); + variable_definition_item(); + } + } + setState(115); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(116); + match(T__1); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Variable_definition_itemContext extends ParserRuleContext { + public TerminalNode LIDENT() { return getToken(LamaParser.LIDENT, 0); } + public Basic_expressionContext basic_expression() { + return getRuleContext(Basic_expressionContext.class,0); + } + public Variable_definition_itemContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_variable_definition_item; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterVariable_definition_item(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitVariable_definition_item(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitVariable_definition_item(this); + else return visitor.visitChildren(this); + } + } + + public final Variable_definition_itemContext variable_definition_item() throws RecognitionException { + Variable_definition_itemContext _localctx = new Variable_definition_itemContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_variable_definition_item); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(118); + match(LIDENT); + setState(121); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__5) { + { + setState(119); + match(T__5); + setState(120); + basic_expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Function_definitionContext extends ParserRuleContext { + public TerminalNode LIDENT() { return getToken(LamaParser.LIDENT, 0); } + public Function_bodyContext function_body() { + return getRuleContext(Function_bodyContext.class,0); + } + public Function_argumentsContext function_arguments() { + return getRuleContext(Function_argumentsContext.class,0); + } + public Function_definitionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_function_definition; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterFunction_definition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitFunction_definition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitFunction_definition(this); + else return visitor.visitChildren(this); + } + } + + public final Function_definitionContext function_definition() throws RecognitionException { + Function_definitionContext _localctx = new Function_definitionContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_function_definition); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(124); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__3) { + { + setState(123); + match(T__3); + } + } + + setState(126); + match(T__6); + setState(127); + match(LIDENT); + setState(128); + match(T__7); + setState(130); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==LIDENT) { + { + setState(129); + function_arguments(); + } + } + + setState(132); + match(T__8); + setState(133); + function_body(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Function_argumentsContext extends ParserRuleContext { + public List LIDENT() { return getTokens(LamaParser.LIDENT); } + public TerminalNode LIDENT(int i) { + return getToken(LamaParser.LIDENT, i); + } + public Function_argumentsContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_function_arguments; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterFunction_arguments(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitFunction_arguments(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitFunction_arguments(this); + else return visitor.visitChildren(this); + } + } + + public final Function_argumentsContext function_arguments() throws RecognitionException { + Function_argumentsContext _localctx = new Function_argumentsContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_function_arguments); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(135); + match(LIDENT); + setState(140); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(136); + match(T__4); + setState(137); + match(LIDENT); + } + } + setState(142); + _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 Function_bodyContext extends ParserRuleContext { + public Scope_expressionContext scope_expression() { + return getRuleContext(Scope_expressionContext.class,0); + } + public Function_bodyContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_function_body; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterFunction_body(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitFunction_body(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitFunction_body(this); + else return visitor.visitChildren(this); + } + } + + public final Function_bodyContext function_body() throws RecognitionException { + Function_bodyContext _localctx = new Function_bodyContext(_ctx, getState()); + enterRule(_localctx, 18, RULE_function_body); + try { + enterOuterAlt(_localctx, 1); + { + setState(143); + match(T__9); + setState(144); + scope_expression(); + setState(145); + match(T__10); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Infix_definitionContext extends ParserRuleContext { + public Infix_headContext infix_head() { + return getRuleContext(Infix_headContext.class,0); + } + public Function_argumentsContext function_arguments() { + return getRuleContext(Function_argumentsContext.class,0); + } + public Function_bodyContext function_body() { + return getRuleContext(Function_bodyContext.class,0); + } + public Infix_definitionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_infix_definition; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterInfix_definition(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitInfix_definition(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitInfix_definition(this); + else return visitor.visitChildren(this); + } + } + + public final Infix_definitionContext infix_definition() throws RecognitionException { + Infix_definitionContext _localctx = new Infix_definitionContext(_ctx, getState()); + enterRule(_localctx, 20, RULE_infix_definition); + try { + enterOuterAlt(_localctx, 1); + { + setState(147); + infix_head(); + setState(148); + match(T__7); + setState(149); + function_arguments(); + setState(150); + match(T__8); + setState(151); + function_body(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Infix_headContext extends ParserRuleContext { + public InfixityContext infixity() { + return getRuleContext(InfixityContext.class,0); + } + public TerminalNode INFIX() { return getToken(LamaParser.INFIX, 0); } + public LevelContext level() { + return getRuleContext(LevelContext.class,0); + } + public Infix_headContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_infix_head; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterInfix_head(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitInfix_head(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitInfix_head(this); + else return visitor.visitChildren(this); + } + } + + public final Infix_headContext infix_head() throws RecognitionException { + Infix_headContext _localctx = new Infix_headContext(_ctx, getState()); + enterRule(_localctx, 22, RULE_infix_head); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(154); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__3) { + { + setState(153); + match(T__3); + } + } + + setState(156); + infixity(); + setState(157); + match(INFIX); + setState(158); + level(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class InfixityContext extends ParserRuleContext { + public InfixityContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_infixity; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterInfixity(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitInfixity(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitInfixity(this); + else return visitor.visitChildren(this); + } + } + + public final InfixityContext infixity() throws RecognitionException { + InfixityContext _localctx = new InfixityContext(_ctx, getState()); + enterRule(_localctx, 24, RULE_infixity); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(160); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 28672L) != 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 LevelContext extends ParserRuleContext { + public TerminalNode INFIX() { return getToken(LamaParser.INFIX, 0); } + public LevelContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_level; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterLevel(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitLevel(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitLevel(this); + else return visitor.visitChildren(this); + } + } + + public final LevelContext level() throws RecognitionException { + LevelContext _localctx = new LevelContext(_ctx, getState()); + enterRule(_localctx, 26, RULE_level); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(162); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 229376L) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(163); + match(INFIX); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ExpressionContext extends ParserRuleContext { + public SLExpressionNode result; + public Basic_expressionContext basic_expression() { + return getRuleContext(Basic_expressionContext.class,0); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitExpression(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionContext expression() throws RecognitionException { + ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); + enterRule(_localctx, 28, RULE_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(165); + basic_expression(); + setState(168); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__1) { + { + setState(166); + match(T__1); + setState(167); + expression(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Basic_expressionContext extends ParserRuleContext { + public SLExpressionNode result; + public Binary_expressionContext binary_expression() { + return getRuleContext(Binary_expressionContext.class,0); + } + public Basic_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_basic_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterBasic_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitBasic_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitBasic_expression(this); + else return visitor.visitChildren(this); + } + } + + public final Basic_expressionContext basic_expression() throws RecognitionException { + Basic_expressionContext _localctx = new Basic_expressionContext(_ctx, getState()); + enterRule(_localctx, 30, RULE_basic_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(170); + binary_expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Binary_expressionContext extends ParserRuleContext { + public SLExpressionNode result; + public List postfix_expression() { + return getRuleContexts(Postfix_expressionContext.class); + } + public Postfix_expressionContext postfix_expression(int i) { + return getRuleContext(Postfix_expressionContext.class,i); + } + public List INFIX() { return getTokens(LamaParser.INFIX); } + public TerminalNode INFIX(int i) { + return getToken(LamaParser.INFIX, i); + } + public Binary_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_binary_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterBinary_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitBinary_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitBinary_expression(this); + else return visitor.visitChildren(this); + } + } + + public final Binary_expressionContext binary_expression() throws RecognitionException { + Binary_expressionContext _localctx = new Binary_expressionContext(_ctx, getState()); + enterRule(_localctx, 32, RULE_binary_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(172); + postfix_expression(); + setState(177); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==INFIX) { + { + { + setState(173); + match(INFIX); + setState(174); + postfix_expression(); + } + } + setState(179); + _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 Postfix_expressionContext extends ParserRuleContext { + public SLExpressionNode result; + public PrimaryContext primary() { + return getRuleContext(PrimaryContext.class,0); + } + public List postfix() { + return getRuleContexts(PostfixContext.class); + } + public PostfixContext postfix(int i) { + return getRuleContext(PostfixContext.class,i); + } + public Postfix_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_postfix_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterPostfix_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitPostfix_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitPostfix_expression(this); + else return visitor.visitChildren(this); + } + } + + public final Postfix_expressionContext postfix_expression() throws RecognitionException { + Postfix_expressionContext _localctx = new Postfix_expressionContext(_ctx, getState()); + enterRule(_localctx, 34, RULE_postfix_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(181); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__17) { + { + setState(180); + match(T__17); + } + } + + setState(183); + primary(); + setState(187); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__7 || _la==T__18) { + { + { + setState(184); + postfix(); + } + } + setState(189); + _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 PostfixContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public PostfixContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_postfix; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterPostfix(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitPostfix(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitPostfix(this); + else return visitor.visitChildren(this); + } + } + + public final PostfixContext postfix() throws RecognitionException { + PostfixContext _localctx = new PostfixContext(_ctx, getState()); + enterRule(_localctx, 36, RULE_postfix); + int _la; + try { + setState(205); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__7: + enterOuterAlt(_localctx, 1); + { + setState(190); + match(T__7); + setState(191); + expression(); + setState(196); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(192); + match(T__4); + setState(193); + expression(); + } + } + setState(198); + _errHandler.sync(this); + _la = _input.LA(1); + } + setState(199); + match(T__8); + } + break; + case T__18: + enterOuterAlt(_localctx, 2); + { + setState(201); + match(T__18); + setState(202); + expression(); + setState(203); + match(T__19); + } + 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 PrimaryContext extends ParserRuleContext { + public SLExpressionNode result; + public TerminalNode DECIMAL_LITERAL() { return getToken(LamaParser.DECIMAL_LITERAL, 0); } + public TerminalNode STRING_LITERAL() { return getToken(LamaParser.STRING_LITERAL, 0); } + public TerminalNode CHAR_LITERAL() { return getToken(LamaParser.CHAR_LITERAL, 0); } + public TerminalNode LIDENT() { return getToken(LamaParser.LIDENT, 0); } + public TerminalNode INFIX() { return getToken(LamaParser.INFIX, 0); } + public Function_argumentsContext function_arguments() { + return getRuleContext(Function_argumentsContext.class,0); + } + public Function_bodyContext function_body() { + return getRuleContext(Function_bodyContext.class,0); + } + public Scope_expressionContext scope_expression() { + return getRuleContext(Scope_expressionContext.class,0); + } + public List_expressionContext list_expression() { + return getRuleContext(List_expressionContext.class,0); + } + public Array_expressionContext array_expression() { + return getRuleContext(Array_expressionContext.class,0); + } + public S_expressionContext s_expression() { + return getRuleContext(S_expressionContext.class,0); + } + public If_expressionContext if_expression() { + return getRuleContext(If_expressionContext.class,0); + } + public While_do_expressionContext while_do_expression() { + return getRuleContext(While_do_expressionContext.class,0); + } + public Do_while_expressionContext do_while_expression() { + return getRuleContext(Do_while_expressionContext.class,0); + } + public For_expressionContext for_expression() { + return getRuleContext(For_expressionContext.class,0); + } + public Case_expressionContext case_expression() { + return getRuleContext(Case_expressionContext.class,0); + } + public PrimaryContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_primary; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterPrimary(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitPrimary(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitPrimary(this); + else return visitor.visitChildren(this); + } + } + + public final PrimaryContext primary() throws RecognitionException { + PrimaryContext _localctx = new PrimaryContext(_ctx, getState()); + enterRule(_localctx, 38, RULE_primary); + try { + setState(234); + _errHandler.sync(this); + switch (_input.LA(1)) { + case DECIMAL_LITERAL: + enterOuterAlt(_localctx, 1); + { + setState(207); + match(DECIMAL_LITERAL); + } + break; + case STRING_LITERAL: + enterOuterAlt(_localctx, 2); + { + setState(208); + match(STRING_LITERAL); + } + break; + case CHAR_LITERAL: + enterOuterAlt(_localctx, 3); + { + setState(209); + match(CHAR_LITERAL); + } + break; + case LIDENT: + enterOuterAlt(_localctx, 4); + { + setState(210); + match(LIDENT); + } + break; + case T__20: + enterOuterAlt(_localctx, 5); + { + setState(211); + match(T__20); + } + break; + case T__21: + enterOuterAlt(_localctx, 6); + { + setState(212); + match(T__21); + } + break; + case T__11: + enterOuterAlt(_localctx, 7); + { + setState(213); + match(T__11); + setState(214); + match(INFIX); + } + break; + case T__6: + enterOuterAlt(_localctx, 8); + { + setState(215); + match(T__6); + setState(216); + match(T__7); + setState(217); + function_arguments(); + setState(218); + match(T__8); + setState(219); + function_body(); + } + break; + case T__22: + enterOuterAlt(_localctx, 9); + { + setState(221); + match(T__22); + } + break; + case T__7: + enterOuterAlt(_localctx, 10); + { + setState(222); + match(T__7); + setState(223); + scope_expression(); + setState(224); + match(T__8); + } + break; + case T__9: + enterOuterAlt(_localctx, 11); + { + setState(226); + list_expression(); + } + break; + case T__18: + enterOuterAlt(_localctx, 12); + { + setState(227); + array_expression(); + } + break; + case UIDENT: + enterOuterAlt(_localctx, 13); + { + setState(228); + s_expression(); + } + break; + case T__23: + enterOuterAlt(_localctx, 14); + { + setState(229); + if_expression(); + } + break; + case T__28: + enterOuterAlt(_localctx, 15); + { + setState(230); + while_do_expression(); + } + break; + case T__29: + enterOuterAlt(_localctx, 16); + { + setState(231); + do_while_expression(); + } + break; + case T__31: + enterOuterAlt(_localctx, 17); + { + setState(232); + for_expression(); + } + break; + case T__42: + enterOuterAlt(_localctx, 18); + { + setState(233); + case_expression(); + } + 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 Array_expressionContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public Array_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_array_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterArray_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitArray_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitArray_expression(this); + else return visitor.visitChildren(this); + } + } + + public final Array_expressionContext array_expression() throws RecognitionException { + Array_expressionContext _localctx = new Array_expressionContext(_ctx, getState()); + enterRule(_localctx, 40, RULE_array_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(236); + match(T__18); + setState(245); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 139620390479336832L) != 0)) { + { + setState(237); + expression(); + setState(242); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(238); + match(T__4); + setState(239); + expression(); + } + } + setState(244); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(247); + match(T__19); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class List_expressionContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public List_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_list_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterList_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitList_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitList_expression(this); + else return visitor.visitChildren(this); + } + } + + public final List_expressionContext list_expression() throws RecognitionException { + List_expressionContext _localctx = new List_expressionContext(_ctx, getState()); + enterRule(_localctx, 42, RULE_list_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(249); + match(T__9); + setState(258); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 139620390479336832L) != 0)) { + { + setState(250); + expression(); + setState(255); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(251); + match(T__4); + setState(252); + expression(); + } + } + setState(257); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(260); + match(T__10); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class S_expressionContext extends ParserRuleContext { + public TerminalNode UIDENT() { return getToken(LamaParser.UIDENT, 0); } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public S_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_s_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterS_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitS_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitS_expression(this); + else return visitor.visitChildren(this); + } + } + + public final S_expressionContext s_expression() throws RecognitionException { + S_expressionContext _localctx = new S_expressionContext(_ctx, getState()); + enterRule(_localctx, 44, RULE_s_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(262); + match(UIDENT); + setState(275); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,24,_ctx) ) { + case 1: + { + setState(263); + match(T__7); + setState(272); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 139620390479336832L) != 0)) { + { + setState(264); + expression(); + setState(269); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(265); + match(T__4); + setState(266); + expression(); + } + } + setState(271); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(274); + match(T__8); + } + break; + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class If_expressionContext extends ParserRuleContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public Scope_expressionContext scope_expression() { + return getRuleContext(Scope_expressionContext.class,0); + } + public Else_partContext else_part() { + return getRuleContext(Else_partContext.class,0); + } + public If_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_if_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterIf_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitIf_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitIf_expression(this); + else return visitor.visitChildren(this); + } + } + + public final If_expressionContext if_expression() throws RecognitionException { + If_expressionContext _localctx = new If_expressionContext(_ctx, getState()); + enterRule(_localctx, 46, RULE_if_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(277); + match(T__23); + setState(278); + expression(); + setState(279); + match(T__24); + setState(280); + scope_expression(); + setState(282); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__26 || _la==T__27) { + { + setState(281); + else_part(); + } + } + + setState(284); + match(T__25); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Else_partContext extends ParserRuleContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public Scope_expressionContext scope_expression() { + return getRuleContext(Scope_expressionContext.class,0); + } + public Else_partContext else_part() { + return getRuleContext(Else_partContext.class,0); + } + public Else_partContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_else_part; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterElse_part(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitElse_part(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitElse_part(this); + else return visitor.visitChildren(this); + } + } + + public final Else_partContext else_part() throws RecognitionException { + Else_partContext _localctx = new Else_partContext(_ctx, getState()); + enterRule(_localctx, 48, RULE_else_part); + int _la; + try { + setState(295); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__26: + enterOuterAlt(_localctx, 1); + { + setState(286); + match(T__26); + setState(287); + expression(); + setState(288); + match(T__24); + setState(289); + scope_expression(); + setState(291); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__26 || _la==T__27) { + { + setState(290); + else_part(); + } + } + + } + break; + case T__27: + enterOuterAlt(_localctx, 2); + { + setState(293); + match(T__27); + setState(294); + scope_expression(); + } + 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 While_do_expressionContext extends ParserRuleContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public Scope_expressionContext scope_expression() { + return getRuleContext(Scope_expressionContext.class,0); + } + public While_do_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_while_do_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterWhile_do_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitWhile_do_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitWhile_do_expression(this); + else return visitor.visitChildren(this); + } + } + + public final While_do_expressionContext while_do_expression() throws RecognitionException { + While_do_expressionContext _localctx = new While_do_expressionContext(_ctx, getState()); + enterRule(_localctx, 50, RULE_while_do_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(297); + match(T__28); + setState(298); + expression(); + setState(299); + match(T__29); + setState(300); + scope_expression(); + setState(301); + match(T__30); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Do_while_expressionContext extends ParserRuleContext { + public Scope_expressionContext scope_expression() { + return getRuleContext(Scope_expressionContext.class,0); + } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public Do_while_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_do_while_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterDo_while_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitDo_while_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitDo_while_expression(this); + else return visitor.visitChildren(this); + } + } + + public final Do_while_expressionContext do_while_expression() throws RecognitionException { + Do_while_expressionContext _localctx = new Do_while_expressionContext(_ctx, getState()); + enterRule(_localctx, 52, RULE_do_while_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(303); + match(T__29); + setState(304); + scope_expression(); + setState(305); + match(T__28); + setState(306); + expression(); + setState(307); + match(T__30); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class For_expressionContext extends ParserRuleContext { + public List scope_expression() { + return getRuleContexts(Scope_expressionContext.class); + } + public Scope_expressionContext scope_expression(int i) { + return getRuleContext(Scope_expressionContext.class,i); + } + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public For_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_for_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterFor_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitFor_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitFor_expression(this); + else return visitor.visitChildren(this); + } + } + + public final For_expressionContext for_expression() throws RecognitionException { + For_expressionContext _localctx = new For_expressionContext(_ctx, getState()); + enterRule(_localctx, 54, RULE_for_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(309); + match(T__31); + setState(310); + scope_expression(); + setState(311); + match(T__4); + setState(312); + expression(); + setState(313); + match(T__4); + setState(314); + expression(); + setState(315); + match(T__29); + setState(316); + scope_expression(); + setState(317); + match(T__30); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PatternContext extends ParserRuleContext { + public Cons_patternContext cons_pattern() { + return getRuleContext(Cons_patternContext.class,0); + } + public Simple_patternContext simple_pattern() { + return getRuleContext(Simple_patternContext.class,0); + } + public PatternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_pattern; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterPattern(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitPattern(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitPattern(this); + else return visitor.visitChildren(this); + } + } + + public final PatternContext pattern() throws RecognitionException { + PatternContext _localctx = new PatternContext(_ctx, getState()); + enterRule(_localctx, 56, RULE_pattern); + try { + enterOuterAlt(_localctx, 1); + { + setState(319); + cons_pattern(); + setState(320); + match(T__32); + setState(321); + simple_pattern(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Cons_patternContext extends ParserRuleContext { + public Simple_patternContext simple_pattern() { + return getRuleContext(Simple_patternContext.class,0); + } + public PatternContext pattern() { + return getRuleContext(PatternContext.class,0); + } + public Cons_patternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_cons_pattern; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterCons_pattern(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitCons_pattern(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitCons_pattern(this); + else return visitor.visitChildren(this); + } + } + + public final Cons_patternContext cons_pattern() throws RecognitionException { + Cons_patternContext _localctx = new Cons_patternContext(_ctx, getState()); + enterRule(_localctx, 58, RULE_cons_pattern); + try { + enterOuterAlt(_localctx, 1); + { + setState(323); + simple_pattern(); + setState(324); + match(T__33); + setState(325); + pattern(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Simple_patternContext extends ParserRuleContext { + public Wildcard_patternContext wildcard_pattern() { + return getRuleContext(Wildcard_patternContext.class,0); + } + public S_expr_patternContext s_expr_pattern() { + return getRuleContext(S_expr_patternContext.class,0); + } + public Array_patternContext array_pattern() { + return getRuleContext(Array_patternContext.class,0); + } + public List_patternContext list_pattern() { + return getRuleContext(List_patternContext.class,0); + } + public TerminalNode LIDENT() { return getToken(LamaParser.LIDENT, 0); } + public PatternContext pattern() { + return getRuleContext(PatternContext.class,0); + } + public TerminalNode DECIMAL_LITERAL() { return getToken(LamaParser.DECIMAL_LITERAL, 0); } + public TerminalNode STRING_LITERAL() { return getToken(LamaParser.STRING_LITERAL, 0); } + public TerminalNode CHAR_LITERAL() { return getToken(LamaParser.CHAR_LITERAL, 0); } + public Simple_patternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_simple_pattern; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterSimple_pattern(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitSimple_pattern(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitSimple_pattern(this); + else return visitor.visitChildren(this); + } + } + + public final Simple_patternContext simple_pattern() throws RecognitionException { + Simple_patternContext _localctx = new Simple_patternContext(_ctx, getState()); + enterRule(_localctx, 60, RULE_simple_pattern); + int _la; + try { + setState(360); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,30,_ctx) ) { + case 1: + enterOuterAlt(_localctx, 1); + { + setState(327); + wildcard_pattern(); + } + break; + case 2: + enterOuterAlt(_localctx, 2); + { + setState(328); + s_expr_pattern(); + } + break; + case 3: + enterOuterAlt(_localctx, 3); + { + setState(329); + array_pattern(); + } + break; + case 4: + enterOuterAlt(_localctx, 4); + { + setState(330); + list_pattern(); + } + break; + case 5: + enterOuterAlt(_localctx, 5); + { + setState(331); + match(LIDENT); + setState(334); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__34) { + { + setState(332); + match(T__34); + setState(333); + pattern(); + } + } + + } + break; + case 6: + enterOuterAlt(_localctx, 6); + { + setState(337); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__17) { + { + setState(336); + match(T__17); + } + } + + setState(339); + match(DECIMAL_LITERAL); + } + break; + case 7: + enterOuterAlt(_localctx, 7); + { + setState(340); + match(STRING_LITERAL); + } + break; + case 8: + enterOuterAlt(_localctx, 8); + { + setState(341); + match(CHAR_LITERAL); + } + break; + case 9: + enterOuterAlt(_localctx, 9); + { + setState(342); + match(T__20); + } + break; + case 10: + enterOuterAlt(_localctx, 10); + { + setState(343); + match(T__21); + } + break; + case 11: + enterOuterAlt(_localctx, 11); + { + setState(344); + match(T__35); + setState(345); + match(T__36); + } + break; + case 12: + enterOuterAlt(_localctx, 12); + { + setState(346); + match(T__35); + setState(347); + match(T__37); + } + break; + case 13: + enterOuterAlt(_localctx, 13); + { + setState(348); + match(T__35); + setState(349); + match(T__38); + } + break; + case 14: + enterOuterAlt(_localctx, 14); + { + setState(350); + match(T__35); + setState(351); + match(T__39); + } + break; + case 15: + enterOuterAlt(_localctx, 15); + { + setState(352); + match(T__35); + setState(353); + match(T__40); + } + break; + case 16: + enterOuterAlt(_localctx, 16); + { + setState(354); + match(T__35); + setState(355); + match(T__6); + } + break; + case 17: + enterOuterAlt(_localctx, 17); + { + setState(356); + match(T__7); + setState(357); + pattern(); + setState(358); + match(T__8); + } + break; + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Wildcard_patternContext extends ParserRuleContext { + public Wildcard_patternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_wildcard_pattern; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterWildcard_pattern(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitWildcard_pattern(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitWildcard_pattern(this); + else return visitor.visitChildren(this); + } + } + + public final Wildcard_patternContext wildcard_pattern() throws RecognitionException { + Wildcard_patternContext _localctx = new Wildcard_patternContext(_ctx, getState()); + enterRule(_localctx, 62, RULE_wildcard_pattern); + try { + enterOuterAlt(_localctx, 1); + { + setState(362); + match(T__41); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class S_expr_patternContext extends ParserRuleContext { + public TerminalNode UIDENT() { return getToken(LamaParser.UIDENT, 0); } + public List pattern() { + return getRuleContexts(PatternContext.class); + } + public PatternContext pattern(int i) { + return getRuleContext(PatternContext.class,i); + } + public S_expr_patternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_s_expr_pattern; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterS_expr_pattern(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitS_expr_pattern(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitS_expr_pattern(this); + else return visitor.visitChildren(this); + } + } + + public final S_expr_patternContext s_expr_pattern() throws RecognitionException { + S_expr_patternContext _localctx = new S_expr_patternContext(_ctx, getState()); + enterRule(_localctx, 64, RULE_s_expr_pattern); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(364); + match(UIDENT); + setState(377); + _errHandler.sync(this); + _la = _input.LA(1); + if (_la==T__7) { + { + setState(365); + match(T__7); + setState(374); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 139616055221552384L) != 0)) { + { + setState(366); + pattern(); + setState(371); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(367); + match(T__4); + setState(368); + pattern(); + } + } + setState(373); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(376); + match(T__8); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Array_patternContext extends ParserRuleContext { + public List pattern() { + return getRuleContexts(PatternContext.class); + } + public PatternContext pattern(int i) { + return getRuleContext(PatternContext.class,i); + } + public Array_patternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_array_pattern; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterArray_pattern(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitArray_pattern(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitArray_pattern(this); + else return visitor.visitChildren(this); + } + } + + public final Array_patternContext array_pattern() throws RecognitionException { + Array_patternContext _localctx = new Array_patternContext(_ctx, getState()); + enterRule(_localctx, 66, RULE_array_pattern); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(379); + match(T__18); + setState(388); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 139616055221552384L) != 0)) { + { + setState(380); + pattern(); + setState(385); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(381); + match(T__4); + setState(382); + pattern(); + } + } + setState(387); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(390); + match(T__19); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class List_patternContext extends ParserRuleContext { + public List pattern() { + return getRuleContexts(PatternContext.class); + } + public PatternContext pattern(int i) { + return getRuleContext(PatternContext.class,i); + } + public List_patternContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_list_pattern; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterList_pattern(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitList_pattern(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitList_pattern(this); + else return visitor.visitChildren(this); + } + } + + public final List_patternContext list_pattern() throws RecognitionException { + List_patternContext _localctx = new List_patternContext(_ctx, getState()); + enterRule(_localctx, 68, RULE_list_pattern); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(392); + match(T__9); + setState(401); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 139616055221552384L) != 0)) { + { + setState(393); + pattern(); + setState(398); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__4) { + { + { + setState(394); + match(T__4); + setState(395); + pattern(); + } + } + setState(400); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + + setState(403); + match(T__10); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Case_expressionContext extends ParserRuleContext { + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public Case_branchesContext case_branches() { + return getRuleContext(Case_branchesContext.class,0); + } + public Case_expressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_case_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterCase_expression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitCase_expression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitCase_expression(this); + else return visitor.visitChildren(this); + } + } + + public final Case_expressionContext case_expression() throws RecognitionException { + Case_expressionContext _localctx = new Case_expressionContext(_ctx, getState()); + enterRule(_localctx, 70, RULE_case_expression); + try { + enterOuterAlt(_localctx, 1); + { + setState(405); + match(T__42); + setState(406); + expression(); + setState(407); + match(T__43); + setState(408); + case_branches(); + setState(409); + match(T__44); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Case_branchesContext extends ParserRuleContext { + public List case_branch() { + return getRuleContexts(Case_branchContext.class); + } + public Case_branchContext case_branch(int i) { + return getRuleContext(Case_branchContext.class,i); + } + public Case_branchesContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_case_branches; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterCase_branches(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitCase_branches(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitCase_branches(this); + else return visitor.visitChildren(this); + } + } + + public final Case_branchesContext case_branches() throws RecognitionException { + Case_branchesContext _localctx = new Case_branchesContext(_ctx, getState()); + enterRule(_localctx, 72, RULE_case_branches); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(411); + case_branch(); + setState(416); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__32) { + { + { + setState(412); + match(T__32); + setState(413); + case_branch(); + } + } + setState(418); + _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 Case_branchContext extends ParserRuleContext { + public PatternContext pattern() { + return getRuleContext(PatternContext.class,0); + } + public Scope_expressionContext scope_expression() { + return getRuleContext(Scope_expressionContext.class,0); + } + public Case_branchContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_case_branch; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).enterCase_branch(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof LamaListener ) ((LamaListener)listener).exitCase_branch(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof LamaVisitor ) return ((LamaVisitor)visitor).visitCase_branch(this); + else return visitor.visitChildren(this); + } + } + + public final Case_branchContext case_branch() throws RecognitionException { + Case_branchContext _localctx = new Case_branchContext(_ctx, getState()); + enterRule(_localctx, 74, RULE_case_branch); + try { + enterOuterAlt(_localctx, 1); + { + setState(419); + pattern(); + setState(420); + match(T__45); + setState(421); + scope_expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\u0004\u00018\u01a8\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"+ + "\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002\u001b\u0007\u001b"+ + "\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002\u001e\u0007\u001e"+ + "\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007!\u0002\"\u0007\"\u0002"+ + "#\u0007#\u0002$\u0007$\u0002%\u0007%\u0001\u0000\u0005\u0000N\b\u0000"+ + "\n\u0000\f\u0000Q\t\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0001"+ + "\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0004\u0002[\b\u0002"+ + "\u000b\u0002\f\u0002\\\u0001\u0002\u0003\u0002`\b\u0002\u0001\u0002\u0003"+ + "\u0002c\b\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0003\u0003h\b\u0003"+ + "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005"+ + "\u0005\u0005p\b\u0005\n\u0005\f\u0005s\t\u0005\u0001\u0005\u0001\u0005"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0003\u0006z\b\u0006\u0001\u0007"+ + "\u0003\u0007}\b\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007"+ + "\u0003\u0007\u0083\b\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b"+ + "\u0001\b\u0001\b\u0005\b\u008b\b\b\n\b\f\b\u008e\t\b\u0001\t\u0001\t\u0001"+ + "\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\n\u0001\u000b"+ + "\u0003\u000b\u009b\b\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b"+ + "\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001\u000e\u0001"+ + "\u000e\u0003\u000e\u00a9\b\u000e\u0001\u000f\u0001\u000f\u0001\u0010\u0001"+ + "\u0010\u0001\u0010\u0005\u0010\u00b0\b\u0010\n\u0010\f\u0010\u00b3\t\u0010"+ + "\u0001\u0011\u0003\u0011\u00b6\b\u0011\u0001\u0011\u0001\u0011\u0005\u0011"+ + "\u00ba\b\u0011\n\u0011\f\u0011\u00bd\t\u0011\u0001\u0012\u0001\u0012\u0001"+ + "\u0012\u0001\u0012\u0005\u0012\u00c3\b\u0012\n\u0012\f\u0012\u00c6\t\u0012"+ + "\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ + "\u0003\u0012\u00ce\b\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013"+ + "\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013"+ + "\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013"+ + "\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013"+ + "\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0013\u0003\u0013"+ + "\u00eb\b\u0013\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0005\u0014"+ + "\u00f1\b\u0014\n\u0014\f\u0014\u00f4\t\u0014\u0003\u0014\u00f6\b\u0014"+ + "\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0015\u0001\u0015"+ + "\u0005\u0015\u00fe\b\u0015\n\u0015\f\u0015\u0101\t\u0015\u0003\u0015\u0103"+ + "\b\u0015\u0001\u0015\u0001\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0001"+ + "\u0016\u0001\u0016\u0005\u0016\u010c\b\u0016\n\u0016\f\u0016\u010f\t\u0016"+ + "\u0003\u0016\u0111\b\u0016\u0001\u0016\u0003\u0016\u0114\b\u0016\u0001"+ + "\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0001\u0017\u0003\u0017\u011b"+ + "\b\u0017\u0001\u0017\u0001\u0017\u0001\u0018\u0001\u0018\u0001\u0018\u0001"+ + "\u0018\u0001\u0018\u0003\u0018\u0124\b\u0018\u0001\u0018\u0001\u0018\u0003"+ + "\u0018\u0128\b\u0018\u0001\u0019\u0001\u0019\u0001\u0019\u0001\u0019\u0001"+ + "\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001"+ + "\u001a\u0001\u001a\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001"+ + "\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001\u001b\u0001"+ + "\u001c\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001d\u0001\u001d\u0001"+ + "\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001"+ + "\u001e\u0001\u001e\u0001\u001e\u0003\u001e\u014f\b\u001e\u0001\u001e\u0003"+ + "\u001e\u0152\b\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001"+ + "\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001"+ + "\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001"+ + "\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0001\u001e\u0003\u001e\u0169"+ + "\b\u001e\u0001\u001f\u0001\u001f\u0001 \u0001 \u0001 \u0001 \u0001 \u0005"+ + " \u0172\b \n \f \u0175\t \u0003 \u0177\b \u0001 \u0003 \u017a\b \u0001"+ + "!\u0001!\u0001!\u0001!\u0005!\u0180\b!\n!\f!\u0183\t!\u0003!\u0185\b!"+ + "\u0001!\u0001!\u0001\"\u0001\"\u0001\"\u0001\"\u0005\"\u018d\b\"\n\"\f"+ + "\"\u0190\t\"\u0003\"\u0192\b\"\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001"+ + "#\u0001#\u0001#\u0001$\u0001$\u0001$\u0005$\u019f\b$\n$\f$\u01a2\t$\u0001"+ + "%\u0001%\u0001%\u0001%\u0001%\u0000\u0000&\u0000\u0002\u0004\u0006\b\n"+ + "\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a\u001c\u001e \"$&(*,.0246"+ + "8:<>@BDFHJ\u0000\u0003\u0001\u0000\u0003\u0004\u0001\u0000\f\u000e\u0001"+ + "\u0000\u000f\u0011\u01c8\u0000O\u0001\u0000\u0000\u0000\u0002U\u0001\u0000"+ + "\u0000\u0000\u0004b\u0001\u0000\u0000\u0000\u0006g\u0001\u0000\u0000\u0000"+ + "\bi\u0001\u0000\u0000\u0000\nl\u0001\u0000\u0000\u0000\fv\u0001\u0000"+ + "\u0000\u0000\u000e|\u0001\u0000\u0000\u0000\u0010\u0087\u0001\u0000\u0000"+ + "\u0000\u0012\u008f\u0001\u0000\u0000\u0000\u0014\u0093\u0001\u0000\u0000"+ + "\u0000\u0016\u009a\u0001\u0000\u0000\u0000\u0018\u00a0\u0001\u0000\u0000"+ + "\u0000\u001a\u00a2\u0001\u0000\u0000\u0000\u001c\u00a5\u0001\u0000\u0000"+ + "\u0000\u001e\u00aa\u0001\u0000\u0000\u0000 \u00ac\u0001\u0000\u0000\u0000"+ + "\"\u00b5\u0001\u0000\u0000\u0000$\u00cd\u0001\u0000\u0000\u0000&\u00ea"+ + "\u0001\u0000\u0000\u0000(\u00ec\u0001\u0000\u0000\u0000*\u00f9\u0001\u0000"+ + "\u0000\u0000,\u0106\u0001\u0000\u0000\u0000.\u0115\u0001\u0000\u0000\u0000"+ + "0\u0127\u0001\u0000\u0000\u00002\u0129\u0001\u0000\u0000\u00004\u012f"+ + "\u0001\u0000\u0000\u00006\u0135\u0001\u0000\u0000\u00008\u013f\u0001\u0000"+ + "\u0000\u0000:\u0143\u0001\u0000\u0000\u0000<\u0168\u0001\u0000\u0000\u0000"+ + ">\u016a\u0001\u0000\u0000\u0000@\u016c\u0001\u0000\u0000\u0000B\u017b"+ + "\u0001\u0000\u0000\u0000D\u0188\u0001\u0000\u0000\u0000F\u0195\u0001\u0000"+ + "\u0000\u0000H\u019b\u0001\u0000\u0000\u0000J\u01a3\u0001\u0000\u0000\u0000"+ + "LN\u0003\u0002\u0001\u0000ML\u0001\u0000\u0000\u0000NQ\u0001\u0000\u0000"+ + "\u0000OM\u0001\u0000\u0000\u0000OP\u0001\u0000\u0000\u0000PR\u0001\u0000"+ + "\u0000\u0000QO\u0001\u0000\u0000\u0000RS\u0003\u0004\u0002\u0000ST\u0005"+ + "\u0000\u0000\u0001T\u0001\u0001\u0000\u0000\u0000UV\u0005\u0001\u0000"+ + "\u0000VW\u00054\u0000\u0000WX\u0005\u0002\u0000\u0000X\u0003\u0001\u0000"+ + "\u0000\u0000Y[\u0003\u0006\u0003\u0000ZY\u0001\u0000\u0000\u0000[\\\u0001"+ + "\u0000\u0000\u0000\\Z\u0001\u0000\u0000\u0000\\]\u0001\u0000\u0000\u0000"+ + "]_\u0001\u0000\u0000\u0000^`\u0003\u001c\u000e\u0000_^\u0001\u0000\u0000"+ + "\u0000_`\u0001\u0000\u0000\u0000`c\u0001\u0000\u0000\u0000ac\u0003\u001c"+ + "\u000e\u0000bZ\u0001\u0000\u0000\u0000ba\u0001\u0000\u0000\u0000c\u0005"+ + "\u0001\u0000\u0000\u0000dh\u0003\b\u0004\u0000eh\u0003\u000e\u0007\u0000"+ + "fh\u0003\u0014\n\u0000gd\u0001\u0000\u0000\u0000ge\u0001\u0000\u0000\u0000"+ + "gf\u0001\u0000\u0000\u0000h\u0007\u0001\u0000\u0000\u0000ij\u0007\u0000"+ + "\u0000\u0000jk\u0003\n\u0005\u0000k\t\u0001\u0000\u0000\u0000lq\u0003"+ + "\f\u0006\u0000mn\u0005\u0005\u0000\u0000np\u0003\f\u0006\u0000om\u0001"+ + "\u0000\u0000\u0000ps\u0001\u0000\u0000\u0000qo\u0001\u0000\u0000\u0000"+ + "qr\u0001\u0000\u0000\u0000rt\u0001\u0000\u0000\u0000sq\u0001\u0000\u0000"+ + "\u0000tu\u0005\u0002\u0000\u0000u\u000b\u0001\u0000\u0000\u0000vy\u0005"+ + "5\u0000\u0000wx\u0005\u0006\u0000\u0000xz\u0003\u001e\u000f\u0000yw\u0001"+ + "\u0000\u0000\u0000yz\u0001\u0000\u0000\u0000z\r\u0001\u0000\u0000\u0000"+ + "{}\u0005\u0004\u0000\u0000|{\u0001\u0000\u0000\u0000|}\u0001\u0000\u0000"+ + "\u0000}~\u0001\u0000\u0000\u0000~\u007f\u0005\u0007\u0000\u0000\u007f"+ + "\u0080\u00055\u0000\u0000\u0080\u0082\u0005\b\u0000\u0000\u0081\u0083"+ + "\u0003\u0010\b\u0000\u0082\u0081\u0001\u0000\u0000\u0000\u0082\u0083\u0001"+ + "\u0000\u0000\u0000\u0083\u0084\u0001\u0000\u0000\u0000\u0084\u0085\u0005"+ + "\t\u0000\u0000\u0085\u0086\u0003\u0012\t\u0000\u0086\u000f\u0001\u0000"+ + "\u0000\u0000\u0087\u008c\u00055\u0000\u0000\u0088\u0089\u0005\u0005\u0000"+ + "\u0000\u0089\u008b\u00055\u0000\u0000\u008a\u0088\u0001\u0000\u0000\u0000"+ + "\u008b\u008e\u0001\u0000\u0000\u0000\u008c\u008a\u0001\u0000\u0000\u0000"+ + "\u008c\u008d\u0001\u0000\u0000\u0000\u008d\u0011\u0001\u0000\u0000\u0000"+ + "\u008e\u008c\u0001\u0000\u0000\u0000\u008f\u0090\u0005\n\u0000\u0000\u0090"+ + "\u0091\u0003\u0004\u0002\u0000\u0091\u0092\u0005\u000b\u0000\u0000\u0092"+ + "\u0013\u0001\u0000\u0000\u0000\u0093\u0094\u0003\u0016\u000b\u0000\u0094"+ + "\u0095\u0005\b\u0000\u0000\u0095\u0096\u0003\u0010\b\u0000\u0096\u0097"+ + "\u0005\t\u0000\u0000\u0097\u0098\u0003\u0012\t\u0000\u0098\u0015\u0001"+ + "\u0000\u0000\u0000\u0099\u009b\u0005\u0004\u0000\u0000\u009a\u0099\u0001"+ + "\u0000\u0000\u0000\u009a\u009b\u0001\u0000\u0000\u0000\u009b\u009c\u0001"+ + "\u0000\u0000\u0000\u009c\u009d\u0003\u0018\f\u0000\u009d\u009e\u00053"+ + "\u0000\u0000\u009e\u009f\u0003\u001a\r\u0000\u009f\u0017\u0001\u0000\u0000"+ + "\u0000\u00a0\u00a1\u0007\u0001\u0000\u0000\u00a1\u0019\u0001\u0000\u0000"+ + "\u0000\u00a2\u00a3\u0007\u0002\u0000\u0000\u00a3\u00a4\u00053\u0000\u0000"+ + "\u00a4\u001b\u0001\u0000\u0000\u0000\u00a5\u00a8\u0003\u001e\u000f\u0000"+ + "\u00a6\u00a7\u0005\u0002\u0000\u0000\u00a7\u00a9\u0003\u001c\u000e\u0000"+ + "\u00a8\u00a6\u0001\u0000\u0000\u0000\u00a8\u00a9\u0001\u0000\u0000\u0000"+ + "\u00a9\u001d\u0001\u0000\u0000\u0000\u00aa\u00ab\u0003 \u0010\u0000\u00ab"+ + "\u001f\u0001\u0000\u0000\u0000\u00ac\u00b1\u0003\"\u0011\u0000\u00ad\u00ae"+ + "\u00053\u0000\u0000\u00ae\u00b0\u0003\"\u0011\u0000\u00af\u00ad\u0001"+ + "\u0000\u0000\u0000\u00b0\u00b3\u0001\u0000\u0000\u0000\u00b1\u00af\u0001"+ + "\u0000\u0000\u0000\u00b1\u00b2\u0001\u0000\u0000\u0000\u00b2!\u0001\u0000"+ + "\u0000\u0000\u00b3\u00b1\u0001\u0000\u0000\u0000\u00b4\u00b6\u0005\u0012"+ + "\u0000\u0000\u00b5\u00b4\u0001\u0000\u0000\u0000\u00b5\u00b6\u0001\u0000"+ + "\u0000\u0000\u00b6\u00b7\u0001\u0000\u0000\u0000\u00b7\u00bb\u0003&\u0013"+ + "\u0000\u00b8\u00ba\u0003$\u0012\u0000\u00b9\u00b8\u0001\u0000\u0000\u0000"+ + "\u00ba\u00bd\u0001\u0000\u0000\u0000\u00bb\u00b9\u0001\u0000\u0000\u0000"+ + "\u00bb\u00bc\u0001\u0000\u0000\u0000\u00bc#\u0001\u0000\u0000\u0000\u00bd"+ + "\u00bb\u0001\u0000\u0000\u0000\u00be\u00bf\u0005\b\u0000\u0000\u00bf\u00c4"+ + "\u0003\u001c\u000e\u0000\u00c0\u00c1\u0005\u0005\u0000\u0000\u00c1\u00c3"+ + "\u0003\u001c\u000e\u0000\u00c2\u00c0\u0001\u0000\u0000\u0000\u00c3\u00c6"+ + "\u0001\u0000\u0000\u0000\u00c4\u00c2\u0001\u0000\u0000\u0000\u00c4\u00c5"+ + "\u0001\u0000\u0000\u0000\u00c5\u00c7\u0001\u0000\u0000\u0000\u00c6\u00c4"+ + "\u0001\u0000\u0000\u0000\u00c7\u00c8\u0005\t\u0000\u0000\u00c8\u00ce\u0001"+ + "\u0000\u0000\u0000\u00c9\u00ca\u0005\u0013\u0000\u0000\u00ca\u00cb\u0003"+ + "\u001c\u000e\u0000\u00cb\u00cc\u0005\u0014\u0000\u0000\u00cc\u00ce\u0001"+ + "\u0000\u0000\u0000\u00cd\u00be\u0001\u0000\u0000\u0000\u00cd\u00c9\u0001"+ + "\u0000\u0000\u0000\u00ce%\u0001\u0000\u0000\u0000\u00cf\u00eb\u00058\u0000"+ + "\u0000\u00d0\u00eb\u00057\u0000\u0000\u00d1\u00eb\u00056\u0000\u0000\u00d2"+ + "\u00eb\u00055\u0000\u0000\u00d3\u00eb\u0005\u0015\u0000\u0000\u00d4\u00eb"+ + "\u0005\u0016\u0000\u0000\u00d5\u00d6\u0005\f\u0000\u0000\u00d6\u00eb\u0005"+ + "3\u0000\u0000\u00d7\u00d8\u0005\u0007\u0000\u0000\u00d8\u00d9\u0005\b"+ + "\u0000\u0000\u00d9\u00da\u0003\u0010\b\u0000\u00da\u00db\u0005\t\u0000"+ + "\u0000\u00db\u00dc\u0003\u0012\t\u0000\u00dc\u00eb\u0001\u0000\u0000\u0000"+ + "\u00dd\u00eb\u0005\u0017\u0000\u0000\u00de\u00df\u0005\b\u0000\u0000\u00df"+ + "\u00e0\u0003\u0004\u0002\u0000\u00e0\u00e1\u0005\t\u0000\u0000\u00e1\u00eb"+ + "\u0001\u0000\u0000\u0000\u00e2\u00eb\u0003*\u0015\u0000\u00e3\u00eb\u0003"+ + "(\u0014\u0000\u00e4\u00eb\u0003,\u0016\u0000\u00e5\u00eb\u0003.\u0017"+ + "\u0000\u00e6\u00eb\u00032\u0019\u0000\u00e7\u00eb\u00034\u001a\u0000\u00e8"+ + "\u00eb\u00036\u001b\u0000\u00e9\u00eb\u0003F#\u0000\u00ea\u00cf\u0001"+ + "\u0000\u0000\u0000\u00ea\u00d0\u0001\u0000\u0000\u0000\u00ea\u00d1\u0001"+ + "\u0000\u0000\u0000\u00ea\u00d2\u0001\u0000\u0000\u0000\u00ea\u00d3\u0001"+ + "\u0000\u0000\u0000\u00ea\u00d4\u0001\u0000\u0000\u0000\u00ea\u00d5\u0001"+ + "\u0000\u0000\u0000\u00ea\u00d7\u0001\u0000\u0000\u0000\u00ea\u00dd\u0001"+ + "\u0000\u0000\u0000\u00ea\u00de\u0001\u0000\u0000\u0000\u00ea\u00e2\u0001"+ + "\u0000\u0000\u0000\u00ea\u00e3\u0001\u0000\u0000\u0000\u00ea\u00e4\u0001"+ + "\u0000\u0000\u0000\u00ea\u00e5\u0001\u0000\u0000\u0000\u00ea\u00e6\u0001"+ + "\u0000\u0000\u0000\u00ea\u00e7\u0001\u0000\u0000\u0000\u00ea\u00e8\u0001"+ + "\u0000\u0000\u0000\u00ea\u00e9\u0001\u0000\u0000\u0000\u00eb\'\u0001\u0000"+ + "\u0000\u0000\u00ec\u00f5\u0005\u0013\u0000\u0000\u00ed\u00f2\u0003\u001c"+ + "\u000e\u0000\u00ee\u00ef\u0005\u0005\u0000\u0000\u00ef\u00f1\u0003\u001c"+ + "\u000e\u0000\u00f0\u00ee\u0001\u0000\u0000\u0000\u00f1\u00f4\u0001\u0000"+ + "\u0000\u0000\u00f2\u00f0\u0001\u0000\u0000\u0000\u00f2\u00f3\u0001\u0000"+ + "\u0000\u0000\u00f3\u00f6\u0001\u0000\u0000\u0000\u00f4\u00f2\u0001\u0000"+ + "\u0000\u0000\u00f5\u00ed\u0001\u0000\u0000\u0000\u00f5\u00f6\u0001\u0000"+ + "\u0000\u0000\u00f6\u00f7\u0001\u0000\u0000\u0000\u00f7\u00f8\u0005\u0014"+ + "\u0000\u0000\u00f8)\u0001\u0000\u0000\u0000\u00f9\u0102\u0005\n\u0000"+ + "\u0000\u00fa\u00ff\u0003\u001c\u000e\u0000\u00fb\u00fc\u0005\u0005\u0000"+ + "\u0000\u00fc\u00fe\u0003\u001c\u000e\u0000\u00fd\u00fb\u0001\u0000\u0000"+ + "\u0000\u00fe\u0101\u0001\u0000\u0000\u0000\u00ff\u00fd\u0001\u0000\u0000"+ + "\u0000\u00ff\u0100\u0001\u0000\u0000\u0000\u0100\u0103\u0001\u0000\u0000"+ + "\u0000\u0101\u00ff\u0001\u0000\u0000\u0000\u0102\u00fa\u0001\u0000\u0000"+ + "\u0000\u0102\u0103\u0001\u0000\u0000\u0000\u0103\u0104\u0001\u0000\u0000"+ + "\u0000\u0104\u0105\u0005\u000b\u0000\u0000\u0105+\u0001\u0000\u0000\u0000"+ + "\u0106\u0113\u00054\u0000\u0000\u0107\u0110\u0005\b\u0000\u0000\u0108"+ + "\u010d\u0003\u001c\u000e\u0000\u0109\u010a\u0005\u0005\u0000\u0000\u010a"+ + "\u010c\u0003\u001c\u000e\u0000\u010b\u0109\u0001\u0000\u0000\u0000\u010c"+ + "\u010f\u0001\u0000\u0000\u0000\u010d\u010b\u0001\u0000\u0000\u0000\u010d"+ + "\u010e\u0001\u0000\u0000\u0000\u010e\u0111\u0001\u0000\u0000\u0000\u010f"+ + "\u010d\u0001\u0000\u0000\u0000\u0110\u0108\u0001\u0000\u0000\u0000\u0110"+ + "\u0111\u0001\u0000\u0000\u0000\u0111\u0112\u0001\u0000\u0000\u0000\u0112"+ + "\u0114\u0005\t\u0000\u0000\u0113\u0107\u0001\u0000\u0000\u0000\u0113\u0114"+ + "\u0001\u0000\u0000\u0000\u0114-\u0001\u0000\u0000\u0000\u0115\u0116\u0005"+ + "\u0018\u0000\u0000\u0116\u0117\u0003\u001c\u000e\u0000\u0117\u0118\u0005"+ + "\u0019\u0000\u0000\u0118\u011a\u0003\u0004\u0002\u0000\u0119\u011b\u0003"+ + "0\u0018\u0000\u011a\u0119\u0001\u0000\u0000\u0000\u011a\u011b\u0001\u0000"+ + "\u0000\u0000\u011b\u011c\u0001\u0000\u0000\u0000\u011c\u011d\u0005\u001a"+ + "\u0000\u0000\u011d/\u0001\u0000\u0000\u0000\u011e\u011f\u0005\u001b\u0000"+ + "\u0000\u011f\u0120\u0003\u001c\u000e\u0000\u0120\u0121\u0005\u0019\u0000"+ + "\u0000\u0121\u0123\u0003\u0004\u0002\u0000\u0122\u0124\u00030\u0018\u0000"+ + "\u0123\u0122\u0001\u0000\u0000\u0000\u0123\u0124\u0001\u0000\u0000\u0000"+ + "\u0124\u0128\u0001\u0000\u0000\u0000\u0125\u0126\u0005\u001c\u0000\u0000"+ + "\u0126\u0128\u0003\u0004\u0002\u0000\u0127\u011e\u0001\u0000\u0000\u0000"+ + "\u0127\u0125\u0001\u0000\u0000\u0000\u01281\u0001\u0000\u0000\u0000\u0129"+ + "\u012a\u0005\u001d\u0000\u0000\u012a\u012b\u0003\u001c\u000e\u0000\u012b"+ + "\u012c\u0005\u001e\u0000\u0000\u012c\u012d\u0003\u0004\u0002\u0000\u012d"+ + "\u012e\u0005\u001f\u0000\u0000\u012e3\u0001\u0000\u0000\u0000\u012f\u0130"+ + "\u0005\u001e\u0000\u0000\u0130\u0131\u0003\u0004\u0002\u0000\u0131\u0132"+ + "\u0005\u001d\u0000\u0000\u0132\u0133\u0003\u001c\u000e\u0000\u0133\u0134"+ + "\u0005\u001f\u0000\u0000\u01345\u0001\u0000\u0000\u0000\u0135\u0136\u0005"+ + " \u0000\u0000\u0136\u0137\u0003\u0004\u0002\u0000\u0137\u0138\u0005\u0005"+ + "\u0000\u0000\u0138\u0139\u0003\u001c\u000e\u0000\u0139\u013a\u0005\u0005"+ + "\u0000\u0000\u013a\u013b\u0003\u001c\u000e\u0000\u013b\u013c\u0005\u001e"+ + "\u0000\u0000\u013c\u013d\u0003\u0004\u0002\u0000\u013d\u013e\u0005\u001f"+ + "\u0000\u0000\u013e7\u0001\u0000\u0000\u0000\u013f\u0140\u0003:\u001d\u0000"+ + "\u0140\u0141\u0005!\u0000\u0000\u0141\u0142\u0003<\u001e\u0000\u01429"+ + "\u0001\u0000\u0000\u0000\u0143\u0144\u0003<\u001e\u0000\u0144\u0145\u0005"+ + "\"\u0000\u0000\u0145\u0146\u00038\u001c\u0000\u0146;\u0001\u0000\u0000"+ + "\u0000\u0147\u0169\u0003>\u001f\u0000\u0148\u0169\u0003@ \u0000\u0149"+ + "\u0169\u0003B!\u0000\u014a\u0169\u0003D\"\u0000\u014b\u014e\u00055\u0000"+ + "\u0000\u014c\u014d\u0005#\u0000\u0000\u014d\u014f\u00038\u001c\u0000\u014e"+ + "\u014c\u0001\u0000\u0000\u0000\u014e\u014f\u0001\u0000\u0000\u0000\u014f"+ + "\u0169\u0001\u0000\u0000\u0000\u0150\u0152\u0005\u0012\u0000\u0000\u0151"+ + "\u0150\u0001\u0000\u0000\u0000\u0151\u0152\u0001\u0000\u0000\u0000\u0152"+ + "\u0153\u0001\u0000\u0000\u0000\u0153\u0169\u00058\u0000\u0000\u0154\u0169"+ + "\u00057\u0000\u0000\u0155\u0169\u00056\u0000\u0000\u0156\u0169\u0005\u0015"+ + "\u0000\u0000\u0157\u0169\u0005\u0016\u0000\u0000\u0158\u0159\u0005$\u0000"+ + "\u0000\u0159\u0169\u0005%\u0000\u0000\u015a\u015b\u0005$\u0000\u0000\u015b"+ + "\u0169\u0005&\u0000\u0000\u015c\u015d\u0005$\u0000\u0000\u015d\u0169\u0005"+ + "\'\u0000\u0000\u015e\u015f\u0005$\u0000\u0000\u015f\u0169\u0005(\u0000"+ + "\u0000\u0160\u0161\u0005$\u0000\u0000\u0161\u0169\u0005)\u0000\u0000\u0162"+ + "\u0163\u0005$\u0000\u0000\u0163\u0169\u0005\u0007\u0000\u0000\u0164\u0165"+ + "\u0005\b\u0000\u0000\u0165\u0166\u00038\u001c\u0000\u0166\u0167\u0005"+ + "\t\u0000\u0000\u0167\u0169\u0001\u0000\u0000\u0000\u0168\u0147\u0001\u0000"+ + "\u0000\u0000\u0168\u0148\u0001\u0000\u0000\u0000\u0168\u0149\u0001\u0000"+ + "\u0000\u0000\u0168\u014a\u0001\u0000\u0000\u0000\u0168\u014b\u0001\u0000"+ + "\u0000\u0000\u0168\u0151\u0001\u0000\u0000\u0000\u0168\u0154\u0001\u0000"+ + "\u0000\u0000\u0168\u0155\u0001\u0000\u0000\u0000\u0168\u0156\u0001\u0000"+ + "\u0000\u0000\u0168\u0157\u0001\u0000\u0000\u0000\u0168\u0158\u0001\u0000"+ + "\u0000\u0000\u0168\u015a\u0001\u0000\u0000\u0000\u0168\u015c\u0001\u0000"+ + "\u0000\u0000\u0168\u015e\u0001\u0000\u0000\u0000\u0168\u0160\u0001\u0000"+ + "\u0000\u0000\u0168\u0162\u0001\u0000\u0000\u0000\u0168\u0164\u0001\u0000"+ + "\u0000\u0000\u0169=\u0001\u0000\u0000\u0000\u016a\u016b\u0005*\u0000\u0000"+ + "\u016b?\u0001\u0000\u0000\u0000\u016c\u0179\u00054\u0000\u0000\u016d\u0176"+ + "\u0005\b\u0000\u0000\u016e\u0173\u00038\u001c\u0000\u016f\u0170\u0005"+ + "\u0005\u0000\u0000\u0170\u0172\u00038\u001c\u0000\u0171\u016f\u0001\u0000"+ + "\u0000\u0000\u0172\u0175\u0001\u0000\u0000\u0000\u0173\u0171\u0001\u0000"+ + "\u0000\u0000\u0173\u0174\u0001\u0000\u0000\u0000\u0174\u0177\u0001\u0000"+ + "\u0000\u0000\u0175\u0173\u0001\u0000\u0000\u0000\u0176\u016e\u0001\u0000"+ + "\u0000\u0000\u0176\u0177\u0001\u0000\u0000\u0000\u0177\u0178\u0001\u0000"+ + "\u0000\u0000\u0178\u017a\u0005\t\u0000\u0000\u0179\u016d\u0001\u0000\u0000"+ + "\u0000\u0179\u017a\u0001\u0000\u0000\u0000\u017aA\u0001\u0000\u0000\u0000"+ + "\u017b\u0184\u0005\u0013\u0000\u0000\u017c\u0181\u00038\u001c\u0000\u017d"+ + "\u017e\u0005\u0005\u0000\u0000\u017e\u0180\u00038\u001c\u0000\u017f\u017d"+ + "\u0001\u0000\u0000\u0000\u0180\u0183\u0001\u0000\u0000\u0000\u0181\u017f"+ + "\u0001\u0000\u0000\u0000\u0181\u0182\u0001\u0000\u0000\u0000\u0182\u0185"+ + "\u0001\u0000\u0000\u0000\u0183\u0181\u0001\u0000\u0000\u0000\u0184\u017c"+ + "\u0001\u0000\u0000\u0000\u0184\u0185\u0001\u0000\u0000\u0000\u0185\u0186"+ + "\u0001\u0000\u0000\u0000\u0186\u0187\u0005\u0014\u0000\u0000\u0187C\u0001"+ + "\u0000\u0000\u0000\u0188\u0191\u0005\n\u0000\u0000\u0189\u018e\u00038"+ + "\u001c\u0000\u018a\u018b\u0005\u0005\u0000\u0000\u018b\u018d\u00038\u001c"+ + "\u0000\u018c\u018a\u0001\u0000\u0000\u0000\u018d\u0190\u0001\u0000\u0000"+ + "\u0000\u018e\u018c\u0001\u0000\u0000\u0000\u018e\u018f\u0001\u0000\u0000"+ + "\u0000\u018f\u0192\u0001\u0000\u0000\u0000\u0190\u018e\u0001\u0000\u0000"+ + "\u0000\u0191\u0189\u0001\u0000\u0000\u0000\u0191\u0192\u0001\u0000\u0000"+ + "\u0000\u0192\u0193\u0001\u0000\u0000\u0000\u0193\u0194\u0005\u000b\u0000"+ + "\u0000\u0194E\u0001\u0000\u0000\u0000\u0195\u0196\u0005+\u0000\u0000\u0196"+ + "\u0197\u0003\u001c\u000e\u0000\u0197\u0198\u0005,\u0000\u0000\u0198\u0199"+ + "\u0003H$\u0000\u0199\u019a\u0005-\u0000\u0000\u019aG\u0001\u0000\u0000"+ + "\u0000\u019b\u01a0\u0003J%\u0000\u019c\u019d\u0005!\u0000\u0000\u019d"+ + "\u019f\u0003J%\u0000\u019e\u019c\u0001\u0000\u0000\u0000\u019f\u01a2\u0001"+ + "\u0000\u0000\u0000\u01a0\u019e\u0001\u0000\u0000\u0000\u01a0\u01a1\u0001"+ + "\u0000\u0000\u0000\u01a1I\u0001\u0000\u0000\u0000\u01a2\u01a0\u0001\u0000"+ + "\u0000\u0000\u01a3\u01a4\u00038\u001c\u0000\u01a4\u01a5\u0005.\u0000\u0000"+ + "\u01a5\u01a6\u0003\u0004\u0002\u0000\u01a6K\u0001\u0000\u0000\u0000\'"+ + "O\\_bgqy|\u0082\u008c\u009a\u00a8\u00b1\u00b5\u00bb\u00c4\u00cd\u00ea"+ + "\u00f2\u00f5\u00ff\u0102\u010d\u0110\u0113\u011a\u0123\u0127\u014e\u0151"+ + "\u0168\u0173\u0176\u0179\u0181\u0184\u018e\u0191\u01a0"; + 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/org/programsnail/truffle_lama/parser/LamaVisitor.java b/src/main/java/org/programsnail/truffle_lama/parser/LamaVisitor.java new file mode 100644 index 0000000..d88565a --- /dev/null +++ b/src/main/java/org/programsnail/truffle_lama/parser/LamaVisitor.java @@ -0,0 +1,241 @@ +// Generated from /home/dragon/Containers/DevGraalVM/src/truffle-lama-from-scratch/src/main/java/org/programsnail/truffle_lama/parser/Lama.g4 by ANTLR 4.13.2 +package org.programsnail.truffle_lama.parser; +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link LamaParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface LamaVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link LamaParser#lama}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLama(LamaParser.LamaContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#import_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitImport_expression(LamaParser.Import_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#scope_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitScope_expression(LamaParser.Scope_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#definition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDefinition(LamaParser.DefinitionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#variable_definition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVariable_definition(LamaParser.Variable_definitionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#variable_definition_sequence}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#variable_definition_item}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitVariable_definition_item(LamaParser.Variable_definition_itemContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#function_definition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunction_definition(LamaParser.Function_definitionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#function_arguments}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunction_arguments(LamaParser.Function_argumentsContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#function_body}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunction_body(LamaParser.Function_bodyContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#infix_definition}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInfix_definition(LamaParser.Infix_definitionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#infix_head}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInfix_head(LamaParser.Infix_headContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#infixity}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitInfixity(LamaParser.InfixityContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#level}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLevel(LamaParser.LevelContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression(LamaParser.ExpressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#basic_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBasic_expression(LamaParser.Basic_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#binary_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitBinary_expression(LamaParser.Binary_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#postfix_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPostfix_expression(LamaParser.Postfix_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#postfix}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPostfix(LamaParser.PostfixContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#primary}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPrimary(LamaParser.PrimaryContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#array_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArray_expression(LamaParser.Array_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#list_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitList_expression(LamaParser.List_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#s_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitS_expression(LamaParser.S_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#if_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitIf_expression(LamaParser.If_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#else_part}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitElse_part(LamaParser.Else_partContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#while_do_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWhile_do_expression(LamaParser.While_do_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#do_while_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDo_while_expression(LamaParser.Do_while_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#for_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFor_expression(LamaParser.For_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#pattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPattern(LamaParser.PatternContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#cons_pattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCons_pattern(LamaParser.Cons_patternContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#simple_pattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitSimple_pattern(LamaParser.Simple_patternContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#wildcard_pattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitWildcard_pattern(LamaParser.Wildcard_patternContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#s_expr_pattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitS_expr_pattern(LamaParser.S_expr_patternContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#array_pattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitArray_pattern(LamaParser.Array_patternContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#list_pattern}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitList_pattern(LamaParser.List_patternContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#case_expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCase_expression(LamaParser.Case_expressionContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#case_branches}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCase_branches(LamaParser.Case_branchesContext ctx); + /** + * Visit a parse tree produced by {@link LamaParser#case_branch}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitCase_branch(LamaParser.Case_branchContext ctx); +} \ No newline at end of file