init, parser generation (without attributes), attempts to build basic lang class

This commit is contained in:
ProgramSnail 2025-02-16 17:04:11 +03:00
parent 8401a5418d
commit a149766007
22 changed files with 6363 additions and 17 deletions

7
.idea/encodings.xml generated Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

9
README.md Normal file
View file

@ -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
---

37
pom.xml
View file

@ -12,6 +12,43 @@
<maven.compiler.source>23</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<graalvm.version>23.1.0</graalvm.version>
<antlr.version>4.12.0</antlr.version>
</properties>
<dependencies>
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>polyglot</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-runtime</artifactId>
<version>${graalvm.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-tck</artifactId>
<version>${graalvm.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr.version}</version>
</dependency>
</dependencies>
</project>

View file

@ -1,17 +0,0 @@
package org.programsnail;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
public static void main(String[] args) {
//TIP Press <shortcut actionId="ShowIntentionActions"/> 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 <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
System.out.println("i = " + i);
}
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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<LamaContext> {
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<LamaLanguage> REFERENCE = LanguageReference.create(LamaLanguage.class);
private static final List<NodeFactory<? extends LamaBuiltinNode>> 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<NodeFactory<? extends LamaBuiltinNode>, RootCallTarget> builtinTargets = new ConcurrentHashMap<>();
private final Map<TruffleString, RootCallTarget> 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<? extends LamaBuiltinNode> 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<TruffleString, RootCallTarget> 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<? extends LamaBuiltinNode> 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();
}
}

View file

@ -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();
}
}
}

View file

@ -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 {}

View file

@ -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);
}

View file

@ -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<? extends Tag> 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));
}
}

View file

@ -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<TruffleString, RootCallTarget> 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*;

File diff suppressed because one or more lines are too long

View file

@ -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

View file

