@@ -0,0 +1,47 @@
|
||||
token literal names:
|
||||
null
|
||||
'('
|
||||
','
|
||||
')'
|
||||
'='
|
||||
'%'
|
||||
';'
|
||||
'{'
|
||||
'}'
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
|
||||
token symbolic names:
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
WS
|
||||
NUMBER
|
||||
HEX
|
||||
IDENTIFIER
|
||||
MATH
|
||||
STRING
|
||||
|
||||
rule names:
|
||||
round_def
|
||||
func_def
|
||||
var_def
|
||||
var_def_set
|
||||
asm
|
||||
expr
|
||||
code_block
|
||||
top
|
||||
|
||||
|
||||
atn:
|
||||
[4, 1, 14, 85, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 21, 8, 0, 10, 0, 12, 0, 24, 9, 0, 1, 0, 3, 0, 27, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 5, 4, 48, 8, 4, 10, 4, 12, 4, 51, 9, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 5, 5, 58, 8, 5, 10, 5, 12, 5, 61, 9, 5, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 67, 8, 6, 1, 6, 1, 6, 5, 6, 71, 8, 6, 10, 6, 12, 6, 74, 9, 6, 1, 6, 1, 6, 1, 7, 1, 7, 5, 7, 80, 8, 7, 10, 7, 12, 7, 83, 9, 7, 1, 7, 0, 0, 8, 0, 2, 4, 6, 8, 10, 12, 14, 0, 1, 2, 0, 10, 12, 14, 14, 85, 0, 16, 1, 0, 0, 0, 2, 30, 1, 0, 0, 0, 4, 35, 1, 0, 0, 0, 6, 38, 1, 0, 0, 0, 8, 42, 1, 0, 0, 0, 10, 54, 1, 0, 0, 0, 12, 62, 1, 0, 0, 0, 14, 81, 1, 0, 0, 0, 16, 17, 5, 1, 0, 0, 17, 22, 3, 4, 2, 0, 18, 19, 5, 2, 0, 0, 19, 21, 3, 4, 2, 0, 20, 18, 1, 0, 0, 0, 21, 24, 1, 0, 0, 0, 22, 20, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 26, 1, 0, 0, 0, 24, 22, 1, 0, 0, 0, 25, 27, 5, 2, 0, 0, 26, 25, 1, 0, 0, 0, 26, 27, 1, 0, 0, 0, 27, 28, 1, 0, 0, 0, 28, 29, 5, 3, 0, 0, 29, 1, 1, 0, 0, 0, 30, 31, 5, 12, 0, 0, 31, 32, 5, 12, 0, 0, 32, 33, 3, 0, 0, 0, 33, 34, 3, 12, 6, 0, 34, 3, 1, 0, 0, 0, 35, 36, 5, 12, 0, 0, 36, 37, 5, 12, 0, 0, 37, 5, 1, 0, 0, 0, 38, 39, 3, 4, 2, 0, 39, 40, 5, 4, 0, 0, 40, 41, 3, 10, 5, 0, 41, 7, 1, 0, 0, 0, 42, 43, 5, 5, 0, 0, 43, 44, 5, 12, 0, 0, 44, 49, 3, 10, 5, 0, 45, 46, 5, 2, 0, 0, 46, 48, 3, 10, 5, 0, 47, 45, 1, 0, 0, 0, 48, 51, 1, 0, 0, 0, 49, 47, 1, 0, 0, 0, 49, 50, 1, 0, 0, 0, 50, 52, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 52, 53, 5, 6, 0, 0, 53, 9, 1, 0, 0, 0, 54, 59, 7, 0, 0, 0, 55, 56, 5, 13, 0, 0, 56, 58, 3, 10, 5, 0, 57, 55, 1, 0, 0, 0, 58, 61, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 11, 1, 0, 0, 0, 61, 59, 1, 0, 0, 0, 62, 72, 5, 7, 0, 0, 63, 67, 3, 10, 5, 0, 64, 67, 3, 4, 2, 0, 65, 67, 3, 6, 3, 0, 66, 63, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 66, 65, 1, 0, 0, 0, 67, 68, 1, 0, 0, 0, 68, 69, 5, 6, 0, 0, 69, 71, 1, 0, 0, 0, 70, 66, 1, 0, 0, 0, 71, 74, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 72, 73, 1, 0, 0, 0, 73, 75, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 75, 76, 5, 8, 0, 0, 76, 13, 1, 0, 0, 0, 77, 80, 3, 8, 4, 0, 78, 80, 3, 2, 1, 0, 79, 77, 1, 0, 0, 0, 79, 78, 1, 0, 0, 0, 80, 83, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 15, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 8, 22, 26, 49, 59, 66, 72, 79, 81]
|
||||
@@ -0,0 +1,22 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
WS=9
|
||||
NUMBER=10
|
||||
HEX=11
|
||||
IDENTIFIER=12
|
||||
MATH=13
|
||||
STRING=14
|
||||
'('=1
|
||||
','=2
|
||||
')'=3
|
||||
'='=4
|
||||
'%'=5
|
||||
';'=6
|
||||
'{'=7
|
||||
'}'=8
|
||||
@@ -0,0 +1,60 @@
|
||||
token literal names:
|
||||
null
|
||||
'('
|
||||
','
|
||||
')'
|
||||
'='
|
||||
'%'
|
||||
';'
|
||||
'{'
|
||||
'}'
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
|
||||
token symbolic names:
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
WS
|
||||
NUMBER
|
||||
HEX
|
||||
IDENTIFIER
|
||||
MATH
|
||||
STRING
|
||||
|
||||
rule names:
|
||||
T__0
|
||||
T__1
|
||||
T__2
|
||||
T__3
|
||||
T__4
|
||||
T__5
|
||||
T__6
|
||||
T__7
|
||||
WS
|
||||
NUMBER
|
||||
HEX
|
||||
IDENTIFIER
|
||||
MATH
|
||||
ESC
|
||||
STRING
|
||||
|
||||
channel names:
|
||||
DEFAULT_TOKEN_CHANNEL
|
||||
HIDDEN
|
||||
|
||||
mode names:
|
||||
DEFAULT_MODE
|
||||
|
||||
atn:
|
||||
[4, 0, 14, 97, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 4, 8, 49, 8, 8, 11, 8, 12, 8, 50, 1, 8, 1, 8, 1, 9, 1, 9, 5, 9, 57, 8, 9, 10, 9, 12, 9, 60, 9, 9, 1, 9, 3, 9, 63, 8, 9, 1, 10, 1, 10, 1, 10, 1, 10, 5, 10, 69, 8, 10, 10, 10, 12, 10, 72, 9, 10, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 78, 8, 11, 10, 11, 12, 11, 81, 9, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 5, 14, 91, 8, 14, 10, 14, 12, 14, 94, 9, 14, 1, 14, 1, 14, 0, 0, 15, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 0, 29, 14, 1, 0, 9, 3, 0, 9, 10, 13, 13, 32, 32, 1, 0, 49, 57, 1, 0, 48, 57, 3, 0, 48, 57, 65, 70, 97, 102, 3, 0, 65, 90, 95, 95, 97, 122, 3, 0, 48, 57, 65, 90, 97, 122, 3, 0, 42, 43, 45, 45, 47, 47, 3, 0, 34, 34, 39, 39, 92, 92, 2, 0, 34, 34, 92, 92, 103, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 1, 31, 1, 0, 0, 0, 3, 33, 1, 0, 0, 0, 5, 35, 1, 0, 0, 0, 7, 37, 1, 0, 0, 0, 9, 39, 1, 0, 0, 0, 11, 41, 1, 0, 0, 0, 13, 43, 1, 0, 0, 0, 15, 45, 1, 0, 0, 0, 17, 48, 1, 0, 0, 0, 19, 62, 1, 0, 0, 0, 21, 64, 1, 0, 0, 0, 23, 73, 1, 0, 0, 0, 25, 82, 1, 0, 0, 0, 27, 84, 1, 0, 0, 0, 29, 87, 1, 0, 0, 0, 31, 32, 5, 40, 0, 0, 32, 2, 1, 0, 0, 0, 33, 34, 5, 44, 0, 0, 34, 4, 1, 0, 0, 0, 35, 36, 5, 41, 0, 0, 36, 6, 1, 0, 0, 0, 37, 38, 5, 61, 0, 0, 38, 8, 1, 0, 0, 0, 39, 40, 5, 37, 0, 0, 40, 10, 1, 0, 0, 0, 41, 42, 5, 59, 0, 0, 42, 12, 1, 0, 0, 0, 43, 44, 5, 123, 0, 0, 44, 14, 1, 0, 0, 0, 45, 46, 5, 125, 0, 0, 46, 16, 1, 0, 0, 0, 47, 49, 7, 0, 0, 0, 48, 47, 1, 0, 0, 0, 49, 50, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 53, 6, 8, 0, 0, 53, 18, 1, 0, 0, 0, 54, 58, 7, 1, 0, 0, 55, 57, 7, 2, 0, 0, 56, 55, 1, 0, 0, 0, 57, 60, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 63, 1, 0, 0, 0, 60, 58, 1, 0, 0, 0, 61, 63, 5, 48, 0, 0, 62, 54, 1, 0, 0, 0, 62, 61, 1, 0, 0, 0, 63, 20, 1, 0, 0, 0, 64, 65, 5, 48, 0, 0, 65, 66, 5, 120, 0, 0, 66, 70, 1, 0, 0, 0, 67, 69, 7, 3, 0, 0, 68, 67, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 22, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 79, 7, 4, 0, 0, 74, 78, 7, 5, 0, 0, 75, 76, 5, 58, 0, 0, 76, 78, 5, 58, 0, 0, 77, 74, 1, 0, 0, 0, 77, 75, 1, 0, 0, 0, 78, 81, 1, 0, 0, 0, 79, 77, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 24, 1, 0, 0, 0, 81, 79, 1, 0, 0, 0, 82, 83, 7, 6, 0, 0, 83, 26, 1, 0, 0, 0, 84, 85, 5, 92, 0, 0, 85, 86, 7, 7, 0, 0, 86, 28, 1, 0, 0, 0, 87, 92, 5, 34, 0, 0, 88, 91, 3, 27, 13, 0, 89, 91, 8, 8, 0, 0, 90, 88, 1, 0, 0, 0, 90, 89, 1, 0, 0, 0, 91, 94, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 95, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 95, 96, 5, 34, 0, 0, 96, 30, 1, 0, 0, 0, 9, 0, 50, 58, 62, 70, 77, 79, 90, 92, 1, 6, 0, 0]
|
||||
@@ -0,0 +1,175 @@
|
||||
// Generated from /Users/klestiselimaj/Developer/RustRoverProjects/wyst/Wyst.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 WystLexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, WS=9,
|
||||
NUMBER=10, HEX=11, IDENTIFIER=12, MATH=13, STRING=14;
|
||||
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", "WS",
|
||||
"NUMBER", "HEX", "IDENTIFIER", "MATH", "ESC", "STRING"
|
||||
};
|
||||
}
|
||||
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, null, null, null, null, null, null, null, "WS", "NUMBER",
|
||||
"HEX", "IDENTIFIER", "MATH", "STRING"
|
||||
};
|
||||
}
|
||||
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 WystLexer(CharStream input) {
|
||||
super(input);
|
||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "Wyst.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\u000ea\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\u0001"+
|
||||
"\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001"+
|
||||
"\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001"+
|
||||
"\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\b\u0004\b1\b\b\u000b"+
|
||||
"\b\f\b2\u0001\b\u0001\b\u0001\t\u0001\t\u0005\t9\b\t\n\t\f\t<\t\t\u0001"+
|
||||
"\t\u0003\t?\b\t\u0001\n\u0001\n\u0001\n\u0001\n\u0005\nE\b\n\n\n\f\nH"+
|
||||
"\t\n\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0005\u000bN\b\u000b"+
|
||||
"\n\u000b\f\u000bQ\t\u000b\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001"+
|
||||
"\u000e\u0001\u000e\u0001\u000e\u0005\u000e[\b\u000e\n\u000e\f\u000e^\t"+
|
||||
"\u000e\u0001\u000e\u0001\u000e\u0000\u0000\u000f\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\u0000\u001d\u000e\u0001\u0000\t\u0003"+
|
||||
"\u0000\t\n\r\r \u0001\u000019\u0001\u000009\u0003\u000009AFaf\u0003\u0000"+
|
||||
"AZ__az\u0003\u000009AZaz\u0003\u0000*+--//\u0003\u0000\"\"\'\'\\\\\u0002"+
|
||||
"\u0000\"\"\\\\g\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\u001d\u0001\u0000\u0000"+
|
||||
"\u0000\u0001\u001f\u0001\u0000\u0000\u0000\u0003!\u0001\u0000\u0000\u0000"+
|
||||
"\u0005#\u0001\u0000\u0000\u0000\u0007%\u0001\u0000\u0000\u0000\t\'\u0001"+
|
||||
"\u0000\u0000\u0000\u000b)\u0001\u0000\u0000\u0000\r+\u0001\u0000\u0000"+
|
||||
"\u0000\u000f-\u0001\u0000\u0000\u0000\u00110\u0001\u0000\u0000\u0000\u0013"+
|
||||
">\u0001\u0000\u0000\u0000\u0015@\u0001\u0000\u0000\u0000\u0017I\u0001"+
|
||||
"\u0000\u0000\u0000\u0019R\u0001\u0000\u0000\u0000\u001bT\u0001\u0000\u0000"+
|
||||
"\u0000\u001dW\u0001\u0000\u0000\u0000\u001f \u0005(\u0000\u0000 \u0002"+
|
||||
"\u0001\u0000\u0000\u0000!\"\u0005,\u0000\u0000\"\u0004\u0001\u0000\u0000"+
|
||||
"\u0000#$\u0005)\u0000\u0000$\u0006\u0001\u0000\u0000\u0000%&\u0005=\u0000"+
|
||||
"\u0000&\b\u0001\u0000\u0000\u0000\'(\u0005%\u0000\u0000(\n\u0001\u0000"+
|
||||
"\u0000\u0000)*\u0005;\u0000\u0000*\f\u0001\u0000\u0000\u0000+,\u0005{"+
|
||||
"\u0000\u0000,\u000e\u0001\u0000\u0000\u0000-.\u0005}\u0000\u0000.\u0010"+
|
||||
"\u0001\u0000\u0000\u0000/1\u0007\u0000\u0000\u00000/\u0001\u0000\u0000"+
|
||||
"\u000012\u0001\u0000\u0000\u000020\u0001\u0000\u0000\u000023\u0001\u0000"+
|
||||
"\u0000\u000034\u0001\u0000\u0000\u000045\u0006\b\u0000\u00005\u0012\u0001"+
|
||||
"\u0000\u0000\u00006:\u0007\u0001\u0000\u000079\u0007\u0002\u0000\u0000"+
|
||||
"87\u0001\u0000\u0000\u00009<\u0001\u0000\u0000\u0000:8\u0001\u0000\u0000"+
|
||||
"\u0000:;\u0001\u0000\u0000\u0000;?\u0001\u0000\u0000\u0000<:\u0001\u0000"+
|
||||
"\u0000\u0000=?\u00050\u0000\u0000>6\u0001\u0000\u0000\u0000>=\u0001\u0000"+
|
||||
"\u0000\u0000?\u0014\u0001\u0000\u0000\u0000@A\u00050\u0000\u0000AB\u0005"+
|
||||
"x\u0000\u0000BF\u0001\u0000\u0000\u0000CE\u0007\u0003\u0000\u0000DC\u0001"+
|
||||
"\u0000\u0000\u0000EH\u0001\u0000\u0000\u0000FD\u0001\u0000\u0000\u0000"+
|
||||
"FG\u0001\u0000\u0000\u0000G\u0016\u0001\u0000\u0000\u0000HF\u0001\u0000"+
|
||||
"\u0000\u0000IO\u0007\u0004\u0000\u0000JN\u0007\u0005\u0000\u0000KL\u0005"+
|
||||
":\u0000\u0000LN\u0005:\u0000\u0000MJ\u0001\u0000\u0000\u0000MK\u0001\u0000"+
|
||||
"\u0000\u0000NQ\u0001\u0000\u0000\u0000OM\u0001\u0000\u0000\u0000OP\u0001"+
|
||||
"\u0000\u0000\u0000P\u0018\u0001\u0000\u0000\u0000QO\u0001\u0000\u0000"+
|
||||
"\u0000RS\u0007\u0006\u0000\u0000S\u001a\u0001\u0000\u0000\u0000TU\u0005"+
|
||||
"\\\u0000\u0000UV\u0007\u0007\u0000\u0000V\u001c\u0001\u0000\u0000\u0000"+
|
||||
"W\\\u0005\"\u0000\u0000X[\u0003\u001b\r\u0000Y[\b\b\u0000\u0000ZX\u0001"+
|
||||
"\u0000\u0000\u0000ZY\u0001\u0000\u0000\u0000[^\u0001\u0000\u0000\u0000"+
|
||||
"\\Z\u0001\u0000\u0000\u0000\\]\u0001\u0000\u0000\u0000]_\u0001\u0000\u0000"+
|
||||
"\u0000^\\\u0001\u0000\u0000\u0000_`\u0005\"\u0000\u0000`\u001e\u0001\u0000"+
|
||||
"\u0000\u0000\t\u00002:>FMOZ\\\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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
T__0=1
|
||||
T__1=2
|
||||
T__2=3
|
||||
T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
T__7=8
|
||||
WS=9
|
||||
NUMBER=10
|
||||
HEX=11
|
||||
IDENTIFIER=12
|
||||
MATH=13
|
||||
STRING=14
|
||||
'('=1
|
||||
','=2
|
||||
')'=3
|
||||
'='=4
|
||||
'%'=5
|
||||
';'=6
|
||||
'{'=7
|
||||
'}'=8
|
||||
@@ -0,0 +1,625 @@
|
||||
// Generated from /Users/klestiselimaj/Developer/RustRoverProjects/wyst/Wyst.g4 by ANTLR 4.13.1
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.antlr.v4.runtime.*;
|
||||
import org.antlr.v4.runtime.misc.*;
|
||||
import org.antlr.v4.runtime.tree.*;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"})
|
||||
public class WystParser extends Parser {
|
||||
static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, WS=9,
|
||||
NUMBER=10, HEX=11, IDENTIFIER=12, MATH=13, STRING=14;
|
||||
public static final int
|
||||
RULE_round_def = 0, RULE_func_def = 1, RULE_var_def = 2, RULE_var_def_set = 3,
|
||||
RULE_asm = 4, RULE_expr = 5, RULE_code_block = 6, RULE_top = 7;
|
||||
private static String[] makeRuleNames() {
|
||||
return new String[] {
|
||||
"round_def", "func_def", "var_def", "var_def_set", "asm", "expr", "code_block",
|
||||
"top"
|
||||
};
|
||||
}
|
||||
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, null, null, null, null, null, null, null, "WS", "NUMBER",
|
||||
"HEX", "IDENTIFIER", "MATH", "STRING"
|
||||
};
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGrammarFileName() { return "Wyst.g4"; }
|
||||
|
||||
@Override
|
||||
public String[] getRuleNames() { return ruleNames; }
|
||||
|
||||
@Override
|
||||
public String getSerializedATN() { return _serializedATN; }
|
||||
|
||||
@Override
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public WystParser(TokenStream input) {
|
||||
super(input);
|
||||
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class Round_defContext extends ParserRuleContext {
|
||||
public List<Var_defContext> var_def() {
|
||||
return getRuleContexts(Var_defContext.class);
|
||||
}
|
||||
public Var_defContext var_def(int i) {
|
||||
return getRuleContext(Var_defContext.class,i);
|
||||
}
|
||||
public Round_defContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_round_def; }
|
||||
}
|
||||
|
||||
public final Round_defContext round_def() throws RecognitionException {
|
||||
Round_defContext _localctx = new Round_defContext(_ctx, getState());
|
||||
enterRule(_localctx, 0, RULE_round_def);
|
||||
int _la;
|
||||
try {
|
||||
int _alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(16);
|
||||
match(T__0);
|
||||
setState(17);
|
||||
var_def();
|
||||
setState(22);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,0,_ctx);
|
||||
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
|
||||
if ( _alt==1 ) {
|
||||
{
|
||||
{
|
||||
setState(18);
|
||||
match(T__1);
|
||||
setState(19);
|
||||
var_def();
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(24);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,0,_ctx);
|
||||
}
|
||||
setState(26);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
if (_la==T__1) {
|
||||
{
|
||||
setState(25);
|
||||
match(T__1);
|
||||
}
|
||||
}
|
||||
|
||||
setState(28);
|
||||
match(T__2);
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class Func_defContext extends ParserRuleContext {
|
||||
public List<TerminalNode> IDENTIFIER() { return getTokens(WystParser.IDENTIFIER); }
|
||||
public TerminalNode IDENTIFIER(int i) {
|
||||
return getToken(WystParser.IDENTIFIER, i);
|
||||
}
|
||||
public Round_defContext round_def() {
|
||||
return getRuleContext(Round_defContext.class,0);
|
||||
}
|
||||
public Code_blockContext code_block() {
|
||||
return getRuleContext(Code_blockContext.class,0);
|
||||
}
|
||||
public Func_defContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_func_def; }
|
||||
}
|
||||
|
||||
public final Func_defContext func_def() throws RecognitionException {
|
||||
Func_defContext _localctx = new Func_defContext(_ctx, getState());
|
||||
enterRule(_localctx, 2, RULE_func_def);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(30);
|
||||
match(IDENTIFIER);
|
||||
setState(31);
|
||||
match(IDENTIFIER);
|
||||
setState(32);
|
||||
round_def();
|
||||
setState(33);
|
||||
code_block();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class Var_defContext extends ParserRuleContext {
|
||||
public List<TerminalNode> IDENTIFIER() { return getTokens(WystParser.IDENTIFIER); }
|
||||
public TerminalNode IDENTIFIER(int i) {
|
||||
return getToken(WystParser.IDENTIFIER, i);
|
||||
}
|
||||
public Var_defContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_var_def; }
|
||||
}
|
||||
|
||||
public final Var_defContext var_def() throws RecognitionException {
|
||||
Var_defContext _localctx = new Var_defContext(_ctx, getState());
|
||||
enterRule(_localctx, 4, RULE_var_def);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(35);
|
||||
match(IDENTIFIER);
|
||||
setState(36);
|
||||
match(IDENTIFIER);
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class Var_def_setContext extends ParserRuleContext {
|
||||
public Var_defContext var_def() {
|
||||
return getRuleContext(Var_defContext.class,0);
|
||||
}
|
||||
public ExprContext expr() {
|
||||
return getRuleContext(ExprContext.class,0);
|
||||
}
|
||||
public Var_def_setContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_var_def_set; }
|
||||
}
|
||||
|
||||
public final Var_def_setContext var_def_set() throws RecognitionException {
|
||||
Var_def_setContext _localctx = new Var_def_setContext(_ctx, getState());
|
||||
enterRule(_localctx, 6, RULE_var_def_set);
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(38);
|
||||
var_def();
|
||||
setState(39);
|
||||
match(T__3);
|
||||
setState(40);
|
||||
expr();
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class AsmContext extends ParserRuleContext {
|
||||
public TerminalNode IDENTIFIER() { return getToken(WystParser.IDENTIFIER, 0); }
|
||||
public List<ExprContext> expr() {
|
||||
return getRuleContexts(ExprContext.class);
|
||||
}
|
||||
public ExprContext expr(int i) {
|
||||
return getRuleContext(ExprContext.class,i);
|
||||
}
|
||||
public AsmContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_asm; }
|
||||
}
|
||||
|
||||
public final AsmContext asm() throws RecognitionException {
|
||||
AsmContext _localctx = new AsmContext(_ctx, getState());
|
||||
enterRule(_localctx, 8, RULE_asm);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(42);
|
||||
match(T__4);
|
||||
setState(43);
|
||||
match(IDENTIFIER);
|
||||
setState(44);
|
||||
expr();
|
||||
setState(49);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while (_la==T__1) {
|
||||
{
|
||||
{
|
||||
setState(45);
|
||||
match(T__1);
|
||||
setState(46);
|
||||
expr();
|
||||
}
|
||||
}
|
||||
setState(51);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
setState(52);
|
||||
match(T__5);
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class ExprContext extends ParserRuleContext {
|
||||
public TerminalNode NUMBER() { return getToken(WystParser.NUMBER, 0); }
|
||||
public TerminalNode HEX() { return getToken(WystParser.HEX, 0); }
|
||||
public TerminalNode IDENTIFIER() { return getToken(WystParser.IDENTIFIER, 0); }
|
||||
public TerminalNode STRING() { return getToken(WystParser.STRING, 0); }
|
||||
public List<TerminalNode> MATH() { return getTokens(WystParser.MATH); }
|
||||
public TerminalNode MATH(int i) {
|
||||
return getToken(WystParser.MATH, i);
|
||||
}
|
||||
public List<ExprContext> expr() {
|
||||
return getRuleContexts(ExprContext.class);
|
||||
}
|
||||
public ExprContext expr(int i) {
|
||||
return getRuleContext(ExprContext.class,i);
|
||||
}
|
||||
public ExprContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_expr; }
|
||||
}
|
||||
|
||||
public final ExprContext expr() throws RecognitionException {
|
||||
ExprContext _localctx = new ExprContext(_ctx, getState());
|
||||
enterRule(_localctx, 10, RULE_expr);
|
||||
int _la;
|
||||
try {
|
||||
int _alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(54);
|
||||
_la = _input.LA(1);
|
||||
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 23552L) != 0)) ) {
|
||||
_errHandler.recoverInline(this);
|
||||
}
|
||||
else {
|
||||
if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
|
||||
_errHandler.reportMatch(this);
|
||||
consume();
|
||||
}
|
||||
setState(59);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,3,_ctx);
|
||||
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
|
||||
if ( _alt==1 ) {
|
||||
{
|
||||
{
|
||||
setState(55);
|
||||
match(MATH);
|
||||
setState(56);
|
||||
expr();
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(61);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,3,_ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class Code_blockContext extends ParserRuleContext {
|
||||
public List<ExprContext> expr() {
|
||||
return getRuleContexts(ExprContext.class);
|
||||
}
|
||||
public ExprContext expr(int i) {
|
||||
return getRuleContext(ExprContext.class,i);
|
||||
}
|
||||
public List<Var_defContext> var_def() {
|
||||
return getRuleContexts(Var_defContext.class);
|
||||
}
|
||||
public Var_defContext var_def(int i) {
|
||||
return getRuleContext(Var_defContext.class,i);
|
||||
}
|
||||
public List<Var_def_setContext> var_def_set() {
|
||||
return getRuleContexts(Var_def_setContext.class);
|
||||
}
|
||||
public Var_def_setContext var_def_set(int i) {
|
||||
return getRuleContext(Var_def_setContext.class,i);
|
||||
}
|
||||
public Code_blockContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_code_block; }
|
||||
}
|
||||
|
||||
public final Code_blockContext code_block() throws RecognitionException {
|
||||
Code_blockContext _localctx = new Code_blockContext(_ctx, getState());
|
||||
enterRule(_localctx, 12, RULE_code_block);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(62);
|
||||
match(T__6);
|
||||
setState(72);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 23552L) != 0)) {
|
||||
{
|
||||
{
|
||||
setState(66);
|
||||
_errHandler.sync(this);
|
||||
switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) {
|
||||
case 1:
|
||||
{
|
||||
setState(63);
|
||||
expr();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
setState(64);
|
||||
var_def();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
setState(65);
|
||||
var_def_set();
|
||||
}
|
||||
break;
|
||||
}
|
||||
setState(68);
|
||||
match(T__5);
|
||||
}
|
||||
}
|
||||
setState(74);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
setState(75);
|
||||
match(T__7);
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class TopContext extends ParserRuleContext {
|
||||
public List<AsmContext> asm() {
|
||||
return getRuleContexts(AsmContext.class);
|
||||
}
|
||||
public AsmContext asm(int i) {
|
||||
return getRuleContext(AsmContext.class,i);
|
||||
}
|
||||
public List<Func_defContext> func_def() {
|
||||
return getRuleContexts(Func_defContext.class);
|
||||
}
|
||||
public Func_defContext func_def(int i) {
|
||||
return getRuleContext(Func_defContext.class,i);
|
||||
}
|
||||
public TopContext(ParserRuleContext parent, int invokingState) {
|
||||
super(parent, invokingState);
|
||||
}
|
||||
@Override public int getRuleIndex() { return RULE_top; }
|
||||
}
|
||||
|
||||
public final TopContext top() throws RecognitionException {
|
||||
TopContext _localctx = new TopContext(_ctx, getState());
|
||||
enterRule(_localctx, 14, RULE_top);
|
||||
int _la;
|
||||
try {
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(81);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
while (_la==T__4 || _la==IDENTIFIER) {
|
||||
{
|
||||
setState(79);
|
||||
_errHandler.sync(this);
|
||||
switch (_input.LA(1)) {
|
||||
case T__4:
|
||||
{
|
||||
setState(77);
|
||||
asm();
|
||||
}
|
||||
break;
|
||||
case IDENTIFIER:
|
||||
{
|
||||
setState(78);
|
||||
func_def();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new NoViableAltException(this);
|
||||
}
|
||||
}
|
||||
setState(83);
|
||||
_errHandler.sync(this);
|
||||
_la = _input.LA(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (RecognitionException re) {
|
||||
_localctx.exception = re;
|
||||
_errHandler.reportError(this, re);
|
||||
_errHandler.recover(this, re);
|
||||
}
|
||||
finally {
|
||||
exitRule();
|
||||
}
|
||||
return _localctx;
|
||||
}
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\u0004\u0001\u000eU\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\u0001"+
|
||||
"\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0005\u0000\u0015\b\u0000\n"+
|
||||
"\u0000\f\u0000\u0018\t\u0000\u0001\u0000\u0003\u0000\u001b\b\u0000\u0001"+
|
||||
"\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
|
||||
"\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001"+
|
||||
"\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001"+
|
||||
"\u0004\u0005\u00040\b\u0004\n\u0004\f\u00043\t\u0004\u0001\u0004\u0001"+
|
||||
"\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0005\u0005:\b\u0005\n\u0005"+
|
||||
"\f\u0005=\t\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0003"+
|
||||
"\u0006C\b\u0006\u0001\u0006\u0001\u0006\u0005\u0006G\b\u0006\n\u0006\f"+
|
||||
"\u0006J\t\u0006\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0005"+
|
||||
"\u0007P\b\u0007\n\u0007\f\u0007S\t\u0007\u0001\u0007\u0000\u0000\b\u0000"+
|
||||
"\u0002\u0004\u0006\b\n\f\u000e\u0000\u0001\u0002\u0000\n\f\u000e\u000e"+
|
||||
"U\u0000\u0010\u0001\u0000\u0000\u0000\u0002\u001e\u0001\u0000\u0000\u0000"+
|
||||
"\u0004#\u0001\u0000\u0000\u0000\u0006&\u0001\u0000\u0000\u0000\b*\u0001"+
|
||||
"\u0000\u0000\u0000\n6\u0001\u0000\u0000\u0000\f>\u0001\u0000\u0000\u0000"+
|
||||
"\u000eQ\u0001\u0000\u0000\u0000\u0010\u0011\u0005\u0001\u0000\u0000\u0011"+
|
||||
"\u0016\u0003\u0004\u0002\u0000\u0012\u0013\u0005\u0002\u0000\u0000\u0013"+
|
||||
"\u0015\u0003\u0004\u0002\u0000\u0014\u0012\u0001\u0000\u0000\u0000\u0015"+
|
||||
"\u0018\u0001\u0000\u0000\u0000\u0016\u0014\u0001\u0000\u0000\u0000\u0016"+
|
||||
"\u0017\u0001\u0000\u0000\u0000\u0017\u001a\u0001\u0000\u0000\u0000\u0018"+
|
||||
"\u0016\u0001\u0000\u0000\u0000\u0019\u001b\u0005\u0002\u0000\u0000\u001a"+
|
||||
"\u0019\u0001\u0000\u0000\u0000\u001a\u001b\u0001\u0000\u0000\u0000\u001b"+
|
||||
"\u001c\u0001\u0000\u0000\u0000\u001c\u001d\u0005\u0003\u0000\u0000\u001d"+
|
||||
"\u0001\u0001\u0000\u0000\u0000\u001e\u001f\u0005\f\u0000\u0000\u001f "+
|
||||
"\u0005\f\u0000\u0000 !\u0003\u0000\u0000\u0000!\"\u0003\f\u0006\u0000"+
|
||||
"\"\u0003\u0001\u0000\u0000\u0000#$\u0005\f\u0000\u0000$%\u0005\f\u0000"+
|
||||
"\u0000%\u0005\u0001\u0000\u0000\u0000&\'\u0003\u0004\u0002\u0000\'(\u0005"+
|
||||
"\u0004\u0000\u0000()\u0003\n\u0005\u0000)\u0007\u0001\u0000\u0000\u0000"+
|
||||
"*+\u0005\u0005\u0000\u0000+,\u0005\f\u0000\u0000,1\u0003\n\u0005\u0000"+
|
||||
"-.\u0005\u0002\u0000\u0000.0\u0003\n\u0005\u0000/-\u0001\u0000\u0000\u0000"+
|
||||
"03\u0001\u0000\u0000\u00001/\u0001\u0000\u0000\u000012\u0001\u0000\u0000"+
|
||||
"\u000024\u0001\u0000\u0000\u000031\u0001\u0000\u0000\u000045\u0005\u0006"+
|
||||
"\u0000\u00005\t\u0001\u0000\u0000\u00006;\u0007\u0000\u0000\u000078\u0005"+
|
||||
"\r\u0000\u00008:\u0003\n\u0005\u000097\u0001\u0000\u0000\u0000:=\u0001"+
|
||||
"\u0000\u0000\u0000;9\u0001\u0000\u0000\u0000;<\u0001\u0000\u0000\u0000"+
|
||||
"<\u000b\u0001\u0000\u0000\u0000=;\u0001\u0000\u0000\u0000>H\u0005\u0007"+
|
||||
"\u0000\u0000?C\u0003\n\u0005\u0000@C\u0003\u0004\u0002\u0000AC\u0003\u0006"+
|
||||
"\u0003\u0000B?\u0001\u0000\u0000\u0000B@\u0001\u0000\u0000\u0000BA\u0001"+
|
||||
"\u0000\u0000\u0000CD\u0001\u0000\u0000\u0000DE\u0005\u0006\u0000\u0000"+
|
||||
"EG\u0001\u0000\u0000\u0000FB\u0001\u0000\u0000\u0000GJ\u0001\u0000\u0000"+
|
||||
"\u0000HF\u0001\u0000\u0000\u0000HI\u0001\u0000\u0000\u0000IK\u0001\u0000"+
|
||||
"\u0000\u0000JH\u0001\u0000\u0000\u0000KL\u0005\b\u0000\u0000L\r\u0001"+
|
||||
"\u0000\u0000\u0000MP\u0003\b\u0004\u0000NP\u0003\u0002\u0001\u0000OM\u0001"+
|
||||
"\u0000\u0000\u0000ON\u0001\u0000\u0000\u0000PS\u0001\u0000\u0000\u0000"+
|
||||
"QO\u0001\u0000\u0000\u0000QR\u0001\u0000\u0000\u0000R\u000f\u0001\u0000"+
|
||||
"\u0000\u0000SQ\u0001\u0000\u0000\u0000\b\u0016\u001a1;BHOQ";
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+90
-4
@@ -1,8 +1,94 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ast := Parse("abc123::hello")
|
||||
fmt.Printf("%v", ast)
|
||||
type wmap [2]string
|
||||
|
||||
var wyst_map []wmap
|
||||
|
||||
func TranspileToken(node ASTNode) string {
|
||||
res := ""
|
||||
switch node.Rule {
|
||||
|
||||
case "NUMBER":
|
||||
res += node.Text
|
||||
case "IDENTIFIER":
|
||||
for _, i := range wyst_map {
|
||||
if node.Text == i[0] {
|
||||
return i[1]
|
||||
}
|
||||
}
|
||||
res += "_0x"
|
||||
for _, c := range node.Text {
|
||||
if c == ':' || c == '.' {
|
||||
res += string(c)
|
||||
} else {
|
||||
res += fmt.Sprintf("%x", c)
|
||||
}
|
||||
}
|
||||
case "HEX":
|
||||
res += node.Text
|
||||
case "MATH":
|
||||
res += node.Text
|
||||
case "STRING":
|
||||
res += node.Text
|
||||
case "';'":
|
||||
res += "\n "
|
||||
default:
|
||||
fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing token case for '%s'\n", node.Rule)
|
||||
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func TranspileNode(node ASTNode) string {
|
||||
res := ""
|
||||
if node.Rule == strings.ToUpper(node.Rule) {
|
||||
return TranspileToken(node)
|
||||
}
|
||||
switch node.Rule {
|
||||
|
||||
case "func_def":
|
||||
res += fmt.Sprintf("func %s%s %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[2]), TranspileNode(node.Inner[0]), TranspileNode(node.Inner[3]))
|
||||
case "expr":
|
||||
res += TranspileNodes(node.Inner)
|
||||
case "code_block":
|
||||
res += "{\n "
|
||||
res += strings.TrimSuffix(TranspileNodes(node.Inner), " ")
|
||||
res += "}\n"
|
||||
case "var_def":
|
||||
res += fmt.Sprintf("var %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[0]))
|
||||
case "round_def":
|
||||
res += "("
|
||||
res += strings.TrimSuffix(strings.ReplaceAll(TranspileNodes(node.Inner), "var ", ""), " ")
|
||||
res += ")"
|
||||
case "asm":
|
||||
if node.Inner[0].Text == "map" && len(node.Inner) == 4 {
|
||||
wyst_map = append(wyst_map, wmap{node.Inner[1].Text, node.Inner[2].Text})
|
||||
}
|
||||
|
||||
default:
|
||||
fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing case for '%s'\n", node.Rule)
|
||||
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func TranspileNodes(nodes []ASTNode) string {
|
||||
res := ""
|
||||
for i := 0; i < len(nodes); i++ {
|
||||
res += TranspileNode(nodes[i])
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func Transpile(code string) string {
|
||||
ast := Parse(code)
|
||||
res := TranspileNodes(ast.Inner)
|
||||
// fmt.Printf("%v", ast)
|
||||
return res
|
||||
}
|
||||
|
||||
+5
-2
@@ -36,7 +36,10 @@ func ConvertAST(node antlr.Tree, wparser *parser.WystParser, lexer *parser.WystL
|
||||
ast.Text = parseTree.GetText()
|
||||
}
|
||||
for i := 0; i < node.GetChildCount(); i++ {
|
||||
ast.Inner = append(ast.Inner, ConvertAST(node.GetChild(i), wparser, lexer))
|
||||
l := ConvertAST(node.GetChild(i), wparser, lexer)
|
||||
if l.Rule != ("'"+l.Text+"'") || l.Text == ";" {
|
||||
ast.Inner = append(ast.Inner, l)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ast
|
||||
@@ -48,6 +51,6 @@ func Parse(code string) ASTNode {
|
||||
stream := antlr.NewCommonTokenStream(lexer, 0)
|
||||
p := parser.NewWystParser(stream)
|
||||
// p.AddErrorListener(antlr.NewDiagnosticErrorListener(true).WithContext(p))
|
||||
tree := p.Expr()
|
||||
tree := p.Top()
|
||||
return ConvertAST(tree, p, lexer)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type wmap [2]string
|
||||
|
||||
var wyst_map []wmap
|
||||
|
||||
func TranspileToken(node ASTNode) string {
|
||||
res := ""
|
||||
switch node.Rule {
|
||||
|
||||
case "NUMBER":
|
||||
res += node.Text
|
||||
case "IDENTIFIER":
|
||||
for _, i := range wyst_map {
|
||||
if node.Text == i[0] {
|
||||
return i[1]
|
||||
}
|
||||
}
|
||||
res += "_0x"
|
||||
for _, c := range node.Text {
|
||||
if c == ':' || c == '.' {
|
||||
res += string(c)
|
||||
} else {
|
||||
res += fmt.Sprintf("%x", c)
|
||||
}
|
||||
}
|
||||
case "HEX":
|
||||
res += node.Text
|
||||
case "MATH":
|
||||
res += node.Text
|
||||
case "STRING":
|
||||
res += node.Text
|
||||
case "';'":
|
||||
res += "\n "
|
||||
default:
|
||||
fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing token case for '%s'\n", node.Rule)
|
||||
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func TranspileNode(node ASTNode) string {
|
||||
res := ""
|
||||
if node.Rule == strings.ToUpper(node.Rule) {
|
||||
return TranspileToken(node)
|
||||
}
|
||||
switch node.Rule {
|
||||
|
||||
case "func_def":
|
||||
res += fmt.Sprintf("func %s%s %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[2]), TranspileNode(node.Inner[0]), TranspileNode(node.Inner[3]))
|
||||
case "expr":
|
||||
res += TranspileNodes(node.Inner)
|
||||
case "code_block":
|
||||
res += "{\n "
|
||||
res += strings.TrimSuffix(TranspileNodes(node.Inner), " ")
|
||||
res += "}\n"
|
||||
case "var_def":
|
||||
res += fmt.Sprintf("var %s %s", TranspileNode(node.Inner[1]), TranspileNode(node.Inner[0]))
|
||||
case "round_def":
|
||||
res += "("
|
||||
res += strings.TrimSuffix(strings.ReplaceAll(TranspileNodes(node.Inner), "var ", ""), " ")
|
||||
res += ")"
|
||||
case "asm":
|
||||
if node.Inner[0].Text == "map" && len(node.Inner) == 4 {
|
||||
wyst_map = append(wyst_map, wmap{node.Inner[1].Text, node.Inner[2].Text})
|
||||
}
|
||||
|
||||
default:
|
||||
fmt.Printf("\x1b[33mDEV NOTICE:\x1b[0m Missing case for '%s'\n", node.Rule)
|
||||
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func TranspileNodes(nodes []ASTNode) string {
|
||||
res := ""
|
||||
for i := 0; i < len(nodes); i++ {
|
||||
res += TranspileNode(nodes[i])
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
func Transpile(code string) string {
|
||||
ast := Parse(code)
|
||||
res := TranspileNodes(ast.Inner)
|
||||
// fmt.Printf("%v", ast)
|
||||
return res
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/antlr4-go/antlr"
|
||||
"github.com/wyst-lang/wyst/parser"
|
||||
)
|
||||
|
||||
func iterateTree(node antlr.Tree, wparser *parser.WystParser, depth int) {
|
||||
if ruleContext, ok := node.(antlr.RuleContext); ok {
|
||||
ruleIndex := ruleContext.GetRuleIndex()
|
||||
ruleName := wparser.RuleNames[ruleIndex]
|
||||
fmt.Printf("%sRule: %s\n", indent(depth), ruleName)
|
||||
}
|
||||
|
||||
if parseTree, ok := node.(antlr.ParseTree); ok {
|
||||
fmt.Printf("%sNode: %s\n", indent(depth), parseTree.GetText())
|
||||
}
|
||||
|
||||
for i := 0; i < node.GetChildCount(); i++ {
|
||||
child := node.GetChild(i)
|
||||
iterateTree(child, wparser, depth+1)
|
||||
}
|
||||
}
|
||||
|
||||
func indent(depth int) string {
|
||||
return fmt.Sprintf("%s", string(make([]byte, depth*2)))
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
%map test, bruh
|
||||
Reference in New Issue
Block a user