Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
Added visitForLoop() method and generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
maxschwinghammer committed Jun 5, 2024
1 parent 90bbe55 commit fcf81d5
Show file tree
Hide file tree
Showing 10 changed files with 545 additions and 0 deletions.
19 changes: 19 additions & 0 deletions gen/Example.interp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
token literal names:
null
'+'
null
null

token symbolic names:
null
null
INT_LIT
WS

rule names:
addition
const


atn:
[4, 1, 3, 15, 2, 0, 7, 0, 2, 1, 7, 1, 1, 0, 1, 0, 1, 0, 5, 0, 8, 8, 0, 10, 0, 12, 0, 11, 9, 0, 1, 1, 1, 1, 1, 1, 0, 0, 2, 0, 2, 0, 0, 13, 0, 4, 1, 0, 0, 0, 2, 12, 1, 0, 0, 0, 4, 9, 3, 2, 1, 0, 5, 6, 5, 1, 0, 0, 6, 8, 3, 2, 1, 0, 7, 5, 1, 0, 0, 0, 8, 11, 1, 0, 0, 0, 9, 7, 1, 0, 0, 0, 9, 10, 1, 0, 0, 0, 10, 1, 1, 0, 0, 0, 11, 9, 1, 0, 0, 0, 12, 13, 5, 2, 0, 0, 13, 3, 1, 0, 0, 0, 1, 9]
4 changes: 4 additions & 0 deletions gen/Example.tokens
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
T__0=1
INT_LIT=2
WS=3
'+'=1
63 changes: 63 additions & 0 deletions gen/ExampleBaseListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Generated from C:/IdeaProjects/compiler-design-lecture-project-TINF22B6/Example.g4 by ANTLR 4.13.1

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 ExampleListener},
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
@SuppressWarnings("CheckReturnValue")
public class ExampleBaseListener implements ExampleListener {
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAddition(ExampleParser.AdditionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAddition(ExampleParser.AdditionContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterConst(ExampleParser.ConstContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitConst(ExampleParser.ConstContext 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) { }
}
28 changes: 28 additions & 0 deletions gen/ExampleBaseVisitor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Generated from C:/IdeaProjects/compiler-design-lecture-project-TINF22B6/Example.g4 by ANTLR 4.13.1
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;

/**
* This class provides an empty implementation of {@link ExampleVisitor},
* 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 ExampleBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements ExampleVisitor<T> {
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitAddition(ExampleParser.AdditionContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitConst(ExampleParser.ConstContext ctx) { return visitChildren(ctx); }
}
26 changes: 26 additions & 0 deletions gen/ExampleLexer.interp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
token literal names:
null
'+'
null
null

token symbolic names:
null
null
INT_LIT
WS

rule names:
T__0
INT_LIT
WS

channel names:
DEFAULT_TOKEN_CHANNEL
HIDDEN

mode names:
DEFAULT_MODE

atn:
[4, 0, 3, 21, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 1, 0, 1, 0, 1, 1, 4, 1, 11, 8, 1, 11, 1, 12, 1, 12, 1, 2, 4, 2, 16, 8, 2, 11, 2, 12, 2, 17, 1, 2, 1, 2, 0, 0, 3, 1, 1, 3, 2, 5, 3, 1, 0, 2, 1, 0, 48, 57, 3, 0, 9, 10, 13, 13, 32, 32, 22, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 1, 7, 1, 0, 0, 0, 3, 10, 1, 0, 0, 0, 5, 15, 1, 0, 0, 0, 7, 8, 5, 43, 0, 0, 8, 2, 1, 0, 0, 0, 9, 11, 7, 0, 0, 0, 10, 9, 1, 0, 0, 0, 11, 12, 1, 0, 0, 0, 12, 10, 1, 0, 0, 0, 12, 13, 1, 0, 0, 0, 13, 4, 1, 0, 0, 0, 14, 16, 7, 1, 0, 0, 15, 14, 1, 0, 0, 0, 16, 17, 1, 0, 0, 0, 17, 15, 1, 0, 0, 0, 17, 18, 1, 0, 0, 0, 18, 19, 1, 0, 0, 0, 19, 20, 6, 2, 0, 0, 20, 6, 1, 0, 0, 0, 3, 0, 12, 17, 1, 6, 0, 0]
130 changes: 130 additions & 0 deletions gen/ExampleLexer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// Generated from C:/IdeaProjects/compiler-design-lecture-project-TINF22B6/Example.g4 by ANTLR 4.13.1
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;

@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"})
public class ExampleLexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }

protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
T__0=1, INT_LIT=2, WS=3;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};

public static String[] modeNames = {
"DEFAULT_MODE"
};

private static String[] makeRuleNames() {
return new String[] {
"T__0", "INT_LIT", "WS"
};
}
public static final String[] ruleNames = makeRuleNames();

private static String[] makeLiteralNames() {
return new String[] {
null, "'+'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, null, "INT_LIT", "WS"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);

/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}

if (tokenNames[i] == null) {
tokenNames[i] = "<INVALID>";
}
}
}

@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}

@Override

public Vocabulary getVocabulary() {
return VOCABULARY;
}


public ExampleLexer(CharStream input) {
super(input);
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}

@Override
public String getGrammarFileName() { return "Example.g4"; }

@Override
public String[] getRuleNames() { return ruleNames; }

@Override
public String getSerializedATN() { return _serializedATN; }

@Override
public String[] getChannelNames() { return channelNames; }

@Override
public String[] getModeNames() { return modeNames; }

@Override
public ATN getATN() { return _ATN; }

public static final String _serializedATN =
"\u0004\u0000\u0003\u0015\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002"+
"\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0001\u0000\u0001\u0000\u0001"+
"\u0001\u0004\u0001\u000b\b\u0001\u000b\u0001\f\u0001\f\u0001\u0002\u0004"+
"\u0002\u0010\b\u0002\u000b\u0002\f\u0002\u0011\u0001\u0002\u0001\u0002"+
"\u0000\u0000\u0003\u0001\u0001\u0003\u0002\u0005\u0003\u0001\u0000\u0002"+
"\u0001\u000009\u0003\u0000\t\n\r\r \u0016\u0000\u0001\u0001\u0000\u0000"+
"\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000"+
"\u0000\u0001\u0007\u0001\u0000\u0000\u0000\u0003\n\u0001\u0000\u0000\u0000"+
"\u0005\u000f\u0001\u0000\u0000\u0000\u0007\b\u0005+\u0000\u0000\b\u0002"+
"\u0001\u0000\u0000\u0000\t\u000b\u0007\u0000\u0000\u0000\n\t\u0001\u0000"+
"\u0000\u0000\u000b\f\u0001\u0000\u0000\u0000\f\n\u0001\u0000\u0000\u0000"+
"\f\r\u0001\u0000\u0000\u0000\r\u0004\u0001\u0000\u0000\u0000\u000e\u0010"+
"\u0007\u0001\u0000\u0000\u000f\u000e\u0001\u0000\u0000\u0000\u0010\u0011"+
"\u0001\u0000\u0000\u0000\u0011\u000f\u0001\u0000\u0000\u0000\u0011\u0012"+
"\u0001\u0000\u0000\u0000\u0012\u0013\u0001\u0000\u0000\u0000\u0013\u0014"+
"\u0006\u0002\u0000\u0000\u0014\u0006\u0001\u0000\u0000\u0000\u0003\u0000"+
"\f\u0011\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);
}
}
}
4 changes: 4 additions & 0 deletions gen/ExampleLexer.tokens
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
T__0=1
INT_LIT=2
WS=3
'+'=1
29 changes: 29 additions & 0 deletions gen/ExampleListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Generated from C:/IdeaProjects/compiler-design-lecture-project-TINF22B6/Example.g4 by ANTLR 4.13.1
import org.antlr.v4.runtime.tree.ParseTreeListener;

/**
* This interface defines a complete listener for a parse tree produced by
* {@link ExampleParser}.
*/
public interface ExampleListener extends ParseTreeListener {
/**
* Enter a parse tree produced by {@link ExampleParser#addition}.
* @param ctx the parse tree
*/
void enterAddition(ExampleParser.AdditionContext ctx);
/**
* Exit a parse tree produced by {@link ExampleParser#addition}.
* @param ctx the parse tree
*/
void exitAddition(ExampleParser.AdditionContext ctx);
/**
* Enter a parse tree produced by {@link ExampleParser#const}.
* @param ctx the parse tree
*/
void enterConst(ExampleParser.ConstContext ctx);
/**
* Exit a parse tree produced by {@link ExampleParser#const}.
* @param ctx the parse tree
*/
void exitConst(ExampleParser.ConstContext ctx);
}
Loading

0 comments on commit fcf81d5

Please sign in to comment.