@ -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}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterLama(LamaParser.LamaContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLama(LamaParser.LamaContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterImport_expression(LamaParser.Import_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitImport_expression(LamaParser.Import_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterScope_expression(LamaParser.Scope_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitScope_expression(LamaParser.Scope_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterDefinition(LamaParser.DefinitionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDefinition(LamaParser.DefinitionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterVariable_definition(LamaParser.Variable_definitionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitVariable_definition(LamaParser.Variable_definitionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterVariable_definition_item(LamaParser.Variable_definition_itemContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitVariable_definition_item(LamaParser.Variable_definition_itemContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFunction_definition(LamaParser.Function_definitionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFunction_definition(LamaParser.Function_definitionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFunction_arguments(LamaParser.Function_argumentsContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFunction_arguments(LamaParser.Function_argumentsContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFunction_body(LamaParser.Function_bodyContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFunction_body(LamaParser.Function_bodyContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterInfix_definition(LamaParser.Infix_definitionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitInfix_definition(LamaParser.Infix_definitionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterInfix_head(LamaParser.Infix_headContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitInfix_head(LamaParser.Infix_headContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterInfixity(LamaParser.InfixityContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitInfixity(LamaParser.InfixityContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterLevel(LamaParser.LevelContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitLevel(LamaParser.LevelContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterExpression(LamaParser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitExpression(LamaParser.ExpressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBasic_expression(LamaParser.Basic_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBasic_expression(LamaParser.Basic_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterBinary_expression(LamaParser.Binary_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitBinary_expression(LamaParser.Binary_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterPostfix_expression(LamaParser.Postfix_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitPostfix_expression(LamaParser.Postfix_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterPostfix(LamaParser.PostfixContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitPostfix(LamaParser.PostfixContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterPrimary(LamaParser.PrimaryContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitPrimary(LamaParser.PrimaryContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterArray_expression(LamaParser.Array_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitArray_expression(LamaParser.Array_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterList_expression(LamaParser.List_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitList_expression(LamaParser.List_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterS_expression(LamaParser.S_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitS_expression(LamaParser.S_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterIf_expression(LamaParser.If_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitIf_expression(LamaParser.If_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterElse_part(LamaParser.Else_partContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitElse_part(LamaParser.Else_partContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterWhile_do_expression(LamaParser.While_do_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitWhile_do_expression(LamaParser.While_do_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterDo_while_expression(LamaParser.Do_while_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDo_while_expression(LamaParser.Do_while_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterFor_expression(LamaParser.For_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitFor_expression(LamaParser.For_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterPattern(LamaParser.PatternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitPattern(LamaParser.PatternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterCons_pattern(LamaParser.Cons_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitCons_pattern(LamaParser.Cons_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterSimple_pattern(LamaParser.Simple_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitSimple_pattern(LamaParser.Simple_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterWildcard_pattern(LamaParser.Wildcard_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitWildcard_pattern(LamaParser.Wildcard_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterS_expr_pattern(LamaParser.S_expr_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitS_expr_pattern(LamaParser.S_expr_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterArray_pattern(LamaParser.Array_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitArray_pattern(LamaParser.Array_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterList_pattern(LamaParser.List_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitList_pattern(LamaParser.List_patternContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterCase_expression(LamaParser.Case_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitCase_expression(LamaParser.Case_expressionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterCase_branches(LamaParser.Case_branchesContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitCase_branches(LamaParser.Case_branchesContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterCase_branch(LamaParser.Case_branchContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitCase_branch(LamaParser.Case_branchContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitTerminal(TerminalNode node) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitErrorNode(ErrorNode node) { }
}

View file

@ -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 <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
@SuppressWarnings("CheckReturnValue")
public class LamaBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements LamaVisitor<T> {
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLama(LamaParser.LamaContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitImport_expression(LamaParser.Import_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitScope_expression(LamaParser.Scope_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDefinition(LamaParser.DefinitionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitVariable_definition(LamaParser.Variable_definitionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitVariable_definition_sequence(LamaParser.Variable_definition_sequenceContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitVariable_definition_item(LamaParser.Variable_definition_itemContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFunction_definition(LamaParser.Function_definitionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFunction_arguments(LamaParser.Function_argumentsContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFunction_body(LamaParser.Function_bodyContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitInfix_definition(LamaParser.Infix_definitionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitInfix_head(LamaParser.Infix_headContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitInfixity(LamaParser.InfixityContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitLevel(LamaParser.LevelContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitExpression(LamaParser.ExpressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBasic_expression(LamaParser.Basic_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitBinary_expression(LamaParser.Binary_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitPostfix_expression(LamaParser.Postfix_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitPostfix(LamaParser.PostfixContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitPrimary(LamaParser.PrimaryContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitArray_expression(LamaParser.Array_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitList_expression(LamaParser.List_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitS_expression(LamaParser.S_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitIf_expression(LamaParser.If_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitElse_part(LamaParser.Else_partContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitWhile_do_expression(LamaParser.While_do_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDo_while_expression(LamaParser.Do_while_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitFor_expression(LamaParser.For_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitPattern(LamaParser.PatternContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitCons_pattern(LamaParser.Cons_patternContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitSimple_pattern(LamaParser.Simple_patternContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitWildcard_pattern(LamaParser.Wildcard_patternContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitS_expr_pattern(LamaParser.S_expr_patternContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitArray_pattern(LamaParser.Array_patternContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitList_pattern(LamaParser.List_patternContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitCase_expression(LamaParser.Case_expressionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitCase_branches(LamaParser.Case_branchesContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitCase_branch(LamaParser.Case_branchContext ctx) { return visitChildren(ctx); }
}

File diff suppressed because one or more lines are too long

View file

@ -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] = "<INVALID>";
}
}
}
@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);
}
}
}

View file

@ -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

View file

@ -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);
}

File diff suppressed because it is too large Load diff

View file

@ -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 <T> The return type of the visit operation. Use {@link Void} for
* operations with no return type.
*/
public interface LamaVisitor<T> extends ParseTreeVisitor<T> {
/**
* 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);
}