├── .gitattributes
├── .gitignore
├── .replit
├── 84Script
├── Test.efs
├── Test.ti
├── build.gradle
└── src
│ └── main
│ ├── antlr
│ ├── EFScript.g4
│ └── TiBasic.g4
│ └── java
│ └── com
│ └── efscript
│ ├── Logger.java
│ ├── Main.java
│ ├── antlr
│ ├── EFScriptBaseListener.java
│ ├── EFScriptBaseVisitor.java
│ ├── EFScriptLexer.java
│ ├── EFScriptListener.java
│ ├── EFScriptParser.java
│ ├── EFScriptVisitor.java
│ ├── TiBasicBaseListener.java
│ ├── TiBasicBaseVisitor.java
│ ├── TiBasicLexer.java
│ ├── TiBasicListener.java
│ ├── TiBasicParser.java
│ └── TiBasicVisitor.java
│ ├── script
│ ├── ABlock.java
│ ├── Context.java
│ ├── EFSCompiler.java
│ ├── IBlock.java
│ └── blocks
│ │ ├── EFSFunctionBlock.java
│ │ ├── EFSGenericExpression.java
│ │ ├── EFSScriptBlock.java
│ │ ├── EFSStatementBlock.java
│ │ ├── EFSValueBlock.java
│ │ ├── expressions
│ │ ├── EFSBoolexprBlock.java
│ │ ├── EFSCallBlock.java
│ │ └── EFSExpressionBlock.java
│ │ └── statements
│ │ ├── EFSAddAssignBlock.java
│ │ ├── EFSAssignBlock.java
│ │ ├── EFSBracketBlock.java
│ │ ├── EFSDecBlock.java
│ │ ├── EFSDivAssignBlock.java
│ │ ├── EFSIfBlock.java
│ │ ├── EFSIncBlock.java
│ │ ├── EFSMulAssignBlock.java
│ │ ├── EFSReturnBlock.java
│ │ ├── EFSSubAssignBlock.java
│ │ ├── EFSTiBasicBlock.java
│ │ ├── EFSVarBlock.java
│ │ └── EFSWhileBlock.java
│ └── ti
│ ├── ByteArray.java
│ ├── TiCompiler.java
│ ├── TiDecompiler.java
│ ├── TiFile.java
│ ├── TiPreProcessor.java
│ ├── TiToken.java
│ ├── VariableData.java
│ └── VariableEntry.java
├── LICENSE
├── README.md
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitattributes:
--------------------------------------------------------------------------------
1 | #
2 | # https://help.github.com/articles/dealing-with-line-endings/
3 | #
4 | # These are explicitly windows files and should use crlf
5 | *.bat text eol=crlf
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 | # Ignore Gradle project-specific cache directory
3 | .gradle
4 |
5 | # Ignore Gradle build output directory
6 | build
7 |
8 | .settings/
9 | .vscode/
10 | .idea/
11 | buildSrc/
12 | .antlr/
13 | *.classpath
14 | .classpath
15 | *.project
16 | .project
17 | bin/
18 | build/
19 | *.interp
20 | *.tokens
21 | *.8xp
--------------------------------------------------------------------------------
/.replit:
--------------------------------------------------------------------------------
1 | language = "java11"
2 | run = "./gradlew run"
--------------------------------------------------------------------------------
/84Script/Test.efs:
--------------------------------------------------------------------------------
1 | /*
2 | Script metadata
3 | */
4 | name: EPIC;
5 |
6 | /*
7 | Script code
8 | */
9 |
10 | def recursive(i) {
11 | if(i < 100) {
12 | var x = recursive(i+1);
13 | return i + x;
14 | }
15 | return i;
16 | }
17 |
18 | var z = recursive(1);
19 | __tibasic {
20 | DISP z
21 | }
--------------------------------------------------------------------------------
/84Script/Test.ti:
--------------------------------------------------------------------------------
1 | DISP"HEY"
--------------------------------------------------------------------------------
/84Script/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'antlr'
3 | id 'application'
4 | }
5 |
6 | repositories {
7 | mavenCentral()
8 | }
9 |
10 | dependencies {
11 | antlr group: 'org.antlr', name: 'antlr4', version: '4.9.1'
12 | implementation group: 'org.antlr', name: 'antlr4-runtime', version: '4.9.1'
13 | // https://mvnrepository.com/artifact/commons-cli/commons-cli
14 | implementation group: 'commons-cli', name: 'commons-cli', version: '1.4'
15 | }
16 |
17 | generateGrammarSource {
18 | maxHeapSize = "64m"
19 | arguments += ["-visitor", "-long-messages"]
20 | outputDirectory = file("src/main/java/com/efscript/antlr")
21 | }
22 |
23 | sourceCompatibility = 11
24 |
25 | application {
26 | // Define the main class for the application.
27 | mainClass = 'com.efscript.Main'
28 | }
29 |
30 | sourceSets {
31 | main {
32 | java {
33 | srcDirs = ["src/main/java"]
34 | }
35 | resources {
36 | srcDirs = ["src/main/resources"]
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/84Script/src/main/antlr/EFScript.g4:
--------------------------------------------------------------------------------
1 | grammar EFScript;
2 |
3 | @header {
4 | package com.efscript.antlr;
5 | }
6 |
7 |
8 | script
9 | : header function* statement*
10 | | EOF
11 | ;
12 |
13 | header
14 | : meta include*
15 | ;
16 |
17 | meta
18 | : scriptName
19 | ;
20 |
21 | scriptName
22 | : 'name:' identifier END_STMT
23 | ;
24 |
25 | include
26 | : 'include:' identifier END_STMT
27 | ;
28 |
29 | function
30 | : 'def' identifier OPEN_BRACKET func_params CLOSE_BRACKET statement
31 | ;
32 | func_params
33 | : identifier* (',' identifier)*
34 | ;
35 |
36 | statement
37 | : OPEN_CURLEY statement* CLOSE_CURLEY
38 | | assign_stmt
39 | | ti_basic_stmt
40 | | add_assign_stmt
41 | | sub_assign_stmt
42 | | mul_assign_stmt
43 | | div_assign_stmt
44 | | inc_stmt
45 | | dec_stmt
46 | | if_stmt
47 | | while_stmt
48 | | var_stmt
49 | | return_stmt
50 | | expression END_STMT
51 | | END_STMT
52 | ;
53 |
54 | assign_stmt
55 | : identifier ASSIGN expression END_STMT
56 | ;
57 | ti_basic_stmt
58 | : '__tibasic' '{' any '}'
59 | ;
60 | any : ( . )+?;
61 | add_assign_stmt
62 | : identifier ADDASSIGN value END_STMT
63 | ;
64 | sub_assign_stmt
65 | : identifier SUBASSIGN value END_STMT
66 | ;
67 | mul_assign_stmt
68 | : identifier MULASSIGN value END_STMT
69 | ;
70 | div_assign_stmt
71 | : identifier DIVASSIGN value END_STMT
72 | ;
73 | inc_stmt
74 | : identifier INCREMENT END_STMT
75 | ;
76 | dec_stmt
77 | : identifier DECREMENT END_STMT
78 | ;
79 | if_stmt
80 | : IF OPEN_BRACKET boolexpr CLOSE_BRACKET statement
81 | ;
82 | while_stmt
83 | : WHILE OPEN_BRACKET boolexpr CLOSE_BRACKET statement
84 | ;
85 | var_stmt
86 | : VAR identifier ASSIGN expression END_STMT
87 | ;
88 | return_stmt
89 | : RETURN expression END_STMT
90 | ;
91 |
92 | //Expression
93 | expression
94 | : OPEN_BRACKET expression CLOSE_BRACKET
95 | | expression ADD expression
96 | | expression SUB expression
97 | | expression MUL expression
98 | | expression DIV expression
99 | | value
100 | | boolexpr
101 | | QUOTED_TEXT
102 | | methodcall
103 | ;
104 |
105 | //Boolean expression
106 | boolexpr
107 | : value
108 | | TRUE
109 | | FALSE
110 | | value GREATER_THAN boolexpr
111 | | value LESS_THAN boolexpr
112 | | value EQUAL_TO boolexpr
113 | | value NOT_EQUAL_TO boolexpr
114 | | value GREATER_THAN_OR_EQUAL boolexpr
115 | | value LESS_THAN_OR_EQUAL boolexpr
116 | | value OR boolexpr
117 | | value AND boolexpr
118 | ;
119 |
120 |
121 |
122 | methodcall
123 | : identifier OPEN_BRACKET methodparams CLOSE_BRACKET
124 | ;
125 |
126 | methodparams
127 | : expression* (',' expression)*
128 | ;
129 |
130 | //Syntax operators
131 | OPEN_BRACKET : '(';
132 | CLOSE_BRACKET : ')';
133 | OPEN_CURLEY : '{';
134 | CLOSE_CURLEY : '}';
135 | END_STMT : ';';
136 |
137 | //Mathematic operators
138 | ADD : '+';
139 | SUB : '-';
140 | MUL : '*';
141 | DIV : '/';
142 |
143 | //Boolean operators
144 | GREATER_THAN : '>';
145 | LESS_THAN : '<';
146 | EQUAL_TO : '==';
147 | NOT_EQUAL_TO : '!=';
148 | GREATER_THAN_OR_EQUAL : '>=';
149 | LESS_THAN_OR_EQUAL : '<=';
150 | OR : '||';
151 | AND : '&&';
152 |
153 | //Assignment operators
154 | ASSIGN : '=';
155 | ADDASSIGN : '+=';
156 | SUBASSIGN : '-=';
157 | MULASSIGN : '*=';
158 | DIVASSIGN : '/=';
159 |
160 | //Incremental operators
161 | INCREMENT : '++';
162 | DECREMENT : '--';
163 |
164 | //Basic keywords & concepts
165 | DEF : 'def';
166 | VAR : 'var';
167 | STR : 'str'; //Same as Var but for strings
168 | IF : 'if';
169 | WHILE : 'while';
170 | RETURN : 'return';
171 | TRUE : 'true';
172 | FALSE : 'false';
173 |
174 |
175 | value
176 | : identifier
177 | | number
178 | ;
179 |
180 | identifier
181 | : IDENTIFIER
182 | ;
183 |
184 | IDENTIFIER : [a-zA-Z][a-zA-Z0-9_]*;
185 | number
186 | : NUMBER
187 | | PI
188 | | E
189 | | I
190 | ;
191 |
192 |
193 | //Numbers
194 | NUMBER
195 | : '-'? INT ('.' [0-9] +)?
196 | ;
197 |
198 | //Mathematic constants
199 | PI : 'pi';
200 | E : 'e';
201 | I : 'i';
202 |
203 | fragment INT
204 | : '0' | [1-9] [0-9]*
205 | ;
206 | QUOTED_TEXT : '"' ~ ["\r\n]* '"';
207 |
208 | //Stuff we wanna ignore
209 | LINECOMMENT : '//' ~[\r\n]* -> skip;
210 | BLOCKCOMMENT : '/*' .*? '*/' -> skip;
211 | WHITESPACE : [ \t\r\n] -> skip;
--------------------------------------------------------------------------------
/84Script/src/main/antlr/TiBasic.g4:
--------------------------------------------------------------------------------
1 | grammar TiBasic;
2 |
3 | @header {
4 | package com.efscript.antlr;
5 | }
6 |
7 | script
8 | : token*
9 | | EOF
10 | ;
11 |
12 | token
13 | : number
14 | | colon
15 | | if_
16 | | then
17 | | end
18 | | pi
19 | | e
20 | | i
21 | | letter
22 | | quote
23 | | disp
24 | | input
25 | | newline
26 | | comma
27 | | store
28 | | period
29 | | equals
30 | | space
31 | | list
32 | | open_bracket
33 | | close_bracket
34 | | semicolon
35 | ;
36 |
37 | //Tokens
38 | disp : 'DISP';
39 | input : 'INPUT';
40 | store : '->';
41 | if_ : 'IF'; //Has an _ because it conflicts with java's 'if' in code generation
42 | then : 'THEN';
43 | end : 'END';
44 | list : 'LIST' number;
45 | space : ' ';
46 |
47 | //Letters (Ti-basic variables & text)
48 | quote : '"';
49 | letter : LETTER;
50 | LETTER : [A-Z];
51 |
52 | //Symbols
53 | colon : ':';
54 | semicolon : ';';
55 | comma : ',';
56 | period : '.';
57 | open_bracket : '(';
58 | close_bracket : ')';
59 |
60 | //Math operations
61 | equals : '=';
62 |
63 | //Numbers
64 | number : NUMBER;
65 | NUMBER
66 | : [0-9]
67 | ;
68 |
69 | //Mathematic constants
70 | pi : 'pi';
71 | e : 'e';
72 | i : 'i';
73 |
74 | fragment INT
75 | : '0' | [1-9] [0-9]*
76 | ;
77 |
78 | newline : '\n';
79 |
80 | //Stuff we wanna ignore
81 | LINECOMMENT : '//' ~[\r\n]* -> skip;
82 | BLOCKCOMMENT : '/*' .*? '*/' -> skip;
83 | WHITESPACE : [ \t\r\n] -> skip;
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/Logger.java:
--------------------------------------------------------------------------------
1 | package com.efscript;
2 |
3 | public class Logger
4 | {
5 | public static void Log(Object toLog)
6 | {
7 | System.out.println("[84Script] "+toLog.toString());
8 | }
9 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/Main.java:
--------------------------------------------------------------------------------
1 | package com.efscript;
2 |
3 | import java.io.File;
4 | import java.nio.file.Files;
5 | import java.nio.file.Paths;
6 | import java.util.Collection;
7 |
8 | import com.efscript.script.EFSCompiler;
9 | import com.efscript.ti.TiCompiler;
10 | import com.efscript.ti.TiDecompiler;
11 | import com.efscript.ti.TiFile;
12 | import com.efscript.ti.TiToken;
13 |
14 | import org.apache.commons.cli.CommandLine;
15 | import org.apache.commons.cli.CommandLineParser;
16 | import org.apache.commons.cli.DefaultParser;
17 | import org.apache.commons.cli.HelpFormatter;
18 | import org.apache.commons.cli.Option;
19 | import org.apache.commons.cli.OptionBuilder;
20 | import org.apache.commons.cli.Options;
21 |
22 | public class Main {
23 | private enum Lang{
24 | EFS,
25 | TIB;
26 |
27 | private Lang() {
28 |
29 | }
30 | public String getName() {
31 | return this.toString();
32 | }
33 | public static Lang getLang(String str) throws Exception {
34 | for(Lang l : Lang.values()) {
35 | if(l.getName().equalsIgnoreCase(str)) {
36 | return l;
37 | }
38 | }
39 | throw new Exception("Unsupported language \""+str+"\"");
40 | }
41 | }
42 |
43 | // EFSCompiler version
44 | public static final String version = "0.0.1";
45 | public static final String fileDesc = "Compiled with 84Script (" + version + ")";
46 |
47 | //Default option values
48 | public static String prgmName = "ESFG"; //84Script Generated
49 | public static String inputFile = "Source.efs";
50 | public static String outputFile;
51 | public static Lang targetLang = Lang.EFS;
52 | public static boolean printResult = false;
53 |
54 | // Entry function
55 | public static void main(String[] args) throws Exception {
56 | //testCompileTI();
57 | //Apache commons-cli options
58 | Options options = new Options();
59 | Option help = Option.builder("h").longOpt("help").desc("Help menu").required(false).build();
60 | options.addOption(help);
61 | Option file = Option.builder("f").longOpt("file").hasArg().desc("Source file to compile").numberOfArgs(1).argName("File name").required(false).build();
62 | options.addOption(file);
63 | Option out = Option.builder("o").longOpt("output").hasArg().desc("Output file path").numberOfArgs(1).argName("File name").required(false).build();
64 | options.addOption(out);
65 | Option lang = Option.builder("l").longOpt("lang").hasArg().desc("Language to compile (EFS or TIB)").numberOfArgs(1).argName("Target language (EFS or TIB)").required(false).build();
66 | options.addOption(lang);
67 | Option useTib = Option.builder("ti").desc("Compile just Ti-Basic. Shorter alternative to -l TIB").required(false).build();
68 | options.addOption(useTib);
69 | Option useEfs = Option.builder("efs").desc("Compile just 84Script. Shorter alternative to -l EFS").required(false).build();
70 | options.addOption(useEfs);
71 | Option printRes = Option.builder("p").longOpt("print").desc("Print the compiled bytecode in Ti-Basic form to the console").required(false).build();
72 | options.addOption(printRes);
73 |
74 | //Command arg parser stuff
75 | CommandLineParser parser = new DefaultParser();
76 | CommandLine cmd = parser.parse(options, args);
77 |
78 | //If no commands are provided
79 | if(cmd.getArgs().length == 0) {
80 | Logger.Log("No args provided! Use '-h' for help.");
81 | return;
82 | }
83 | //Help argument
84 | if(cmd.hasOption("h")) {
85 | HelpFormatter formatter = new HelpFormatter();
86 | formatter.printHelp("84Script", options);
87 | return;
88 | }
89 | //Options
90 | if(cmd.hasOption("f")) {
91 | inputFile = cmd.getOptionValue("f");
92 | }
93 | if(cmd.hasOption("o")) {
94 | outputFile = cmd.getOptionValue("o");
95 | }
96 | if(cmd.hasOption("l")) {
97 | String langTarget = cmd.getOptionValue("l");
98 | targetLang = Lang.getLang(langTarget);
99 | }
100 | if(cmd.hasOption("ti")) {
101 | targetLang = Lang.TIB;
102 | }
103 | if(cmd.hasOption("efs")) {
104 | targetLang = Lang.EFS;
105 | }
106 | if(cmd.hasOption("p")) {
107 | printResult = true;
108 | }
109 |
110 | //Read input file
111 | String code = Files.readString(Paths.get(inputFile));
112 |
113 | //Compile code
114 | TiToken[] programCode;
115 | if(targetLang == Lang.TIB) {
116 | TiCompiler compiler = new TiCompiler(code);
117 | programCode = compiler.getTokens();
118 | }
119 | else {
120 | EFSCompiler compiler = new EFSCompiler(code);
121 | if(outputFile == null) {
122 | String scriptName = compiler.getMetaScriptName();
123 | outputFile = scriptName + ".8xp";
124 | prgmName = scriptName;
125 | }
126 | programCode = compiler.getTokens();
127 | }
128 |
129 | //Generate the output file
130 | if(printResult) {
131 | for(TiToken token : programCode) {
132 | System.out.print(token.str);
133 | }
134 | }
135 | TiFile outFile = new TiFile(prgmName, programCode);
136 | byte[] fileData = outFile.pack();
137 |
138 | //Output file creation
139 | File jFile = new File(outputFile);
140 | if (!jFile.exists()) {
141 | jFile.createNewFile();
142 | }
143 | jFile.setWritable(true);
144 | Files.write(jFile.toPath(), fileData);
145 | }
146 |
147 | static boolean testCompileEF() {
148 | try {
149 | // Compile "Test.efs"
150 | String code = Files.readString(Paths.get("Test.efs"));
151 | EFSCompiler compiler = new EFSCompiler(code);
152 | byte[] compiled = compiler.compile();
153 | TiDecompiler decomp = new TiDecompiler(compiled);
154 | Logger.Log("EFS TEST RESULTS");
155 | Logger.Log(decomp.getCode());
156 |
157 | TiFile newFile = new TiFile("TEST", decomp.decompile());
158 | byte[] fileBytes = newFile.pack();
159 | File jFile = new File("Gen.8xp");
160 | if (!jFile.exists()) {
161 | jFile.createNewFile();
162 | }
163 | jFile.setWritable(true);
164 | Files.write(jFile.toPath(), fileBytes);
165 |
166 | return true;
167 | } catch (Exception ex) {
168 | ex.printStackTrace();
169 | return false;
170 | }
171 | }
172 |
173 | static boolean testCompileTI() {
174 | try {
175 | // Compile "Test.efs"
176 | String code = Files.readString(Paths.get("Test.ti"));
177 | TiCompiler comp = new TiCompiler(code);
178 | TiFile tiFile = new TiFile("PROG02", comp.getTokens());
179 | byte[] fileContent = tiFile.pack();
180 | File jFile = new File("Gen.8xp");
181 | if (!jFile.exists()) {
182 | jFile.createNewFile();
183 | }
184 | jFile.setWritable(true);
185 | Files.write(jFile.toPath(), fileContent);
186 | byte[] compiled = comp.compile();
187 |
188 | TiDecompiler decomp = new TiDecompiler(compiled);
189 | Logger.Log("TI TEST RESULTS");
190 | Logger.Log(decomp.getCode());
191 |
192 | return true;
193 | } catch (Exception ex) {
194 | ex.printStackTrace();
195 | return false;
196 | }
197 | }
198 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/EFScriptBaseListener.java:
--------------------------------------------------------------------------------
1 | // Generated from EFScript.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 |
6 | import org.antlr.v4.runtime.ParserRuleContext;
7 | import org.antlr.v4.runtime.tree.ErrorNode;
8 | import org.antlr.v4.runtime.tree.TerminalNode;
9 |
10 | /**
11 | * This class provides an empty implementation of {@link EFScriptListener},
12 | * which can be extended to create a listener which only needs to handle a subset
13 | * of the available methods.
14 | */
15 | public class EFScriptBaseListener implements EFScriptListener {
16 | /**
17 | * {@inheritDoc}
18 | *
19 | *
The default implementation does nothing.
20 | */
21 | @Override public void enterScript(EFScriptParser.ScriptContext ctx) { }
22 | /**
23 | * {@inheritDoc}
24 | *
25 | * The default implementation does nothing.
26 | */
27 | @Override public void exitScript(EFScriptParser.ScriptContext ctx) { }
28 | /**
29 | * {@inheritDoc}
30 | *
31 | * The default implementation does nothing.
32 | */
33 | @Override public void enterHeader(EFScriptParser.HeaderContext ctx) { }
34 | /**
35 | * {@inheritDoc}
36 | *
37 | * The default implementation does nothing.
38 | */
39 | @Override public void exitHeader(EFScriptParser.HeaderContext ctx) { }
40 | /**
41 | * {@inheritDoc}
42 | *
43 | * The default implementation does nothing.
44 | */
45 | @Override public void enterMeta(EFScriptParser.MetaContext ctx) { }
46 | /**
47 | * {@inheritDoc}
48 | *
49 | * The default implementation does nothing.
50 | */
51 | @Override public void exitMeta(EFScriptParser.MetaContext ctx) { }
52 | /**
53 | * {@inheritDoc}
54 | *
55 | * The default implementation does nothing.
56 | */
57 | @Override public void enterScriptName(EFScriptParser.ScriptNameContext ctx) { }
58 | /**
59 | * {@inheritDoc}
60 | *
61 | * The default implementation does nothing.
62 | */
63 | @Override public void exitScriptName(EFScriptParser.ScriptNameContext ctx) { }
64 | /**
65 | * {@inheritDoc}
66 | *
67 | * The default implementation does nothing.
68 | */
69 | @Override public void enterInclude(EFScriptParser.IncludeContext ctx) { }
70 | /**
71 | * {@inheritDoc}
72 | *
73 | * The default implementation does nothing.
74 | */
75 | @Override public void exitInclude(EFScriptParser.IncludeContext ctx) { }
76 | /**
77 | * {@inheritDoc}
78 | *
79 | * The default implementation does nothing.
80 | */
81 | @Override public void enterFunction(EFScriptParser.FunctionContext ctx) { }
82 | /**
83 | * {@inheritDoc}
84 | *
85 | * The default implementation does nothing.
86 | */
87 | @Override public void exitFunction(EFScriptParser.FunctionContext ctx) { }
88 | /**
89 | * {@inheritDoc}
90 | *
91 | * The default implementation does nothing.
92 | */
93 | @Override public void enterFunc_params(EFScriptParser.Func_paramsContext ctx) { }
94 | /**
95 | * {@inheritDoc}
96 | *
97 | * The default implementation does nothing.
98 | */
99 | @Override public void exitFunc_params(EFScriptParser.Func_paramsContext ctx) { }
100 | /**
101 | * {@inheritDoc}
102 | *
103 | * The default implementation does nothing.
104 | */
105 | @Override public void enterStatement(EFScriptParser.StatementContext ctx) { }
106 | /**
107 | * {@inheritDoc}
108 | *
109 | * The default implementation does nothing.
110 | */
111 | @Override public void exitStatement(EFScriptParser.StatementContext ctx) { }
112 | /**
113 | * {@inheritDoc}
114 | *
115 | * The default implementation does nothing.
116 | */
117 | @Override public void enterAssign_stmt(EFScriptParser.Assign_stmtContext ctx) { }
118 | /**
119 | * {@inheritDoc}
120 | *
121 | * The default implementation does nothing.
122 | */
123 | @Override public void exitAssign_stmt(EFScriptParser.Assign_stmtContext ctx) { }
124 | /**
125 | * {@inheritDoc}
126 | *
127 | * The default implementation does nothing.
128 | */
129 | @Override public void enterTi_basic_stmt(EFScriptParser.Ti_basic_stmtContext ctx) { }
130 | /**
131 | * {@inheritDoc}
132 | *
133 | * The default implementation does nothing.
134 | */
135 | @Override public void exitTi_basic_stmt(EFScriptParser.Ti_basic_stmtContext ctx) { }
136 | /**
137 | * {@inheritDoc}
138 | *
139 | * The default implementation does nothing.
140 | */
141 | @Override public void enterAny(EFScriptParser.AnyContext ctx) { }
142 | /**
143 | * {@inheritDoc}
144 | *
145 | * The default implementation does nothing.
146 | */
147 | @Override public void exitAny(EFScriptParser.AnyContext ctx) { }
148 | /**
149 | * {@inheritDoc}
150 | *
151 | * The default implementation does nothing.
152 | */
153 | @Override public void enterAdd_assign_stmt(EFScriptParser.Add_assign_stmtContext ctx) { }
154 | /**
155 | * {@inheritDoc}
156 | *
157 | * The default implementation does nothing.
158 | */
159 | @Override public void exitAdd_assign_stmt(EFScriptParser.Add_assign_stmtContext ctx) { }
160 | /**
161 | * {@inheritDoc}
162 | *
163 | * The default implementation does nothing.
164 | */
165 | @Override public void enterSub_assign_stmt(EFScriptParser.Sub_assign_stmtContext ctx) { }
166 | /**
167 | * {@inheritDoc}
168 | *
169 | * The default implementation does nothing.
170 | */
171 | @Override public void exitSub_assign_stmt(EFScriptParser.Sub_assign_stmtContext ctx) { }
172 | /**
173 | * {@inheritDoc}
174 | *
175 | * The default implementation does nothing.
176 | */
177 | @Override public void enterMul_assign_stmt(EFScriptParser.Mul_assign_stmtContext ctx) { }
178 | /**
179 | * {@inheritDoc}
180 | *
181 | * The default implementation does nothing.
182 | */
183 | @Override public void exitMul_assign_stmt(EFScriptParser.Mul_assign_stmtContext ctx) { }
184 | /**
185 | * {@inheritDoc}
186 | *
187 | * The default implementation does nothing.
188 | */
189 | @Override public void enterDiv_assign_stmt(EFScriptParser.Div_assign_stmtContext ctx) { }
190 | /**
191 | * {@inheritDoc}
192 | *
193 | * The default implementation does nothing.
194 | */
195 | @Override public void exitDiv_assign_stmt(EFScriptParser.Div_assign_stmtContext ctx) { }
196 | /**
197 | * {@inheritDoc}
198 | *
199 | * The default implementation does nothing.
200 | */
201 | @Override public void enterInc_stmt(EFScriptParser.Inc_stmtContext ctx) { }
202 | /**
203 | * {@inheritDoc}
204 | *
205 | * The default implementation does nothing.
206 | */
207 | @Override public void exitInc_stmt(EFScriptParser.Inc_stmtContext ctx) { }
208 | /**
209 | * {@inheritDoc}
210 | *
211 | * The default implementation does nothing.
212 | */
213 | @Override public void enterDec_stmt(EFScriptParser.Dec_stmtContext ctx) { }
214 | /**
215 | * {@inheritDoc}
216 | *
217 | * The default implementation does nothing.
218 | */
219 | @Override public void exitDec_stmt(EFScriptParser.Dec_stmtContext ctx) { }
220 | /**
221 | * {@inheritDoc}
222 | *
223 | * The default implementation does nothing.
224 | */
225 | @Override public void enterIf_stmt(EFScriptParser.If_stmtContext ctx) { }
226 | /**
227 | * {@inheritDoc}
228 | *
229 | * The default implementation does nothing.
230 | */
231 | @Override public void exitIf_stmt(EFScriptParser.If_stmtContext ctx) { }
232 | /**
233 | * {@inheritDoc}
234 | *
235 | * The default implementation does nothing.
236 | */
237 | @Override public void enterWhile_stmt(EFScriptParser.While_stmtContext ctx) { }
238 | /**
239 | * {@inheritDoc}
240 | *
241 | * The default implementation does nothing.
242 | */
243 | @Override public void exitWhile_stmt(EFScriptParser.While_stmtContext ctx) { }
244 | /**
245 | * {@inheritDoc}
246 | *
247 | * The default implementation does nothing.
248 | */
249 | @Override public void enterVar_stmt(EFScriptParser.Var_stmtContext ctx) { }
250 | /**
251 | * {@inheritDoc}
252 | *
253 | * The default implementation does nothing.
254 | */
255 | @Override public void exitVar_stmt(EFScriptParser.Var_stmtContext ctx) { }
256 | /**
257 | * {@inheritDoc}
258 | *
259 | * The default implementation does nothing.
260 | */
261 | @Override public void enterReturn_stmt(EFScriptParser.Return_stmtContext ctx) { }
262 | /**
263 | * {@inheritDoc}
264 | *
265 | * The default implementation does nothing.
266 | */
267 | @Override public void exitReturn_stmt(EFScriptParser.Return_stmtContext ctx) { }
268 | /**
269 | * {@inheritDoc}
270 | *
271 | * The default implementation does nothing.
272 | */
273 | @Override public void enterExpression(EFScriptParser.ExpressionContext ctx) { }
274 | /**
275 | * {@inheritDoc}
276 | *
277 | * The default implementation does nothing.
278 | */
279 | @Override public void exitExpression(EFScriptParser.ExpressionContext ctx) { }
280 | /**
281 | * {@inheritDoc}
282 | *
283 | * The default implementation does nothing.
284 | */
285 | @Override public void enterBoolexpr(EFScriptParser.BoolexprContext ctx) { }
286 | /**
287 | * {@inheritDoc}
288 | *
289 | * The default implementation does nothing.
290 | */
291 | @Override public void exitBoolexpr(EFScriptParser.BoolexprContext ctx) { }
292 | /**
293 | * {@inheritDoc}
294 | *
295 | * The default implementation does nothing.
296 | */
297 | @Override public void enterMethodcall(EFScriptParser.MethodcallContext ctx) { }
298 | /**
299 | * {@inheritDoc}
300 | *
301 | * The default implementation does nothing.
302 | */
303 | @Override public void exitMethodcall(EFScriptParser.MethodcallContext ctx) { }
304 | /**
305 | * {@inheritDoc}
306 | *
307 | * The default implementation does nothing.
308 | */
309 | @Override public void enterMethodparams(EFScriptParser.MethodparamsContext ctx) { }
310 | /**
311 | * {@inheritDoc}
312 | *
313 | * The default implementation does nothing.
314 | */
315 | @Override public void exitMethodparams(EFScriptParser.MethodparamsContext ctx) { }
316 | /**
317 | * {@inheritDoc}
318 | *
319 | * The default implementation does nothing.
320 | */
321 | @Override public void enterValue(EFScriptParser.ValueContext ctx) { }
322 | /**
323 | * {@inheritDoc}
324 | *
325 | * The default implementation does nothing.
326 | */
327 | @Override public void exitValue(EFScriptParser.ValueContext ctx) { }
328 | /**
329 | * {@inheritDoc}
330 | *
331 | * The default implementation does nothing.
332 | */
333 | @Override public void enterIdentifier(EFScriptParser.IdentifierContext ctx) { }
334 | /**
335 | * {@inheritDoc}
336 | *
337 | * The default implementation does nothing.
338 | */
339 | @Override public void exitIdentifier(EFScriptParser.IdentifierContext ctx) { }
340 | /**
341 | * {@inheritDoc}
342 | *
343 | * The default implementation does nothing.
344 | */
345 | @Override public void enterNumber(EFScriptParser.NumberContext ctx) { }
346 | /**
347 | * {@inheritDoc}
348 | *
349 | * The default implementation does nothing.
350 | */
351 | @Override public void exitNumber(EFScriptParser.NumberContext ctx) { }
352 |
353 | /**
354 | * {@inheritDoc}
355 | *
356 | * The default implementation does nothing.
357 | */
358 | @Override public void enterEveryRule(ParserRuleContext ctx) { }
359 | /**
360 | * {@inheritDoc}
361 | *
362 | * The default implementation does nothing.
363 | */
364 | @Override public void exitEveryRule(ParserRuleContext ctx) { }
365 | /**
366 | * {@inheritDoc}
367 | *
368 | * The default implementation does nothing.
369 | */
370 | @Override public void visitTerminal(TerminalNode node) { }
371 | /**
372 | * {@inheritDoc}
373 | *
374 | * The default implementation does nothing.
375 | */
376 | @Override public void visitErrorNode(ErrorNode node) { }
377 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/EFScriptBaseVisitor.java:
--------------------------------------------------------------------------------
1 | // Generated from EFScript.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 | import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
6 |
7 | /**
8 | * This class provides an empty implementation of {@link EFScriptVisitor},
9 | * which can be extended to create a visitor which only needs to handle a subset
10 | * of the available methods.
11 | *
12 | * @param The return type of the visit operation. Use {@link Void} for
13 | * operations with no return type.
14 | */
15 | public class EFScriptBaseVisitor extends AbstractParseTreeVisitor implements EFScriptVisitor {
16 | /**
17 | * {@inheritDoc}
18 | *
19 | * The default implementation returns the result of calling
20 | * {@link #visitChildren} on {@code ctx}.
21 | */
22 | @Override public T visitScript(EFScriptParser.ScriptContext ctx) { return visitChildren(ctx); }
23 | /**
24 | * {@inheritDoc}
25 | *
26 | * The default implementation returns the result of calling
27 | * {@link #visitChildren} on {@code ctx}.
28 | */
29 | @Override public T visitHeader(EFScriptParser.HeaderContext ctx) { return visitChildren(ctx); }
30 | /**
31 | * {@inheritDoc}
32 | *
33 | * The default implementation returns the result of calling
34 | * {@link #visitChildren} on {@code ctx}.
35 | */
36 | @Override public T visitMeta(EFScriptParser.MetaContext ctx) { return visitChildren(ctx); }
37 | /**
38 | * {@inheritDoc}
39 | *
40 | * The default implementation returns the result of calling
41 | * {@link #visitChildren} on {@code ctx}.
42 | */
43 | @Override public T visitScriptName(EFScriptParser.ScriptNameContext ctx) { return visitChildren(ctx); }
44 | /**
45 | * {@inheritDoc}
46 | *
47 | * The default implementation returns the result of calling
48 | * {@link #visitChildren} on {@code ctx}.
49 | */
50 | @Override public T visitInclude(EFScriptParser.IncludeContext ctx) { return visitChildren(ctx); }
51 | /**
52 | * {@inheritDoc}
53 | *
54 | * The default implementation returns the result of calling
55 | * {@link #visitChildren} on {@code ctx}.
56 | */
57 | @Override public T visitFunction(EFScriptParser.FunctionContext ctx) { return visitChildren(ctx); }
58 | /**
59 | * {@inheritDoc}
60 | *
61 | * The default implementation returns the result of calling
62 | * {@link #visitChildren} on {@code ctx}.
63 | */
64 | @Override public T visitFunc_params(EFScriptParser.Func_paramsContext ctx) { return visitChildren(ctx); }
65 | /**
66 | * {@inheritDoc}
67 | *
68 | * The default implementation returns the result of calling
69 | * {@link #visitChildren} on {@code ctx}.
70 | */
71 | @Override public T visitStatement(EFScriptParser.StatementContext ctx) { return visitChildren(ctx); }
72 | /**
73 | * {@inheritDoc}
74 | *
75 | * The default implementation returns the result of calling
76 | * {@link #visitChildren} on {@code ctx}.
77 | */
78 | @Override public T visitAssign_stmt(EFScriptParser.Assign_stmtContext ctx) { return visitChildren(ctx); }
79 | /**
80 | * {@inheritDoc}
81 | *
82 | * The default implementation returns the result of calling
83 | * {@link #visitChildren} on {@code ctx}.
84 | */
85 | @Override public T visitTi_basic_stmt(EFScriptParser.Ti_basic_stmtContext ctx) { return visitChildren(ctx); }
86 | /**
87 | * {@inheritDoc}
88 | *
89 | * The default implementation returns the result of calling
90 | * {@link #visitChildren} on {@code ctx}.
91 | */
92 | @Override public T visitAny(EFScriptParser.AnyContext ctx) { return visitChildren(ctx); }
93 | /**
94 | * {@inheritDoc}
95 | *
96 | * The default implementation returns the result of calling
97 | * {@link #visitChildren} on {@code ctx}.
98 | */
99 | @Override public T visitAdd_assign_stmt(EFScriptParser.Add_assign_stmtContext ctx) { return visitChildren(ctx); }
100 | /**
101 | * {@inheritDoc}
102 | *
103 | * The default implementation returns the result of calling
104 | * {@link #visitChildren} on {@code ctx}.
105 | */
106 | @Override public T visitSub_assign_stmt(EFScriptParser.Sub_assign_stmtContext ctx) { return visitChildren(ctx); }
107 | /**
108 | * {@inheritDoc}
109 | *
110 | * The default implementation returns the result of calling
111 | * {@link #visitChildren} on {@code ctx}.
112 | */
113 | @Override public T visitMul_assign_stmt(EFScriptParser.Mul_assign_stmtContext ctx) { return visitChildren(ctx); }
114 | /**
115 | * {@inheritDoc}
116 | *
117 | * The default implementation returns the result of calling
118 | * {@link #visitChildren} on {@code ctx}.
119 | */
120 | @Override public T visitDiv_assign_stmt(EFScriptParser.Div_assign_stmtContext ctx) { return visitChildren(ctx); }
121 | /**
122 | * {@inheritDoc}
123 | *
124 | * The default implementation returns the result of calling
125 | * {@link #visitChildren} on {@code ctx}.
126 | */
127 | @Override public T visitInc_stmt(EFScriptParser.Inc_stmtContext ctx) { return visitChildren(ctx); }
128 | /**
129 | * {@inheritDoc}
130 | *
131 | * The default implementation returns the result of calling
132 | * {@link #visitChildren} on {@code ctx}.
133 | */
134 | @Override public T visitDec_stmt(EFScriptParser.Dec_stmtContext ctx) { return visitChildren(ctx); }
135 | /**
136 | * {@inheritDoc}
137 | *
138 | * The default implementation returns the result of calling
139 | * {@link #visitChildren} on {@code ctx}.
140 | */
141 | @Override public T visitIf_stmt(EFScriptParser.If_stmtContext ctx) { return visitChildren(ctx); }
142 | /**
143 | * {@inheritDoc}
144 | *
145 | * The default implementation returns the result of calling
146 | * {@link #visitChildren} on {@code ctx}.
147 | */
148 | @Override public T visitWhile_stmt(EFScriptParser.While_stmtContext ctx) { return visitChildren(ctx); }
149 | /**
150 | * {@inheritDoc}
151 | *
152 | * The default implementation returns the result of calling
153 | * {@link #visitChildren} on {@code ctx}.
154 | */
155 | @Override public T visitVar_stmt(EFScriptParser.Var_stmtContext ctx) { return visitChildren(ctx); }
156 | /**
157 | * {@inheritDoc}
158 | *
159 | * The default implementation returns the result of calling
160 | * {@link #visitChildren} on {@code ctx}.
161 | */
162 | @Override public T visitReturn_stmt(EFScriptParser.Return_stmtContext ctx) { return visitChildren(ctx); }
163 | /**
164 | * {@inheritDoc}
165 | *
166 | * The default implementation returns the result of calling
167 | * {@link #visitChildren} on {@code ctx}.
168 | */
169 | @Override public T visitExpression(EFScriptParser.ExpressionContext ctx) { return visitChildren(ctx); }
170 | /**
171 | * {@inheritDoc}
172 | *
173 | * The default implementation returns the result of calling
174 | * {@link #visitChildren} on {@code ctx}.
175 | */
176 | @Override public T visitBoolexpr(EFScriptParser.BoolexprContext ctx) { return visitChildren(ctx); }
177 | /**
178 | * {@inheritDoc}
179 | *
180 | * The default implementation returns the result of calling
181 | * {@link #visitChildren} on {@code ctx}.
182 | */
183 | @Override public T visitMethodcall(EFScriptParser.MethodcallContext ctx) { return visitChildren(ctx); }
184 | /**
185 | * {@inheritDoc}
186 | *
187 | * The default implementation returns the result of calling
188 | * {@link #visitChildren} on {@code ctx}.
189 | */
190 | @Override public T visitMethodparams(EFScriptParser.MethodparamsContext ctx) { return visitChildren(ctx); }
191 | /**
192 | * {@inheritDoc}
193 | *
194 | * The default implementation returns the result of calling
195 | * {@link #visitChildren} on {@code ctx}.
196 | */
197 | @Override public T visitValue(EFScriptParser.ValueContext ctx) { return visitChildren(ctx); }
198 | /**
199 | * {@inheritDoc}
200 | *
201 | * The default implementation returns the result of calling
202 | * {@link #visitChildren} on {@code ctx}.
203 | */
204 | @Override public T visitIdentifier(EFScriptParser.IdentifierContext ctx) { return visitChildren(ctx); }
205 | /**
206 | * {@inheritDoc}
207 | *
208 | * The default implementation returns the result of calling
209 | * {@link #visitChildren} on {@code ctx}.
210 | */
211 | @Override public T visitNumber(EFScriptParser.NumberContext ctx) { return visitChildren(ctx); }
212 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/EFScriptLexer.java:
--------------------------------------------------------------------------------
1 | // Generated from EFScript.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 | import org.antlr.v4.runtime.Lexer;
6 | import org.antlr.v4.runtime.CharStream;
7 | import org.antlr.v4.runtime.Token;
8 | import org.antlr.v4.runtime.TokenStream;
9 | import org.antlr.v4.runtime.*;
10 | import org.antlr.v4.runtime.atn.*;
11 | import org.antlr.v4.runtime.dfa.DFA;
12 | import org.antlr.v4.runtime.misc.*;
13 |
14 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
15 | public class EFScriptLexer extends Lexer {
16 | static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); }
17 |
18 | protected static final DFA[] _decisionToDFA;
19 | protected static final PredictionContextCache _sharedContextCache =
20 | new PredictionContextCache();
21 | public static final int
22 | T__0=1, T__1=2, T__2=3, T__3=4, OPEN_BRACKET=5, CLOSE_BRACKET=6, OPEN_CURLEY=7,
23 | CLOSE_CURLEY=8, END_STMT=9, ADD=10, SUB=11, MUL=12, DIV=13, GREATER_THAN=14,
24 | LESS_THAN=15, EQUAL_TO=16, NOT_EQUAL_TO=17, GREATER_THAN_OR_EQUAL=18,
25 | LESS_THAN_OR_EQUAL=19, OR=20, AND=21, ASSIGN=22, ADDASSIGN=23, SUBASSIGN=24,
26 | MULASSIGN=25, DIVASSIGN=26, INCREMENT=27, DECREMENT=28, DEF=29, VAR=30,
27 | STR=31, IF=32, WHILE=33, RETURN=34, TRUE=35, FALSE=36, IDENTIFIER=37,
28 | NUMBER=38, PI=39, E=40, I=41, QUOTED_TEXT=42, LINECOMMENT=43, BLOCKCOMMENT=44,
29 | WHITESPACE=45;
30 | public static String[] channelNames = {
31 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
32 | };
33 |
34 | public static String[] modeNames = {
35 | "DEFAULT_MODE"
36 | };
37 |
38 | private static String[] makeRuleNames() {
39 | return new String[] {
40 | "T__0", "T__1", "T__2", "T__3", "OPEN_BRACKET", "CLOSE_BRACKET", "OPEN_CURLEY",
41 | "CLOSE_CURLEY", "END_STMT", "ADD", "SUB", "MUL", "DIV", "GREATER_THAN",
42 | "LESS_THAN", "EQUAL_TO", "NOT_EQUAL_TO", "GREATER_THAN_OR_EQUAL", "LESS_THAN_OR_EQUAL",
43 | "OR", "AND", "ASSIGN", "ADDASSIGN", "SUBASSIGN", "MULASSIGN", "DIVASSIGN",
44 | "INCREMENT", "DECREMENT", "DEF", "VAR", "STR", "IF", "WHILE", "RETURN",
45 | "TRUE", "FALSE", "IDENTIFIER", "NUMBER", "PI", "E", "I", "INT", "QUOTED_TEXT",
46 | "LINECOMMENT", "BLOCKCOMMENT", "WHITESPACE"
47 | };
48 | }
49 | public static final String[] ruleNames = makeRuleNames();
50 |
51 | private static String[] makeLiteralNames() {
52 | return new String[] {
53 | null, "'name:'", "'include:'", "','", "'__tibasic'", "'('", "')'", "'{'",
54 | "'}'", "';'", "'+'", "'-'", "'*'", "'/'", "'>'", "'<'", "'=='", "'!='",
55 | "'>='", "'<='", "'||'", "'&&'", "'='", "'+='", "'-='", "'*='", "'/='",
56 | "'++'", "'--'", "'def'", "'var'", "'str'", "'if'", "'while'", "'return'",
57 | "'true'", "'false'", null, null, "'pi'", "'e'", "'i'"
58 | };
59 | }
60 | private static final String[] _LITERAL_NAMES = makeLiteralNames();
61 | private static String[] makeSymbolicNames() {
62 | return new String[] {
63 | null, null, null, null, null, "OPEN_BRACKET", "CLOSE_BRACKET", "OPEN_CURLEY",
64 | "CLOSE_CURLEY", "END_STMT", "ADD", "SUB", "MUL", "DIV", "GREATER_THAN",
65 | "LESS_THAN", "EQUAL_TO", "NOT_EQUAL_TO", "GREATER_THAN_OR_EQUAL", "LESS_THAN_OR_EQUAL",
66 | "OR", "AND", "ASSIGN", "ADDASSIGN", "SUBASSIGN", "MULASSIGN", "DIVASSIGN",
67 | "INCREMENT", "DECREMENT", "DEF", "VAR", "STR", "IF", "WHILE", "RETURN",
68 | "TRUE", "FALSE", "IDENTIFIER", "NUMBER", "PI", "E", "I", "QUOTED_TEXT",
69 | "LINECOMMENT", "BLOCKCOMMENT", "WHITESPACE"
70 | };
71 | }
72 | private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
73 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
74 |
75 | /**
76 | * @deprecated Use {@link #VOCABULARY} instead.
77 | */
78 | @Deprecated
79 | public static final String[] tokenNames;
80 | static {
81 | tokenNames = new String[_SYMBOLIC_NAMES.length];
82 | for (int i = 0; i < tokenNames.length; i++) {
83 | tokenNames[i] = VOCABULARY.getLiteralName(i);
84 | if (tokenNames[i] == null) {
85 | tokenNames[i] = VOCABULARY.getSymbolicName(i);
86 | }
87 |
88 | if (tokenNames[i] == null) {
89 | tokenNames[i] = "";
90 | }
91 | }
92 | }
93 |
94 | @Override
95 | @Deprecated
96 | public String[] getTokenNames() {
97 | return tokenNames;
98 | }
99 |
100 | @Override
101 |
102 | public Vocabulary getVocabulary() {
103 | return VOCABULARY;
104 | }
105 |
106 |
107 | public EFScriptLexer(CharStream input) {
108 | super(input);
109 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
110 | }
111 |
112 | @Override
113 | public String getGrammarFileName() { return "EFScript.g4"; }
114 |
115 | @Override
116 | public String[] getRuleNames() { return ruleNames; }
117 |
118 | @Override
119 | public String getSerializedATN() { return _serializedATN; }
120 |
121 | @Override
122 | public String[] getChannelNames() { return channelNames; }
123 |
124 | @Override
125 | public String[] getModeNames() { return modeNames; }
126 |
127 | @Override
128 | public ATN getATN() { return _ATN; }
129 |
130 | public static final String _serializedATN =
131 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2/\u0127\b\1\4\2\t"+
132 | "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
133 | "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
134 | "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
135 | "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+
136 | "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+
137 | ",\t,\4-\t-\4.\t.\4/\t/\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3"+
138 | "\3\3\3\3\3\3\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3"+
139 | "\7\3\7\3\b\3\b\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\r\3\r\3\16\3\16\3\17"+
140 | "\3\17\3\20\3\20\3\21\3\21\3\21\3\22\3\22\3\22\3\23\3\23\3\23\3\24\3\24"+
141 | "\3\24\3\25\3\25\3\25\3\26\3\26\3\26\3\27\3\27\3\30\3\30\3\30\3\31\3\31"+
142 | "\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\34\3\34\3\34\3\35\3\35\3\35\3\36"+
143 | "\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3!\3!\3!\3\"\3\"\3\"\3"+
144 | "\"\3\"\3\"\3#\3#\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%\3&\3"+
145 | "&\7&\u00e0\n&\f&\16&\u00e3\13&\3\'\5\'\u00e6\n\'\3\'\3\'\3\'\6\'\u00eb"+
146 | "\n\'\r\'\16\'\u00ec\5\'\u00ef\n\'\3(\3(\3(\3)\3)\3*\3*\3+\3+\3+\7+\u00fb"+
147 | "\n+\f+\16+\u00fe\13+\5+\u0100\n+\3,\3,\7,\u0104\n,\f,\16,\u0107\13,\3"+
148 | ",\3,\3-\3-\3-\3-\7-\u010f\n-\f-\16-\u0112\13-\3-\3-\3.\3.\3.\3.\7.\u011a"+
149 | "\n.\f.\16.\u011d\13.\3.\3.\3.\3.\3.\3/\3/\3/\3/\3\u011b\2\60\3\3\5\4\7"+
150 | "\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22"+
151 | "#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C"+
152 | "#E$G%I&K\'M(O)Q*S+U\2W,Y-[.]/\3\2\t\4\2C\\c|\6\2\62;C\\aac|\3\2\62;\3"+
153 | "\2\63;\5\2\f\f\17\17$$\4\2\f\f\17\17\5\2\13\f\17\17\"\"\2\u012e\2\3\3"+
154 | "\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2"+
155 | "\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3"+
156 | "\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2"+
157 | "%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61"+
158 | "\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2"+
159 | "\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I"+
160 | "\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2W\3\2"+
161 | "\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\3_\3\2\2\2\5e\3\2\2\2\7n\3\2\2\2"+
162 | "\tp\3\2\2\2\13z\3\2\2\2\r|\3\2\2\2\17~\3\2\2\2\21\u0080\3\2\2\2\23\u0082"+
163 | "\3\2\2\2\25\u0084\3\2\2\2\27\u0086\3\2\2\2\31\u0088\3\2\2\2\33\u008a\3"+
164 | "\2\2\2\35\u008c\3\2\2\2\37\u008e\3\2\2\2!\u0090\3\2\2\2#\u0093\3\2\2\2"+
165 | "%\u0096\3\2\2\2\'\u0099\3\2\2\2)\u009c\3\2\2\2+\u009f\3\2\2\2-\u00a2\3"+
166 | "\2\2\2/\u00a4\3\2\2\2\61\u00a7\3\2\2\2\63\u00aa\3\2\2\2\65\u00ad\3\2\2"+
167 | "\2\67\u00b0\3\2\2\29\u00b3\3\2\2\2;\u00b6\3\2\2\2=\u00ba\3\2\2\2?\u00be"+
168 | "\3\2\2\2A\u00c2\3\2\2\2C\u00c5\3\2\2\2E\u00cb\3\2\2\2G\u00d2\3\2\2\2I"+
169 | "\u00d7\3\2\2\2K\u00dd\3\2\2\2M\u00e5\3\2\2\2O\u00f0\3\2\2\2Q\u00f3\3\2"+
170 | "\2\2S\u00f5\3\2\2\2U\u00ff\3\2\2\2W\u0101\3\2\2\2Y\u010a\3\2\2\2[\u0115"+
171 | "\3\2\2\2]\u0123\3\2\2\2_`\7p\2\2`a\7c\2\2ab\7o\2\2bc\7g\2\2cd\7<\2\2d"+
172 | "\4\3\2\2\2ef\7k\2\2fg\7p\2\2gh\7e\2\2hi\7n\2\2ij\7w\2\2jk\7f\2\2kl\7g"+
173 | "\2\2lm\7<\2\2m\6\3\2\2\2no\7.\2\2o\b\3\2\2\2pq\7a\2\2qr\7a\2\2rs\7v\2"+
174 | "\2st\7k\2\2tu\7d\2\2uv\7c\2\2vw\7u\2\2wx\7k\2\2xy\7e\2\2y\n\3\2\2\2z{"+
175 | "\7*\2\2{\f\3\2\2\2|}\7+\2\2}\16\3\2\2\2~\177\7}\2\2\177\20\3\2\2\2\u0080"+
176 | "\u0081\7\177\2\2\u0081\22\3\2\2\2\u0082\u0083\7=\2\2\u0083\24\3\2\2\2"+
177 | "\u0084\u0085\7-\2\2\u0085\26\3\2\2\2\u0086\u0087\7/\2\2\u0087\30\3\2\2"+
178 | "\2\u0088\u0089\7,\2\2\u0089\32\3\2\2\2\u008a\u008b\7\61\2\2\u008b\34\3"+
179 | "\2\2\2\u008c\u008d\7@\2\2\u008d\36\3\2\2\2\u008e\u008f\7>\2\2\u008f \3"+
180 | "\2\2\2\u0090\u0091\7?\2\2\u0091\u0092\7?\2\2\u0092\"\3\2\2\2\u0093\u0094"+
181 | "\7#\2\2\u0094\u0095\7?\2\2\u0095$\3\2\2\2\u0096\u0097\7@\2\2\u0097\u0098"+
182 | "\7?\2\2\u0098&\3\2\2\2\u0099\u009a\7>\2\2\u009a\u009b\7?\2\2\u009b(\3"+
183 | "\2\2\2\u009c\u009d\7~\2\2\u009d\u009e\7~\2\2\u009e*\3\2\2\2\u009f\u00a0"+
184 | "\7(\2\2\u00a0\u00a1\7(\2\2\u00a1,\3\2\2\2\u00a2\u00a3\7?\2\2\u00a3.\3"+
185 | "\2\2\2\u00a4\u00a5\7-\2\2\u00a5\u00a6\7?\2\2\u00a6\60\3\2\2\2\u00a7\u00a8"+
186 | "\7/\2\2\u00a8\u00a9\7?\2\2\u00a9\62\3\2\2\2\u00aa\u00ab\7,\2\2\u00ab\u00ac"+
187 | "\7?\2\2\u00ac\64\3\2\2\2\u00ad\u00ae\7\61\2\2\u00ae\u00af\7?\2\2\u00af"+
188 | "\66\3\2\2\2\u00b0\u00b1\7-\2\2\u00b1\u00b2\7-\2\2\u00b28\3\2\2\2\u00b3"+
189 | "\u00b4\7/\2\2\u00b4\u00b5\7/\2\2\u00b5:\3\2\2\2\u00b6\u00b7\7f\2\2\u00b7"+
190 | "\u00b8\7g\2\2\u00b8\u00b9\7h\2\2\u00b9<\3\2\2\2\u00ba\u00bb\7x\2\2\u00bb"+
191 | "\u00bc\7c\2\2\u00bc\u00bd\7t\2\2\u00bd>\3\2\2\2\u00be\u00bf\7u\2\2\u00bf"+
192 | "\u00c0\7v\2\2\u00c0\u00c1\7t\2\2\u00c1@\3\2\2\2\u00c2\u00c3\7k\2\2\u00c3"+
193 | "\u00c4\7h\2\2\u00c4B\3\2\2\2\u00c5\u00c6\7y\2\2\u00c6\u00c7\7j\2\2\u00c7"+
194 | "\u00c8\7k\2\2\u00c8\u00c9\7n\2\2\u00c9\u00ca\7g\2\2\u00caD\3\2\2\2\u00cb"+
195 | "\u00cc\7t\2\2\u00cc\u00cd\7g\2\2\u00cd\u00ce\7v\2\2\u00ce\u00cf\7w\2\2"+
196 | "\u00cf\u00d0\7t\2\2\u00d0\u00d1\7p\2\2\u00d1F\3\2\2\2\u00d2\u00d3\7v\2"+
197 | "\2\u00d3\u00d4\7t\2\2\u00d4\u00d5\7w\2\2\u00d5\u00d6\7g\2\2\u00d6H\3\2"+
198 | "\2\2\u00d7\u00d8\7h\2\2\u00d8\u00d9\7c\2\2\u00d9\u00da\7n\2\2\u00da\u00db"+
199 | "\7u\2\2\u00db\u00dc\7g\2\2\u00dcJ\3\2\2\2\u00dd\u00e1\t\2\2\2\u00de\u00e0"+
200 | "\t\3\2\2\u00df\u00de\3\2\2\2\u00e0\u00e3\3\2\2\2\u00e1\u00df\3\2\2\2\u00e1"+
201 | "\u00e2\3\2\2\2\u00e2L\3\2\2\2\u00e3\u00e1\3\2\2\2\u00e4\u00e6\7/\2\2\u00e5"+
202 | "\u00e4\3\2\2\2\u00e5\u00e6\3\2\2\2\u00e6\u00e7\3\2\2\2\u00e7\u00ee\5U"+
203 | "+\2\u00e8\u00ea\7\60\2\2\u00e9\u00eb\t\4\2\2\u00ea\u00e9\3\2\2\2\u00eb"+
204 | "\u00ec\3\2\2\2\u00ec\u00ea\3\2\2\2\u00ec\u00ed\3\2\2\2\u00ed\u00ef\3\2"+
205 | "\2\2\u00ee\u00e8\3\2\2\2\u00ee\u00ef\3\2\2\2\u00efN\3\2\2\2\u00f0\u00f1"+
206 | "\7r\2\2\u00f1\u00f2\7k\2\2\u00f2P\3\2\2\2\u00f3\u00f4\7g\2\2\u00f4R\3"+
207 | "\2\2\2\u00f5\u00f6\7k\2\2\u00f6T\3\2\2\2\u00f7\u0100\7\62\2\2\u00f8\u00fc"+
208 | "\t\5\2\2\u00f9\u00fb\t\4\2\2\u00fa\u00f9\3\2\2\2\u00fb\u00fe\3\2\2\2\u00fc"+
209 | "\u00fa\3\2\2\2\u00fc\u00fd\3\2\2\2\u00fd\u0100\3\2\2\2\u00fe\u00fc\3\2"+
210 | "\2\2\u00ff\u00f7\3\2\2\2\u00ff\u00f8\3\2\2\2\u0100V\3\2\2\2\u0101\u0105"+
211 | "\7$\2\2\u0102\u0104\n\6\2\2\u0103\u0102\3\2\2\2\u0104\u0107\3\2\2\2\u0105"+
212 | "\u0103\3\2\2\2\u0105\u0106\3\2\2\2\u0106\u0108\3\2\2\2\u0107\u0105\3\2"+
213 | "\2\2\u0108\u0109\7$\2\2\u0109X\3\2\2\2\u010a\u010b\7\61\2\2\u010b\u010c"+
214 | "\7\61\2\2\u010c\u0110\3\2\2\2\u010d\u010f\n\7\2\2\u010e\u010d\3\2\2\2"+
215 | "\u010f\u0112\3\2\2\2\u0110\u010e\3\2\2\2\u0110\u0111\3\2\2\2\u0111\u0113"+
216 | "\3\2\2\2\u0112\u0110\3\2\2\2\u0113\u0114\b-\2\2\u0114Z\3\2\2\2\u0115\u0116"+
217 | "\7\61\2\2\u0116\u0117\7,\2\2\u0117\u011b\3\2\2\2\u0118\u011a\13\2\2\2"+
218 | "\u0119\u0118\3\2\2\2\u011a\u011d\3\2\2\2\u011b\u011c\3\2\2\2\u011b\u0119"+
219 | "\3\2\2\2\u011c\u011e\3\2\2\2\u011d\u011b\3\2\2\2\u011e\u011f\7,\2\2\u011f"+
220 | "\u0120\7\61\2\2\u0120\u0121\3\2\2\2\u0121\u0122\b.\2\2\u0122\\\3\2\2\2"+
221 | "\u0123\u0124\t\b\2\2\u0124\u0125\3\2\2\2\u0125\u0126\b/\2\2\u0126^\3\2"+
222 | "\2\2\f\2\u00e1\u00e5\u00ec\u00ee\u00fc\u00ff\u0105\u0110\u011b\3\b\2\2";
223 | public static final ATN _ATN =
224 | new ATNDeserializer().deserialize(_serializedATN.toCharArray());
225 | static {
226 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
227 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
228 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
229 | }
230 | }
231 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/EFScriptListener.java:
--------------------------------------------------------------------------------
1 | // Generated from EFScript.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 | import org.antlr.v4.runtime.tree.ParseTreeListener;
6 |
7 | /**
8 | * This interface defines a complete listener for a parse tree produced by
9 | * {@link EFScriptParser}.
10 | */
11 | public interface EFScriptListener extends ParseTreeListener {
12 | /**
13 | * Enter a parse tree produced by {@link EFScriptParser#script}.
14 | * @param ctx the parse tree
15 | */
16 | void enterScript(EFScriptParser.ScriptContext ctx);
17 | /**
18 | * Exit a parse tree produced by {@link EFScriptParser#script}.
19 | * @param ctx the parse tree
20 | */
21 | void exitScript(EFScriptParser.ScriptContext ctx);
22 | /**
23 | * Enter a parse tree produced by {@link EFScriptParser#header}.
24 | * @param ctx the parse tree
25 | */
26 | void enterHeader(EFScriptParser.HeaderContext ctx);
27 | /**
28 | * Exit a parse tree produced by {@link EFScriptParser#header}.
29 | * @param ctx the parse tree
30 | */
31 | void exitHeader(EFScriptParser.HeaderContext ctx);
32 | /**
33 | * Enter a parse tree produced by {@link EFScriptParser#meta}.
34 | * @param ctx the parse tree
35 | */
36 | void enterMeta(EFScriptParser.MetaContext ctx);
37 | /**
38 | * Exit a parse tree produced by {@link EFScriptParser#meta}.
39 | * @param ctx the parse tree
40 | */
41 | void exitMeta(EFScriptParser.MetaContext ctx);
42 | /**
43 | * Enter a parse tree produced by {@link EFScriptParser#scriptName}.
44 | * @param ctx the parse tree
45 | */
46 | void enterScriptName(EFScriptParser.ScriptNameContext ctx);
47 | /**
48 | * Exit a parse tree produced by {@link EFScriptParser#scriptName}.
49 | * @param ctx the parse tree
50 | */
51 | void exitScriptName(EFScriptParser.ScriptNameContext ctx);
52 | /**
53 | * Enter a parse tree produced by {@link EFScriptParser#include}.
54 | * @param ctx the parse tree
55 | */
56 | void enterInclude(EFScriptParser.IncludeContext ctx);
57 | /**
58 | * Exit a parse tree produced by {@link EFScriptParser#include}.
59 | * @param ctx the parse tree
60 | */
61 | void exitInclude(EFScriptParser.IncludeContext ctx);
62 | /**
63 | * Enter a parse tree produced by {@link EFScriptParser#function}.
64 | * @param ctx the parse tree
65 | */
66 | void enterFunction(EFScriptParser.FunctionContext ctx);
67 | /**
68 | * Exit a parse tree produced by {@link EFScriptParser#function}.
69 | * @param ctx the parse tree
70 | */
71 | void exitFunction(EFScriptParser.FunctionContext ctx);
72 | /**
73 | * Enter a parse tree produced by {@link EFScriptParser#func_params}.
74 | * @param ctx the parse tree
75 | */
76 | void enterFunc_params(EFScriptParser.Func_paramsContext ctx);
77 | /**
78 | * Exit a parse tree produced by {@link EFScriptParser#func_params}.
79 | * @param ctx the parse tree
80 | */
81 | void exitFunc_params(EFScriptParser.Func_paramsContext ctx);
82 | /**
83 | * Enter a parse tree produced by {@link EFScriptParser#statement}.
84 | * @param ctx the parse tree
85 | */
86 | void enterStatement(EFScriptParser.StatementContext ctx);
87 | /**
88 | * Exit a parse tree produced by {@link EFScriptParser#statement}.
89 | * @param ctx the parse tree
90 | */
91 | void exitStatement(EFScriptParser.StatementContext ctx);
92 | /**
93 | * Enter a parse tree produced by {@link EFScriptParser#assign_stmt}.
94 | * @param ctx the parse tree
95 | */
96 | void enterAssign_stmt(EFScriptParser.Assign_stmtContext ctx);
97 | /**
98 | * Exit a parse tree produced by {@link EFScriptParser#assign_stmt}.
99 | * @param ctx the parse tree
100 | */
101 | void exitAssign_stmt(EFScriptParser.Assign_stmtContext ctx);
102 | /**
103 | * Enter a parse tree produced by {@link EFScriptParser#ti_basic_stmt}.
104 | * @param ctx the parse tree
105 | */
106 | void enterTi_basic_stmt(EFScriptParser.Ti_basic_stmtContext ctx);
107 | /**
108 | * Exit a parse tree produced by {@link EFScriptParser#ti_basic_stmt}.
109 | * @param ctx the parse tree
110 | */
111 | void exitTi_basic_stmt(EFScriptParser.Ti_basic_stmtContext ctx);
112 | /**
113 | * Enter a parse tree produced by {@link EFScriptParser#any}.
114 | * @param ctx the parse tree
115 | */
116 | void enterAny(EFScriptParser.AnyContext ctx);
117 | /**
118 | * Exit a parse tree produced by {@link EFScriptParser#any}.
119 | * @param ctx the parse tree
120 | */
121 | void exitAny(EFScriptParser.AnyContext ctx);
122 | /**
123 | * Enter a parse tree produced by {@link EFScriptParser#add_assign_stmt}.
124 | * @param ctx the parse tree
125 | */
126 | void enterAdd_assign_stmt(EFScriptParser.Add_assign_stmtContext ctx);
127 | /**
128 | * Exit a parse tree produced by {@link EFScriptParser#add_assign_stmt}.
129 | * @param ctx the parse tree
130 | */
131 | void exitAdd_assign_stmt(EFScriptParser.Add_assign_stmtContext ctx);
132 | /**
133 | * Enter a parse tree produced by {@link EFScriptParser#sub_assign_stmt}.
134 | * @param ctx the parse tree
135 | */
136 | void enterSub_assign_stmt(EFScriptParser.Sub_assign_stmtContext ctx);
137 | /**
138 | * Exit a parse tree produced by {@link EFScriptParser#sub_assign_stmt}.
139 | * @param ctx the parse tree
140 | */
141 | void exitSub_assign_stmt(EFScriptParser.Sub_assign_stmtContext ctx);
142 | /**
143 | * Enter a parse tree produced by {@link EFScriptParser#mul_assign_stmt}.
144 | * @param ctx the parse tree
145 | */
146 | void enterMul_assign_stmt(EFScriptParser.Mul_assign_stmtContext ctx);
147 | /**
148 | * Exit a parse tree produced by {@link EFScriptParser#mul_assign_stmt}.
149 | * @param ctx the parse tree
150 | */
151 | void exitMul_assign_stmt(EFScriptParser.Mul_assign_stmtContext ctx);
152 | /**
153 | * Enter a parse tree produced by {@link EFScriptParser#div_assign_stmt}.
154 | * @param ctx the parse tree
155 | */
156 | void enterDiv_assign_stmt(EFScriptParser.Div_assign_stmtContext ctx);
157 | /**
158 | * Exit a parse tree produced by {@link EFScriptParser#div_assign_stmt}.
159 | * @param ctx the parse tree
160 | */
161 | void exitDiv_assign_stmt(EFScriptParser.Div_assign_stmtContext ctx);
162 | /**
163 | * Enter a parse tree produced by {@link EFScriptParser#inc_stmt}.
164 | * @param ctx the parse tree
165 | */
166 | void enterInc_stmt(EFScriptParser.Inc_stmtContext ctx);
167 | /**
168 | * Exit a parse tree produced by {@link EFScriptParser#inc_stmt}.
169 | * @param ctx the parse tree
170 | */
171 | void exitInc_stmt(EFScriptParser.Inc_stmtContext ctx);
172 | /**
173 | * Enter a parse tree produced by {@link EFScriptParser#dec_stmt}.
174 | * @param ctx the parse tree
175 | */
176 | void enterDec_stmt(EFScriptParser.Dec_stmtContext ctx);
177 | /**
178 | * Exit a parse tree produced by {@link EFScriptParser#dec_stmt}.
179 | * @param ctx the parse tree
180 | */
181 | void exitDec_stmt(EFScriptParser.Dec_stmtContext ctx);
182 | /**
183 | * Enter a parse tree produced by {@link EFScriptParser#if_stmt}.
184 | * @param ctx the parse tree
185 | */
186 | void enterIf_stmt(EFScriptParser.If_stmtContext ctx);
187 | /**
188 | * Exit a parse tree produced by {@link EFScriptParser#if_stmt}.
189 | * @param ctx the parse tree
190 | */
191 | void exitIf_stmt(EFScriptParser.If_stmtContext ctx);
192 | /**
193 | * Enter a parse tree produced by {@link EFScriptParser#while_stmt}.
194 | * @param ctx the parse tree
195 | */
196 | void enterWhile_stmt(EFScriptParser.While_stmtContext ctx);
197 | /**
198 | * Exit a parse tree produced by {@link EFScriptParser#while_stmt}.
199 | * @param ctx the parse tree
200 | */
201 | void exitWhile_stmt(EFScriptParser.While_stmtContext ctx);
202 | /**
203 | * Enter a parse tree produced by {@link EFScriptParser#var_stmt}.
204 | * @param ctx the parse tree
205 | */
206 | void enterVar_stmt(EFScriptParser.Var_stmtContext ctx);
207 | /**
208 | * Exit a parse tree produced by {@link EFScriptParser#var_stmt}.
209 | * @param ctx the parse tree
210 | */
211 | void exitVar_stmt(EFScriptParser.Var_stmtContext ctx);
212 | /**
213 | * Enter a parse tree produced by {@link EFScriptParser#return_stmt}.
214 | * @param ctx the parse tree
215 | */
216 | void enterReturn_stmt(EFScriptParser.Return_stmtContext ctx);
217 | /**
218 | * Exit a parse tree produced by {@link EFScriptParser#return_stmt}.
219 | * @param ctx the parse tree
220 | */
221 | void exitReturn_stmt(EFScriptParser.Return_stmtContext ctx);
222 | /**
223 | * Enter a parse tree produced by {@link EFScriptParser#expression}.
224 | * @param ctx the parse tree
225 | */
226 | void enterExpression(EFScriptParser.ExpressionContext ctx);
227 | /**
228 | * Exit a parse tree produced by {@link EFScriptParser#expression}.
229 | * @param ctx the parse tree
230 | */
231 | void exitExpression(EFScriptParser.ExpressionContext ctx);
232 | /**
233 | * Enter a parse tree produced by {@link EFScriptParser#boolexpr}.
234 | * @param ctx the parse tree
235 | */
236 | void enterBoolexpr(EFScriptParser.BoolexprContext ctx);
237 | /**
238 | * Exit a parse tree produced by {@link EFScriptParser#boolexpr}.
239 | * @param ctx the parse tree
240 | */
241 | void exitBoolexpr(EFScriptParser.BoolexprContext ctx);
242 | /**
243 | * Enter a parse tree produced by {@link EFScriptParser#methodcall}.
244 | * @param ctx the parse tree
245 | */
246 | void enterMethodcall(EFScriptParser.MethodcallContext ctx);
247 | /**
248 | * Exit a parse tree produced by {@link EFScriptParser#methodcall}.
249 | * @param ctx the parse tree
250 | */
251 | void exitMethodcall(EFScriptParser.MethodcallContext ctx);
252 | /**
253 | * Enter a parse tree produced by {@link EFScriptParser#methodparams}.
254 | * @param ctx the parse tree
255 | */
256 | void enterMethodparams(EFScriptParser.MethodparamsContext ctx);
257 | /**
258 | * Exit a parse tree produced by {@link EFScriptParser#methodparams}.
259 | * @param ctx the parse tree
260 | */
261 | void exitMethodparams(EFScriptParser.MethodparamsContext ctx);
262 | /**
263 | * Enter a parse tree produced by {@link EFScriptParser#value}.
264 | * @param ctx the parse tree
265 | */
266 | void enterValue(EFScriptParser.ValueContext ctx);
267 | /**
268 | * Exit a parse tree produced by {@link EFScriptParser#value}.
269 | * @param ctx the parse tree
270 | */
271 | void exitValue(EFScriptParser.ValueContext ctx);
272 | /**
273 | * Enter a parse tree produced by {@link EFScriptParser#identifier}.
274 | * @param ctx the parse tree
275 | */
276 | void enterIdentifier(EFScriptParser.IdentifierContext ctx);
277 | /**
278 | * Exit a parse tree produced by {@link EFScriptParser#identifier}.
279 | * @param ctx the parse tree
280 | */
281 | void exitIdentifier(EFScriptParser.IdentifierContext ctx);
282 | /**
283 | * Enter a parse tree produced by {@link EFScriptParser#number}.
284 | * @param ctx the parse tree
285 | */
286 | void enterNumber(EFScriptParser.NumberContext ctx);
287 | /**
288 | * Exit a parse tree produced by {@link EFScriptParser#number}.
289 | * @param ctx the parse tree
290 | */
291 | void exitNumber(EFScriptParser.NumberContext ctx);
292 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/EFScriptVisitor.java:
--------------------------------------------------------------------------------
1 | // Generated from EFScript.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 | import org.antlr.v4.runtime.tree.ParseTreeVisitor;
6 |
7 | /**
8 | * This interface defines a complete generic visitor for a parse tree produced
9 | * by {@link EFScriptParser}.
10 | *
11 | * @param The return type of the visit operation. Use {@link Void} for
12 | * operations with no return type.
13 | */
14 | public interface EFScriptVisitor extends ParseTreeVisitor {
15 | /**
16 | * Visit a parse tree produced by {@link EFScriptParser#script}.
17 | * @param ctx the parse tree
18 | * @return the visitor result
19 | */
20 | T visitScript(EFScriptParser.ScriptContext ctx);
21 | /**
22 | * Visit a parse tree produced by {@link EFScriptParser#header}.
23 | * @param ctx the parse tree
24 | * @return the visitor result
25 | */
26 | T visitHeader(EFScriptParser.HeaderContext ctx);
27 | /**
28 | * Visit a parse tree produced by {@link EFScriptParser#meta}.
29 | * @param ctx the parse tree
30 | * @return the visitor result
31 | */
32 | T visitMeta(EFScriptParser.MetaContext ctx);
33 | /**
34 | * Visit a parse tree produced by {@link EFScriptParser#scriptName}.
35 | * @param ctx the parse tree
36 | * @return the visitor result
37 | */
38 | T visitScriptName(EFScriptParser.ScriptNameContext ctx);
39 | /**
40 | * Visit a parse tree produced by {@link EFScriptParser#include}.
41 | * @param ctx the parse tree
42 | * @return the visitor result
43 | */
44 | T visitInclude(EFScriptParser.IncludeContext ctx);
45 | /**
46 | * Visit a parse tree produced by {@link EFScriptParser#function}.
47 | * @param ctx the parse tree
48 | * @return the visitor result
49 | */
50 | T visitFunction(EFScriptParser.FunctionContext ctx);
51 | /**
52 | * Visit a parse tree produced by {@link EFScriptParser#func_params}.
53 | * @param ctx the parse tree
54 | * @return the visitor result
55 | */
56 | T visitFunc_params(EFScriptParser.Func_paramsContext ctx);
57 | /**
58 | * Visit a parse tree produced by {@link EFScriptParser#statement}.
59 | * @param ctx the parse tree
60 | * @return the visitor result
61 | */
62 | T visitStatement(EFScriptParser.StatementContext ctx);
63 | /**
64 | * Visit a parse tree produced by {@link EFScriptParser#assign_stmt}.
65 | * @param ctx the parse tree
66 | * @return the visitor result
67 | */
68 | T visitAssign_stmt(EFScriptParser.Assign_stmtContext ctx);
69 | /**
70 | * Visit a parse tree produced by {@link EFScriptParser#ti_basic_stmt}.
71 | * @param ctx the parse tree
72 | * @return the visitor result
73 | */
74 | T visitTi_basic_stmt(EFScriptParser.Ti_basic_stmtContext ctx);
75 | /**
76 | * Visit a parse tree produced by {@link EFScriptParser#any}.
77 | * @param ctx the parse tree
78 | * @return the visitor result
79 | */
80 | T visitAny(EFScriptParser.AnyContext ctx);
81 | /**
82 | * Visit a parse tree produced by {@link EFScriptParser#add_assign_stmt}.
83 | * @param ctx the parse tree
84 | * @return the visitor result
85 | */
86 | T visitAdd_assign_stmt(EFScriptParser.Add_assign_stmtContext ctx);
87 | /**
88 | * Visit a parse tree produced by {@link EFScriptParser#sub_assign_stmt}.
89 | * @param ctx the parse tree
90 | * @return the visitor result
91 | */
92 | T visitSub_assign_stmt(EFScriptParser.Sub_assign_stmtContext ctx);
93 | /**
94 | * Visit a parse tree produced by {@link EFScriptParser#mul_assign_stmt}.
95 | * @param ctx the parse tree
96 | * @return the visitor result
97 | */
98 | T visitMul_assign_stmt(EFScriptParser.Mul_assign_stmtContext ctx);
99 | /**
100 | * Visit a parse tree produced by {@link EFScriptParser#div_assign_stmt}.
101 | * @param ctx the parse tree
102 | * @return the visitor result
103 | */
104 | T visitDiv_assign_stmt(EFScriptParser.Div_assign_stmtContext ctx);
105 | /**
106 | * Visit a parse tree produced by {@link EFScriptParser#inc_stmt}.
107 | * @param ctx the parse tree
108 | * @return the visitor result
109 | */
110 | T visitInc_stmt(EFScriptParser.Inc_stmtContext ctx);
111 | /**
112 | * Visit a parse tree produced by {@link EFScriptParser#dec_stmt}.
113 | * @param ctx the parse tree
114 | * @return the visitor result
115 | */
116 | T visitDec_stmt(EFScriptParser.Dec_stmtContext ctx);
117 | /**
118 | * Visit a parse tree produced by {@link EFScriptParser#if_stmt}.
119 | * @param ctx the parse tree
120 | * @return the visitor result
121 | */
122 | T visitIf_stmt(EFScriptParser.If_stmtContext ctx);
123 | /**
124 | * Visit a parse tree produced by {@link EFScriptParser#while_stmt}.
125 | * @param ctx the parse tree
126 | * @return the visitor result
127 | */
128 | T visitWhile_stmt(EFScriptParser.While_stmtContext ctx);
129 | /**
130 | * Visit a parse tree produced by {@link EFScriptParser#var_stmt}.
131 | * @param ctx the parse tree
132 | * @return the visitor result
133 | */
134 | T visitVar_stmt(EFScriptParser.Var_stmtContext ctx);
135 | /**
136 | * Visit a parse tree produced by {@link EFScriptParser#return_stmt}.
137 | * @param ctx the parse tree
138 | * @return the visitor result
139 | */
140 | T visitReturn_stmt(EFScriptParser.Return_stmtContext ctx);
141 | /**
142 | * Visit a parse tree produced by {@link EFScriptParser#expression}.
143 | * @param ctx the parse tree
144 | * @return the visitor result
145 | */
146 | T visitExpression(EFScriptParser.ExpressionContext ctx);
147 | /**
148 | * Visit a parse tree produced by {@link EFScriptParser#boolexpr}.
149 | * @param ctx the parse tree
150 | * @return the visitor result
151 | */
152 | T visitBoolexpr(EFScriptParser.BoolexprContext ctx);
153 | /**
154 | * Visit a parse tree produced by {@link EFScriptParser#methodcall}.
155 | * @param ctx the parse tree
156 | * @return the visitor result
157 | */
158 | T visitMethodcall(EFScriptParser.MethodcallContext ctx);
159 | /**
160 | * Visit a parse tree produced by {@link EFScriptParser#methodparams}.
161 | * @param ctx the parse tree
162 | * @return the visitor result
163 | */
164 | T visitMethodparams(EFScriptParser.MethodparamsContext ctx);
165 | /**
166 | * Visit a parse tree produced by {@link EFScriptParser#value}.
167 | * @param ctx the parse tree
168 | * @return the visitor result
169 | */
170 | T visitValue(EFScriptParser.ValueContext ctx);
171 | /**
172 | * Visit a parse tree produced by {@link EFScriptParser#identifier}.
173 | * @param ctx the parse tree
174 | * @return the visitor result
175 | */
176 | T visitIdentifier(EFScriptParser.IdentifierContext ctx);
177 | /**
178 | * Visit a parse tree produced by {@link EFScriptParser#number}.
179 | * @param ctx the parse tree
180 | * @return the visitor result
181 | */
182 | T visitNumber(EFScriptParser.NumberContext ctx);
183 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/TiBasicBaseListener.java:
--------------------------------------------------------------------------------
1 | // Generated from TiBasic.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 |
6 | import org.antlr.v4.runtime.ParserRuleContext;
7 | import org.antlr.v4.runtime.tree.ErrorNode;
8 | import org.antlr.v4.runtime.tree.TerminalNode;
9 |
10 | /**
11 | * This class provides an empty implementation of {@link TiBasicListener},
12 | * which can be extended to create a listener which only needs to handle a subset
13 | * of the available methods.
14 | */
15 | public class TiBasicBaseListener implements TiBasicListener {
16 | /**
17 | * {@inheritDoc}
18 | *
19 | * The default implementation does nothing.
20 | */
21 | @Override public void enterScript(TiBasicParser.ScriptContext ctx) { }
22 | /**
23 | * {@inheritDoc}
24 | *
25 | * The default implementation does nothing.
26 | */
27 | @Override public void exitScript(TiBasicParser.ScriptContext ctx) { }
28 | /**
29 | * {@inheritDoc}
30 | *
31 | * The default implementation does nothing.
32 | */
33 | @Override public void enterToken(TiBasicParser.TokenContext ctx) { }
34 | /**
35 | * {@inheritDoc}
36 | *
37 | * The default implementation does nothing.
38 | */
39 | @Override public void exitToken(TiBasicParser.TokenContext ctx) { }
40 | /**
41 | * {@inheritDoc}
42 | *
43 | * The default implementation does nothing.
44 | */
45 | @Override public void enterDisp(TiBasicParser.DispContext ctx) { }
46 | /**
47 | * {@inheritDoc}
48 | *
49 | * The default implementation does nothing.
50 | */
51 | @Override public void exitDisp(TiBasicParser.DispContext ctx) { }
52 | /**
53 | * {@inheritDoc}
54 | *
55 | * The default implementation does nothing.
56 | */
57 | @Override public void enterInput(TiBasicParser.InputContext ctx) { }
58 | /**
59 | * {@inheritDoc}
60 | *
61 | * The default implementation does nothing.
62 | */
63 | @Override public void exitInput(TiBasicParser.InputContext ctx) { }
64 | /**
65 | * {@inheritDoc}
66 | *
67 | * The default implementation does nothing.
68 | */
69 | @Override public void enterStore(TiBasicParser.StoreContext ctx) { }
70 | /**
71 | * {@inheritDoc}
72 | *
73 | * The default implementation does nothing.
74 | */
75 | @Override public void exitStore(TiBasicParser.StoreContext ctx) { }
76 | /**
77 | * {@inheritDoc}
78 | *
79 | * The default implementation does nothing.
80 | */
81 | @Override public void enterIf_(TiBasicParser.If_Context ctx) { }
82 | /**
83 | * {@inheritDoc}
84 | *
85 | * The default implementation does nothing.
86 | */
87 | @Override public void exitIf_(TiBasicParser.If_Context ctx) { }
88 | /**
89 | * {@inheritDoc}
90 | *
91 | * The default implementation does nothing.
92 | */
93 | @Override public void enterThen(TiBasicParser.ThenContext ctx) { }
94 | /**
95 | * {@inheritDoc}
96 | *
97 | * The default implementation does nothing.
98 | */
99 | @Override public void exitThen(TiBasicParser.ThenContext ctx) { }
100 | /**
101 | * {@inheritDoc}
102 | *
103 | * The default implementation does nothing.
104 | */
105 | @Override public void enterEnd(TiBasicParser.EndContext ctx) { }
106 | /**
107 | * {@inheritDoc}
108 | *
109 | * The default implementation does nothing.
110 | */
111 | @Override public void exitEnd(TiBasicParser.EndContext ctx) { }
112 | /**
113 | * {@inheritDoc}
114 | *
115 | * The default implementation does nothing.
116 | */
117 | @Override public void enterList(TiBasicParser.ListContext ctx) { }
118 | /**
119 | * {@inheritDoc}
120 | *
121 | * The default implementation does nothing.
122 | */
123 | @Override public void exitList(TiBasicParser.ListContext ctx) { }
124 | /**
125 | * {@inheritDoc}
126 | *
127 | * The default implementation does nothing.
128 | */
129 | @Override public void enterSpace(TiBasicParser.SpaceContext ctx) { }
130 | /**
131 | * {@inheritDoc}
132 | *
133 | * The default implementation does nothing.
134 | */
135 | @Override public void exitSpace(TiBasicParser.SpaceContext ctx) { }
136 | /**
137 | * {@inheritDoc}
138 | *
139 | * The default implementation does nothing.
140 | */
141 | @Override public void enterQuote(TiBasicParser.QuoteContext ctx) { }
142 | /**
143 | * {@inheritDoc}
144 | *
145 | * The default implementation does nothing.
146 | */
147 | @Override public void exitQuote(TiBasicParser.QuoteContext ctx) { }
148 | /**
149 | * {@inheritDoc}
150 | *
151 | * The default implementation does nothing.
152 | */
153 | @Override public void enterLetter(TiBasicParser.LetterContext ctx) { }
154 | /**
155 | * {@inheritDoc}
156 | *
157 | * The default implementation does nothing.
158 | */
159 | @Override public void exitLetter(TiBasicParser.LetterContext ctx) { }
160 | /**
161 | * {@inheritDoc}
162 | *
163 | * The default implementation does nothing.
164 | */
165 | @Override public void enterColon(TiBasicParser.ColonContext ctx) { }
166 | /**
167 | * {@inheritDoc}
168 | *
169 | * The default implementation does nothing.
170 | */
171 | @Override public void exitColon(TiBasicParser.ColonContext ctx) { }
172 | /**
173 | * {@inheritDoc}
174 | *
175 | * The default implementation does nothing.
176 | */
177 | @Override public void enterSemicolon(TiBasicParser.SemicolonContext ctx) { }
178 | /**
179 | * {@inheritDoc}
180 | *
181 | * The default implementation does nothing.
182 | */
183 | @Override public void exitSemicolon(TiBasicParser.SemicolonContext ctx) { }
184 | /**
185 | * {@inheritDoc}
186 | *
187 | * The default implementation does nothing.
188 | */
189 | @Override public void enterComma(TiBasicParser.CommaContext ctx) { }
190 | /**
191 | * {@inheritDoc}
192 | *
193 | * The default implementation does nothing.
194 | */
195 | @Override public void exitComma(TiBasicParser.CommaContext ctx) { }
196 | /**
197 | * {@inheritDoc}
198 | *
199 | * The default implementation does nothing.
200 | */
201 | @Override public void enterPeriod(TiBasicParser.PeriodContext ctx) { }
202 | /**
203 | * {@inheritDoc}
204 | *
205 | * The default implementation does nothing.
206 | */
207 | @Override public void exitPeriod(TiBasicParser.PeriodContext ctx) { }
208 | /**
209 | * {@inheritDoc}
210 | *
211 | * The default implementation does nothing.
212 | */
213 | @Override public void enterOpen_bracket(TiBasicParser.Open_bracketContext ctx) { }
214 | /**
215 | * {@inheritDoc}
216 | *
217 | * The default implementation does nothing.
218 | */
219 | @Override public void exitOpen_bracket(TiBasicParser.Open_bracketContext ctx) { }
220 | /**
221 | * {@inheritDoc}
222 | *
223 | * The default implementation does nothing.
224 | */
225 | @Override public void enterClose_bracket(TiBasicParser.Close_bracketContext ctx) { }
226 | /**
227 | * {@inheritDoc}
228 | *
229 | * The default implementation does nothing.
230 | */
231 | @Override public void exitClose_bracket(TiBasicParser.Close_bracketContext ctx) { }
232 | /**
233 | * {@inheritDoc}
234 | *
235 | * The default implementation does nothing.
236 | */
237 | @Override public void enterEquals(TiBasicParser.EqualsContext ctx) { }
238 | /**
239 | * {@inheritDoc}
240 | *
241 | * The default implementation does nothing.
242 | */
243 | @Override public void exitEquals(TiBasicParser.EqualsContext ctx) { }
244 | /**
245 | * {@inheritDoc}
246 | *
247 | * The default implementation does nothing.
248 | */
249 | @Override public void enterNumber(TiBasicParser.NumberContext ctx) { }
250 | /**
251 | * {@inheritDoc}
252 | *
253 | * The default implementation does nothing.
254 | */
255 | @Override public void exitNumber(TiBasicParser.NumberContext ctx) { }
256 | /**
257 | * {@inheritDoc}
258 | *
259 | * The default implementation does nothing.
260 | */
261 | @Override public void enterPi(TiBasicParser.PiContext ctx) { }
262 | /**
263 | * {@inheritDoc}
264 | *
265 | * The default implementation does nothing.
266 | */
267 | @Override public void exitPi(TiBasicParser.PiContext ctx) { }
268 | /**
269 | * {@inheritDoc}
270 | *
271 | * The default implementation does nothing.
272 | */
273 | @Override public void enterE(TiBasicParser.EContext ctx) { }
274 | /**
275 | * {@inheritDoc}
276 | *
277 | * The default implementation does nothing.
278 | */
279 | @Override public void exitE(TiBasicParser.EContext ctx) { }
280 | /**
281 | * {@inheritDoc}
282 | *
283 | * The default implementation does nothing.
284 | */
285 | @Override public void enterI(TiBasicParser.IContext ctx) { }
286 | /**
287 | * {@inheritDoc}
288 | *
289 | * The default implementation does nothing.
290 | */
291 | @Override public void exitI(TiBasicParser.IContext ctx) { }
292 | /**
293 | * {@inheritDoc}
294 | *
295 | * The default implementation does nothing.
296 | */
297 | @Override public void enterNewline(TiBasicParser.NewlineContext ctx) { }
298 | /**
299 | * {@inheritDoc}
300 | *
301 | * The default implementation does nothing.
302 | */
303 | @Override public void exitNewline(TiBasicParser.NewlineContext ctx) { }
304 |
305 | /**
306 | * {@inheritDoc}
307 | *
308 | * The default implementation does nothing.
309 | */
310 | @Override public void enterEveryRule(ParserRuleContext ctx) { }
311 | /**
312 | * {@inheritDoc}
313 | *
314 | * The default implementation does nothing.
315 | */
316 | @Override public void exitEveryRule(ParserRuleContext ctx) { }
317 | /**
318 | * {@inheritDoc}
319 | *
320 | * The default implementation does nothing.
321 | */
322 | @Override public void visitTerminal(TerminalNode node) { }
323 | /**
324 | * {@inheritDoc}
325 | *
326 | * The default implementation does nothing.
327 | */
328 | @Override public void visitErrorNode(ErrorNode node) { }
329 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/TiBasicBaseVisitor.java:
--------------------------------------------------------------------------------
1 | // Generated from TiBasic.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 | import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
6 |
7 | /**
8 | * This class provides an empty implementation of {@link TiBasicVisitor},
9 | * which can be extended to create a visitor which only needs to handle a subset
10 | * of the available methods.
11 | *
12 | * @param The return type of the visit operation. Use {@link Void} for
13 | * operations with no return type.
14 | */
15 | public class TiBasicBaseVisitor extends AbstractParseTreeVisitor implements TiBasicVisitor {
16 | /**
17 | * {@inheritDoc}
18 | *
19 | * The default implementation returns the result of calling
20 | * {@link #visitChildren} on {@code ctx}.
21 | */
22 | @Override public T visitScript(TiBasicParser.ScriptContext ctx) { return visitChildren(ctx); }
23 | /**
24 | * {@inheritDoc}
25 | *
26 | * The default implementation returns the result of calling
27 | * {@link #visitChildren} on {@code ctx}.
28 | */
29 | @Override public T visitToken(TiBasicParser.TokenContext ctx) { return visitChildren(ctx); }
30 | /**
31 | * {@inheritDoc}
32 | *
33 | * The default implementation returns the result of calling
34 | * {@link #visitChildren} on {@code ctx}.
35 | */
36 | @Override public T visitDisp(TiBasicParser.DispContext ctx) { return visitChildren(ctx); }
37 | /**
38 | * {@inheritDoc}
39 | *
40 | * The default implementation returns the result of calling
41 | * {@link #visitChildren} on {@code ctx}.
42 | */
43 | @Override public T visitInput(TiBasicParser.InputContext ctx) { return visitChildren(ctx); }
44 | /**
45 | * {@inheritDoc}
46 | *
47 | * The default implementation returns the result of calling
48 | * {@link #visitChildren} on {@code ctx}.
49 | */
50 | @Override public T visitStore(TiBasicParser.StoreContext ctx) { return visitChildren(ctx); }
51 | /**
52 | * {@inheritDoc}
53 | *
54 | * The default implementation returns the result of calling
55 | * {@link #visitChildren} on {@code ctx}.
56 | */
57 | @Override public T visitIf_(TiBasicParser.If_Context ctx) { return visitChildren(ctx); }
58 | /**
59 | * {@inheritDoc}
60 | *
61 | * The default implementation returns the result of calling
62 | * {@link #visitChildren} on {@code ctx}.
63 | */
64 | @Override public T visitThen(TiBasicParser.ThenContext ctx) { return visitChildren(ctx); }
65 | /**
66 | * {@inheritDoc}
67 | *
68 | * The default implementation returns the result of calling
69 | * {@link #visitChildren} on {@code ctx}.
70 | */
71 | @Override public T visitEnd(TiBasicParser.EndContext ctx) { return visitChildren(ctx); }
72 | /**
73 | * {@inheritDoc}
74 | *
75 | * The default implementation returns the result of calling
76 | * {@link #visitChildren} on {@code ctx}.
77 | */
78 | @Override public T visitList(TiBasicParser.ListContext ctx) { return visitChildren(ctx); }
79 | /**
80 | * {@inheritDoc}
81 | *
82 | * The default implementation returns the result of calling
83 | * {@link #visitChildren} on {@code ctx}.
84 | */
85 | @Override public T visitSpace(TiBasicParser.SpaceContext ctx) { return visitChildren(ctx); }
86 | /**
87 | * {@inheritDoc}
88 | *
89 | * The default implementation returns the result of calling
90 | * {@link #visitChildren} on {@code ctx}.
91 | */
92 | @Override public T visitQuote(TiBasicParser.QuoteContext ctx) { return visitChildren(ctx); }
93 | /**
94 | * {@inheritDoc}
95 | *
96 | * The default implementation returns the result of calling
97 | * {@link #visitChildren} on {@code ctx}.
98 | */
99 | @Override public T visitLetter(TiBasicParser.LetterContext ctx) { return visitChildren(ctx); }
100 | /**
101 | * {@inheritDoc}
102 | *
103 | * The default implementation returns the result of calling
104 | * {@link #visitChildren} on {@code ctx}.
105 | */
106 | @Override public T visitColon(TiBasicParser.ColonContext ctx) { return visitChildren(ctx); }
107 | /**
108 | * {@inheritDoc}
109 | *
110 | * The default implementation returns the result of calling
111 | * {@link #visitChildren} on {@code ctx}.
112 | */
113 | @Override public T visitSemicolon(TiBasicParser.SemicolonContext ctx) { return visitChildren(ctx); }
114 | /**
115 | * {@inheritDoc}
116 | *
117 | * The default implementation returns the result of calling
118 | * {@link #visitChildren} on {@code ctx}.
119 | */
120 | @Override public T visitComma(TiBasicParser.CommaContext ctx) { return visitChildren(ctx); }
121 | /**
122 | * {@inheritDoc}
123 | *
124 | * The default implementation returns the result of calling
125 | * {@link #visitChildren} on {@code ctx}.
126 | */
127 | @Override public T visitPeriod(TiBasicParser.PeriodContext ctx) { return visitChildren(ctx); }
128 | /**
129 | * {@inheritDoc}
130 | *
131 | * The default implementation returns the result of calling
132 | * {@link #visitChildren} on {@code ctx}.
133 | */
134 | @Override public T visitOpen_bracket(TiBasicParser.Open_bracketContext ctx) { return visitChildren(ctx); }
135 | /**
136 | * {@inheritDoc}
137 | *
138 | * The default implementation returns the result of calling
139 | * {@link #visitChildren} on {@code ctx}.
140 | */
141 | @Override public T visitClose_bracket(TiBasicParser.Close_bracketContext ctx) { return visitChildren(ctx); }
142 | /**
143 | * {@inheritDoc}
144 | *
145 | * The default implementation returns the result of calling
146 | * {@link #visitChildren} on {@code ctx}.
147 | */
148 | @Override public T visitEquals(TiBasicParser.EqualsContext ctx) { return visitChildren(ctx); }
149 | /**
150 | * {@inheritDoc}
151 | *
152 | * The default implementation returns the result of calling
153 | * {@link #visitChildren} on {@code ctx}.
154 | */
155 | @Override public T visitNumber(TiBasicParser.NumberContext ctx) { return visitChildren(ctx); }
156 | /**
157 | * {@inheritDoc}
158 | *
159 | * The default implementation returns the result of calling
160 | * {@link #visitChildren} on {@code ctx}.
161 | */
162 | @Override public T visitPi(TiBasicParser.PiContext ctx) { return visitChildren(ctx); }
163 | /**
164 | * {@inheritDoc}
165 | *
166 | * The default implementation returns the result of calling
167 | * {@link #visitChildren} on {@code ctx}.
168 | */
169 | @Override public T visitE(TiBasicParser.EContext ctx) { return visitChildren(ctx); }
170 | /**
171 | * {@inheritDoc}
172 | *
173 | * The default implementation returns the result of calling
174 | * {@link #visitChildren} on {@code ctx}.
175 | */
176 | @Override public T visitI(TiBasicParser.IContext ctx) { return visitChildren(ctx); }
177 | /**
178 | * {@inheritDoc}
179 | *
180 | * The default implementation returns the result of calling
181 | * {@link #visitChildren} on {@code ctx}.
182 | */
183 | @Override public T visitNewline(TiBasicParser.NewlineContext ctx) { return visitChildren(ctx); }
184 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/TiBasicLexer.java:
--------------------------------------------------------------------------------
1 | // Generated from TiBasic.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 | import org.antlr.v4.runtime.Lexer;
6 | import org.antlr.v4.runtime.CharStream;
7 | import org.antlr.v4.runtime.Token;
8 | import org.antlr.v4.runtime.TokenStream;
9 | import org.antlr.v4.runtime.*;
10 | import org.antlr.v4.runtime.atn.*;
11 | import org.antlr.v4.runtime.dfa.DFA;
12 | import org.antlr.v4.runtime.misc.*;
13 |
14 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
15 | public class TiBasicLexer extends Lexer {
16 | static { RuntimeMetaData.checkVersion("4.9.1", RuntimeMetaData.VERSION); }
17 |
18 | protected static final DFA[] _decisionToDFA;
19 | protected static final PredictionContextCache _sharedContextCache =
20 | new PredictionContextCache();
21 | public static final int
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, T__8=9,
23 | T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
24 | T__17=18, T__18=19, T__19=20, LETTER=21, NUMBER=22, LINECOMMENT=23, BLOCKCOMMENT=24,
25 | WHITESPACE=25;
26 | public static String[] channelNames = {
27 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
28 | };
29 |
30 | public static String[] modeNames = {
31 | "DEFAULT_MODE"
32 | };
33 |
34 | private static String[] makeRuleNames() {
35 | return new String[] {
36 | "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
37 | "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
38 | "T__17", "T__18", "T__19", "LETTER", "NUMBER", "INT", "LINECOMMENT",
39 | "BLOCKCOMMENT", "WHITESPACE"
40 | };
41 | }
42 | public static final String[] ruleNames = makeRuleNames();
43 |
44 | private static String[] makeLiteralNames() {
45 | return new String[] {
46 | null, "'DISP'", "'INPUT'", "'->'", "'IF'", "'THEN'", "'END'", "'LIST'",
47 | "' '", "'\"'", "':'", "';'", "','", "'.'", "'('", "')'", "'='", "'pi'",
48 | "'e'", "'i'", "'\n'"
49 | };
50 | }
51 | private static final String[] _LITERAL_NAMES = makeLiteralNames();
52 | private static String[] makeSymbolicNames() {
53 | return new String[] {
54 | null, null, null, null, null, null, null, null, null, null, null, null,
55 | null, null, null, null, null, null, null, null, null, "LETTER", "NUMBER",
56 | "LINECOMMENT", "BLOCKCOMMENT", "WHITESPACE"
57 | };
58 | }
59 | private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
60 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
61 |
62 | /**
63 | * @deprecated Use {@link #VOCABULARY} instead.
64 | */
65 | @Deprecated
66 | public static final String[] tokenNames;
67 | static {
68 | tokenNames = new String[_SYMBOLIC_NAMES.length];
69 | for (int i = 0; i < tokenNames.length; i++) {
70 | tokenNames[i] = VOCABULARY.getLiteralName(i);
71 | if (tokenNames[i] == null) {
72 | tokenNames[i] = VOCABULARY.getSymbolicName(i);
73 | }
74 |
75 | if (tokenNames[i] == null) {
76 | tokenNames[i] = "";
77 | }
78 | }
79 | }
80 |
81 | @Override
82 | @Deprecated
83 | public String[] getTokenNames() {
84 | return tokenNames;
85 | }
86 |
87 | @Override
88 |
89 | public Vocabulary getVocabulary() {
90 | return VOCABULARY;
91 | }
92 |
93 |
94 | public TiBasicLexer(CharStream input) {
95 | super(input);
96 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
97 | }
98 |
99 | @Override
100 | public String getGrammarFileName() { return "TiBasic.g4"; }
101 |
102 | @Override
103 | public String[] getRuleNames() { return ruleNames; }
104 |
105 | @Override
106 | public String getSerializedATN() { return _serializedATN; }
107 |
108 | @Override
109 | public String[] getChannelNames() { return channelNames; }
110 |
111 | @Override
112 | public String[] getModeNames() { return modeNames; }
113 |
114 | @Override
115 | public ATN getATN() { return _ATN; }
116 |
117 | public static final String _serializedATN =
118 | "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\33\u009c\b\1\4\2"+
119 | "\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4"+
120 | "\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22"+
121 | "\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31"+
122 | "\t\31\4\32\t\32\4\33\t\33\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3"+
123 | "\3\4\3\4\3\4\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\b\3\b\3"+
124 | "\b\3\b\3\b\3\t\3\t\3\n\3\n\3\13\3\13\3\f\3\f\3\r\3\r\3\16\3\16\3\17\3"+
125 | "\17\3\20\3\20\3\21\3\21\3\22\3\22\3\22\3\23\3\23\3\24\3\24\3\25\3\25\3"+
126 | "\26\3\26\3\27\3\27\3\30\3\30\3\30\7\30y\n\30\f\30\16\30|\13\30\5\30~\n"+
127 | "\30\3\31\3\31\3\31\3\31\7\31\u0084\n\31\f\31\16\31\u0087\13\31\3\31\3"+
128 | "\31\3\32\3\32\3\32\3\32\7\32\u008f\n\32\f\32\16\32\u0092\13\32\3\32\3"+
129 | "\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\u0090\2\34\3\3\5\4\7\5\t\6\13"+
130 | "\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'"+
131 | "\25)\26+\27-\30/\2\61\31\63\32\65\33\3\2\7\3\2C\\\3\2\62;\3\2\63;\4\2"+
132 | "\f\f\17\17\5\2\13\f\17\17\"\"\2\u009e\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2"+
133 | "\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2"+
134 | "\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3"+
135 | "\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3"+
136 | "\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\3"+
137 | "\67\3\2\2\2\5<\3\2\2\2\7B\3\2\2\2\tE\3\2\2\2\13H\3\2\2\2\rM\3\2\2\2\17"+
138 | "Q\3\2\2\2\21V\3\2\2\2\23X\3\2\2\2\25Z\3\2\2\2\27\\\3\2\2\2\31^\3\2\2\2"+
139 | "\33`\3\2\2\2\35b\3\2\2\2\37d\3\2\2\2!f\3\2\2\2#h\3\2\2\2%k\3\2\2\2\'m"+
140 | "\3\2\2\2)o\3\2\2\2+q\3\2\2\2-s\3\2\2\2/}\3\2\2\2\61\177\3\2\2\2\63\u008a"+
141 | "\3\2\2\2\65\u0098\3\2\2\2\678\7F\2\289\7K\2\29:\7U\2\2:;\7R\2\2;\4\3\2"+
142 | "\2\2<=\7K\2\2=>\7P\2\2>?\7R\2\2?@\7W\2\2@A\7V\2\2A\6\3\2\2\2BC\7/\2\2"+
143 | "CD\7@\2\2D\b\3\2\2\2EF\7K\2\2FG\7H\2\2G\n\3\2\2\2HI\7V\2\2IJ\7J\2\2JK"+
144 | "\7G\2\2KL\7P\2\2L\f\3\2\2\2MN\7G\2\2NO\7P\2\2OP\7F\2\2P\16\3\2\2\2QR\7"+
145 | "N\2\2RS\7K\2\2ST\7U\2\2TU\7V\2\2U\20\3\2\2\2VW\7\"\2\2W\22\3\2\2\2XY\7"+
146 | "$\2\2Y\24\3\2\2\2Z[\7<\2\2[\26\3\2\2\2\\]\7=\2\2]\30\3\2\2\2^_\7.\2\2"+
147 | "_\32\3\2\2\2`a\7\60\2\2a\34\3\2\2\2bc\7*\2\2c\36\3\2\2\2de\7+\2\2e \3"+
148 | "\2\2\2fg\7?\2\2g\"\3\2\2\2hi\7r\2\2ij\7k\2\2j$\3\2\2\2kl\7g\2\2l&\3\2"+
149 | "\2\2mn\7k\2\2n(\3\2\2\2op\7\f\2\2p*\3\2\2\2qr\t\2\2\2r,\3\2\2\2st\t\3"+
150 | "\2\2t.\3\2\2\2u~\7\62\2\2vz\t\4\2\2wy\t\3\2\2xw\3\2\2\2y|\3\2\2\2zx\3"+
151 | "\2\2\2z{\3\2\2\2{~\3\2\2\2|z\3\2\2\2}u\3\2\2\2}v\3\2\2\2~\60\3\2\2\2\177"+
152 | "\u0080\7\61\2\2\u0080\u0081\7\61\2\2\u0081\u0085\3\2\2\2\u0082\u0084\n"+
153 | "\5\2\2\u0083\u0082\3\2\2\2\u0084\u0087\3\2\2\2\u0085\u0083\3\2\2\2\u0085"+
154 | "\u0086\3\2\2\2\u0086\u0088\3\2\2\2\u0087\u0085\3\2\2\2\u0088\u0089\b\31"+
155 | "\2\2\u0089\62\3\2\2\2\u008a\u008b\7\61\2\2\u008b\u008c\7,\2\2\u008c\u0090"+
156 | "\3\2\2\2\u008d\u008f\13\2\2\2\u008e\u008d\3\2\2\2\u008f\u0092\3\2\2\2"+
157 | "\u0090\u0091\3\2\2\2\u0090\u008e\3\2\2\2\u0091\u0093\3\2\2\2\u0092\u0090"+
158 | "\3\2\2\2\u0093\u0094\7,\2\2\u0094\u0095\7\61\2\2\u0095\u0096\3\2\2\2\u0096"+
159 | "\u0097\b\32\2\2\u0097\64\3\2\2\2\u0098\u0099\t\6\2\2\u0099\u009a\3\2\2"+
160 | "\2\u009a\u009b\b\33\2\2\u009b\66\3\2\2\2\7\2z}\u0085\u0090\3\b\2\2";
161 | public static final ATN _ATN =
162 | new ATNDeserializer().deserialize(_serializedATN.toCharArray());
163 | static {
164 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
165 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
166 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
167 | }
168 | }
169 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/TiBasicListener.java:
--------------------------------------------------------------------------------
1 | // Generated from TiBasic.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 | import org.antlr.v4.runtime.tree.ParseTreeListener;
6 |
7 | /**
8 | * This interface defines a complete listener for a parse tree produced by
9 | * {@link TiBasicParser}.
10 | */
11 | public interface TiBasicListener extends ParseTreeListener {
12 | /**
13 | * Enter a parse tree produced by {@link TiBasicParser#script}.
14 | * @param ctx the parse tree
15 | */
16 | void enterScript(TiBasicParser.ScriptContext ctx);
17 | /**
18 | * Exit a parse tree produced by {@link TiBasicParser#script}.
19 | * @param ctx the parse tree
20 | */
21 | void exitScript(TiBasicParser.ScriptContext ctx);
22 | /**
23 | * Enter a parse tree produced by {@link TiBasicParser#token}.
24 | * @param ctx the parse tree
25 | */
26 | void enterToken(TiBasicParser.TokenContext ctx);
27 | /**
28 | * Exit a parse tree produced by {@link TiBasicParser#token}.
29 | * @param ctx the parse tree
30 | */
31 | void exitToken(TiBasicParser.TokenContext ctx);
32 | /**
33 | * Enter a parse tree produced by {@link TiBasicParser#disp}.
34 | * @param ctx the parse tree
35 | */
36 | void enterDisp(TiBasicParser.DispContext ctx);
37 | /**
38 | * Exit a parse tree produced by {@link TiBasicParser#disp}.
39 | * @param ctx the parse tree
40 | */
41 | void exitDisp(TiBasicParser.DispContext ctx);
42 | /**
43 | * Enter a parse tree produced by {@link TiBasicParser#input}.
44 | * @param ctx the parse tree
45 | */
46 | void enterInput(TiBasicParser.InputContext ctx);
47 | /**
48 | * Exit a parse tree produced by {@link TiBasicParser#input}.
49 | * @param ctx the parse tree
50 | */
51 | void exitInput(TiBasicParser.InputContext ctx);
52 | /**
53 | * Enter a parse tree produced by {@link TiBasicParser#store}.
54 | * @param ctx the parse tree
55 | */
56 | void enterStore(TiBasicParser.StoreContext ctx);
57 | /**
58 | * Exit a parse tree produced by {@link TiBasicParser#store}.
59 | * @param ctx the parse tree
60 | */
61 | void exitStore(TiBasicParser.StoreContext ctx);
62 | /**
63 | * Enter a parse tree produced by {@link TiBasicParser#if_}.
64 | * @param ctx the parse tree
65 | */
66 | void enterIf_(TiBasicParser.If_Context ctx);
67 | /**
68 | * Exit a parse tree produced by {@link TiBasicParser#if_}.
69 | * @param ctx the parse tree
70 | */
71 | void exitIf_(TiBasicParser.If_Context ctx);
72 | /**
73 | * Enter a parse tree produced by {@link TiBasicParser#then}.
74 | * @param ctx the parse tree
75 | */
76 | void enterThen(TiBasicParser.ThenContext ctx);
77 | /**
78 | * Exit a parse tree produced by {@link TiBasicParser#then}.
79 | * @param ctx the parse tree
80 | */
81 | void exitThen(TiBasicParser.ThenContext ctx);
82 | /**
83 | * Enter a parse tree produced by {@link TiBasicParser#end}.
84 | * @param ctx the parse tree
85 | */
86 | void enterEnd(TiBasicParser.EndContext ctx);
87 | /**
88 | * Exit a parse tree produced by {@link TiBasicParser#end}.
89 | * @param ctx the parse tree
90 | */
91 | void exitEnd(TiBasicParser.EndContext ctx);
92 | /**
93 | * Enter a parse tree produced by {@link TiBasicParser#list}.
94 | * @param ctx the parse tree
95 | */
96 | void enterList(TiBasicParser.ListContext ctx);
97 | /**
98 | * Exit a parse tree produced by {@link TiBasicParser#list}.
99 | * @param ctx the parse tree
100 | */
101 | void exitList(TiBasicParser.ListContext ctx);
102 | /**
103 | * Enter a parse tree produced by {@link TiBasicParser#space}.
104 | * @param ctx the parse tree
105 | */
106 | void enterSpace(TiBasicParser.SpaceContext ctx);
107 | /**
108 | * Exit a parse tree produced by {@link TiBasicParser#space}.
109 | * @param ctx the parse tree
110 | */
111 | void exitSpace(TiBasicParser.SpaceContext ctx);
112 | /**
113 | * Enter a parse tree produced by {@link TiBasicParser#quote}.
114 | * @param ctx the parse tree
115 | */
116 | void enterQuote(TiBasicParser.QuoteContext ctx);
117 | /**
118 | * Exit a parse tree produced by {@link TiBasicParser#quote}.
119 | * @param ctx the parse tree
120 | */
121 | void exitQuote(TiBasicParser.QuoteContext ctx);
122 | /**
123 | * Enter a parse tree produced by {@link TiBasicParser#letter}.
124 | * @param ctx the parse tree
125 | */
126 | void enterLetter(TiBasicParser.LetterContext ctx);
127 | /**
128 | * Exit a parse tree produced by {@link TiBasicParser#letter}.
129 | * @param ctx the parse tree
130 | */
131 | void exitLetter(TiBasicParser.LetterContext ctx);
132 | /**
133 | * Enter a parse tree produced by {@link TiBasicParser#colon}.
134 | * @param ctx the parse tree
135 | */
136 | void enterColon(TiBasicParser.ColonContext ctx);
137 | /**
138 | * Exit a parse tree produced by {@link TiBasicParser#colon}.
139 | * @param ctx the parse tree
140 | */
141 | void exitColon(TiBasicParser.ColonContext ctx);
142 | /**
143 | * Enter a parse tree produced by {@link TiBasicParser#semicolon}.
144 | * @param ctx the parse tree
145 | */
146 | void enterSemicolon(TiBasicParser.SemicolonContext ctx);
147 | /**
148 | * Exit a parse tree produced by {@link TiBasicParser#semicolon}.
149 | * @param ctx the parse tree
150 | */
151 | void exitSemicolon(TiBasicParser.SemicolonContext ctx);
152 | /**
153 | * Enter a parse tree produced by {@link TiBasicParser#comma}.
154 | * @param ctx the parse tree
155 | */
156 | void enterComma(TiBasicParser.CommaContext ctx);
157 | /**
158 | * Exit a parse tree produced by {@link TiBasicParser#comma}.
159 | * @param ctx the parse tree
160 | */
161 | void exitComma(TiBasicParser.CommaContext ctx);
162 | /**
163 | * Enter a parse tree produced by {@link TiBasicParser#period}.
164 | * @param ctx the parse tree
165 | */
166 | void enterPeriod(TiBasicParser.PeriodContext ctx);
167 | /**
168 | * Exit a parse tree produced by {@link TiBasicParser#period}.
169 | * @param ctx the parse tree
170 | */
171 | void exitPeriod(TiBasicParser.PeriodContext ctx);
172 | /**
173 | * Enter a parse tree produced by {@link TiBasicParser#open_bracket}.
174 | * @param ctx the parse tree
175 | */
176 | void enterOpen_bracket(TiBasicParser.Open_bracketContext ctx);
177 | /**
178 | * Exit a parse tree produced by {@link TiBasicParser#open_bracket}.
179 | * @param ctx the parse tree
180 | */
181 | void exitOpen_bracket(TiBasicParser.Open_bracketContext ctx);
182 | /**
183 | * Enter a parse tree produced by {@link TiBasicParser#close_bracket}.
184 | * @param ctx the parse tree
185 | */
186 | void enterClose_bracket(TiBasicParser.Close_bracketContext ctx);
187 | /**
188 | * Exit a parse tree produced by {@link TiBasicParser#close_bracket}.
189 | * @param ctx the parse tree
190 | */
191 | void exitClose_bracket(TiBasicParser.Close_bracketContext ctx);
192 | /**
193 | * Enter a parse tree produced by {@link TiBasicParser#equals}.
194 | * @param ctx the parse tree
195 | */
196 | void enterEquals(TiBasicParser.EqualsContext ctx);
197 | /**
198 | * Exit a parse tree produced by {@link TiBasicParser#equals}.
199 | * @param ctx the parse tree
200 | */
201 | void exitEquals(TiBasicParser.EqualsContext ctx);
202 | /**
203 | * Enter a parse tree produced by {@link TiBasicParser#number}.
204 | * @param ctx the parse tree
205 | */
206 | void enterNumber(TiBasicParser.NumberContext ctx);
207 | /**
208 | * Exit a parse tree produced by {@link TiBasicParser#number}.
209 | * @param ctx the parse tree
210 | */
211 | void exitNumber(TiBasicParser.NumberContext ctx);
212 | /**
213 | * Enter a parse tree produced by {@link TiBasicParser#pi}.
214 | * @param ctx the parse tree
215 | */
216 | void enterPi(TiBasicParser.PiContext ctx);
217 | /**
218 | * Exit a parse tree produced by {@link TiBasicParser#pi}.
219 | * @param ctx the parse tree
220 | */
221 | void exitPi(TiBasicParser.PiContext ctx);
222 | /**
223 | * Enter a parse tree produced by {@link TiBasicParser#e}.
224 | * @param ctx the parse tree
225 | */
226 | void enterE(TiBasicParser.EContext ctx);
227 | /**
228 | * Exit a parse tree produced by {@link TiBasicParser#e}.
229 | * @param ctx the parse tree
230 | */
231 | void exitE(TiBasicParser.EContext ctx);
232 | /**
233 | * Enter a parse tree produced by {@link TiBasicParser#i}.
234 | * @param ctx the parse tree
235 | */
236 | void enterI(TiBasicParser.IContext ctx);
237 | /**
238 | * Exit a parse tree produced by {@link TiBasicParser#i}.
239 | * @param ctx the parse tree
240 | */
241 | void exitI(TiBasicParser.IContext ctx);
242 | /**
243 | * Enter a parse tree produced by {@link TiBasicParser#newline}.
244 | * @param ctx the parse tree
245 | */
246 | void enterNewline(TiBasicParser.NewlineContext ctx);
247 | /**
248 | * Exit a parse tree produced by {@link TiBasicParser#newline}.
249 | * @param ctx the parse tree
250 | */
251 | void exitNewline(TiBasicParser.NewlineContext ctx);
252 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/antlr/TiBasicVisitor.java:
--------------------------------------------------------------------------------
1 | // Generated from TiBasic.g4 by ANTLR 4.9.1
2 |
3 | package com.efscript.antlr;
4 |
5 | import org.antlr.v4.runtime.tree.ParseTreeVisitor;
6 |
7 | /**
8 | * This interface defines a complete generic visitor for a parse tree produced
9 | * by {@link TiBasicParser}.
10 | *
11 | * @param The return type of the visit operation. Use {@link Void} for
12 | * operations with no return type.
13 | */
14 | public interface TiBasicVisitor extends ParseTreeVisitor {
15 | /**
16 | * Visit a parse tree produced by {@link TiBasicParser#script}.
17 | * @param ctx the parse tree
18 | * @return the visitor result
19 | */
20 | T visitScript(TiBasicParser.ScriptContext ctx);
21 | /**
22 | * Visit a parse tree produced by {@link TiBasicParser#token}.
23 | * @param ctx the parse tree
24 | * @return the visitor result
25 | */
26 | T visitToken(TiBasicParser.TokenContext ctx);
27 | /**
28 | * Visit a parse tree produced by {@link TiBasicParser#disp}.
29 | * @param ctx the parse tree
30 | * @return the visitor result
31 | */
32 | T visitDisp(TiBasicParser.DispContext ctx);
33 | /**
34 | * Visit a parse tree produced by {@link TiBasicParser#input}.
35 | * @param ctx the parse tree
36 | * @return the visitor result
37 | */
38 | T visitInput(TiBasicParser.InputContext ctx);
39 | /**
40 | * Visit a parse tree produced by {@link TiBasicParser#store}.
41 | * @param ctx the parse tree
42 | * @return the visitor result
43 | */
44 | T visitStore(TiBasicParser.StoreContext ctx);
45 | /**
46 | * Visit a parse tree produced by {@link TiBasicParser#if_}.
47 | * @param ctx the parse tree
48 | * @return the visitor result
49 | */
50 | T visitIf_(TiBasicParser.If_Context ctx);
51 | /**
52 | * Visit a parse tree produced by {@link TiBasicParser#then}.
53 | * @param ctx the parse tree
54 | * @return the visitor result
55 | */
56 | T visitThen(TiBasicParser.ThenContext ctx);
57 | /**
58 | * Visit a parse tree produced by {@link TiBasicParser#end}.
59 | * @param ctx the parse tree
60 | * @return the visitor result
61 | */
62 | T visitEnd(TiBasicParser.EndContext ctx);
63 | /**
64 | * Visit a parse tree produced by {@link TiBasicParser#list}.
65 | * @param ctx the parse tree
66 | * @return the visitor result
67 | */
68 | T visitList(TiBasicParser.ListContext ctx);
69 | /**
70 | * Visit a parse tree produced by {@link TiBasicParser#space}.
71 | * @param ctx the parse tree
72 | * @return the visitor result
73 | */
74 | T visitSpace(TiBasicParser.SpaceContext ctx);
75 | /**
76 | * Visit a parse tree produced by {@link TiBasicParser#quote}.
77 | * @param ctx the parse tree
78 | * @return the visitor result
79 | */
80 | T visitQuote(TiBasicParser.QuoteContext ctx);
81 | /**
82 | * Visit a parse tree produced by {@link TiBasicParser#letter}.
83 | * @param ctx the parse tree
84 | * @return the visitor result
85 | */
86 | T visitLetter(TiBasicParser.LetterContext ctx);
87 | /**
88 | * Visit a parse tree produced by {@link TiBasicParser#colon}.
89 | * @param ctx the parse tree
90 | * @return the visitor result
91 | */
92 | T visitColon(TiBasicParser.ColonContext ctx);
93 | /**
94 | * Visit a parse tree produced by {@link TiBasicParser#semicolon}.
95 | * @param ctx the parse tree
96 | * @return the visitor result
97 | */
98 | T visitSemicolon(TiBasicParser.SemicolonContext ctx);
99 | /**
100 | * Visit a parse tree produced by {@link TiBasicParser#comma}.
101 | * @param ctx the parse tree
102 | * @return the visitor result
103 | */
104 | T visitComma(TiBasicParser.CommaContext ctx);
105 | /**
106 | * Visit a parse tree produced by {@link TiBasicParser#period}.
107 | * @param ctx the parse tree
108 | * @return the visitor result
109 | */
110 | T visitPeriod(TiBasicParser.PeriodContext ctx);
111 | /**
112 | * Visit a parse tree produced by {@link TiBasicParser#open_bracket}.
113 | * @param ctx the parse tree
114 | * @return the visitor result
115 | */
116 | T visitOpen_bracket(TiBasicParser.Open_bracketContext ctx);
117 | /**
118 | * Visit a parse tree produced by {@link TiBasicParser#close_bracket}.
119 | * @param ctx the parse tree
120 | * @return the visitor result
121 | */
122 | T visitClose_bracket(TiBasicParser.Close_bracketContext ctx);
123 | /**
124 | * Visit a parse tree produced by {@link TiBasicParser#equals}.
125 | * @param ctx the parse tree
126 | * @return the visitor result
127 | */
128 | T visitEquals(TiBasicParser.EqualsContext ctx);
129 | /**
130 | * Visit a parse tree produced by {@link TiBasicParser#number}.
131 | * @param ctx the parse tree
132 | * @return the visitor result
133 | */
134 | T visitNumber(TiBasicParser.NumberContext ctx);
135 | /**
136 | * Visit a parse tree produced by {@link TiBasicParser#pi}.
137 | * @param ctx the parse tree
138 | * @return the visitor result
139 | */
140 | T visitPi(TiBasicParser.PiContext ctx);
141 | /**
142 | * Visit a parse tree produced by {@link TiBasicParser#e}.
143 | * @param ctx the parse tree
144 | * @return the visitor result
145 | */
146 | T visitE(TiBasicParser.EContext ctx);
147 | /**
148 | * Visit a parse tree produced by {@link TiBasicParser#i}.
149 | * @param ctx the parse tree
150 | * @return the visitor result
151 | */
152 | T visitI(TiBasicParser.IContext ctx);
153 | /**
154 | * Visit a parse tree produced by {@link TiBasicParser#newline}.
155 | * @param ctx the parse tree
156 | * @return the visitor result
157 | */
158 | T visitNewline(TiBasicParser.NewlineContext ctx);
159 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/ABlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script;
2 |
3 | import org.antlr.v4.runtime.ParserRuleContext;
4 |
5 | public abstract class ABlock implements IBlock {
6 | private T ctx;
7 |
8 | public ABlock(T ctx) {
9 | this.ctx = ctx;
10 | }
11 |
12 | public T getCtx() {
13 | return this.ctx;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/Context.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script;
2 |
3 | import com.efscript.Logger;
4 | import com.efscript.ti.TiCompiler;
5 | import com.efscript.ti.TiToken;
6 |
7 | import java.util.ArrayDeque;
8 | import java.util.ArrayList;
9 |
10 | //Class for current compiler context, also known as a "scope"
11 | public class Context {
12 | private static final ArrayDeque contexts = new ArrayDeque<>();
13 | public static Context currentContext() {
14 | return contexts.getFirst();
15 | }
16 | public static Context scriptContext() {
17 | return contexts.getLast();
18 | }
19 | public static Context popContext() {
20 | return contexts.removeFirst();
21 | }
22 | public static void pushContext(Context cont) {
23 | contexts.addFirst(cont);
24 | }
25 |
26 | String ctxName;
27 | ArrayList functions = new ArrayList<>(); // Only the 'SCRIPT' context is allowed to have functions
28 | ArrayList identifiers = new ArrayList<>();
29 | ArrayList parameters = new ArrayList<>();
30 | public Context(String name) {
31 | this.ctxName = name;
32 | }
33 |
34 | public String getName() {
35 | return this.ctxName;
36 | }
37 | public void addParameter(String param) {
38 | parameters.add(param);
39 | }
40 | public void addIdentifier(String identifier) {
41 | identifiers.add(identifier);
42 | }
43 | public String[] getVars() {
44 | String[] arr = new String[identifiers.size()];
45 | for(int i = 0; i < arr.length; i++) {
46 | arr[i] = identifiers.get(i);
47 | }
48 | return arr;
49 | }
50 | public String[] getParams() {
51 | String[] arr = new String[parameters.size()];
52 | for(int i = 0; i < arr.length; i++) {
53 | arr[i] = parameters.get(i);
54 | }
55 | return arr;
56 | }
57 | public String[] getIdentifiers() {
58 | String[] params = getParams();
59 | String[] vars = getVars();
60 | String[] total = new String[params.length + vars.length];
61 | for(int i = 0; i < total.length; i++) {
62 | if(i >= params.length) {
63 | total[i] = vars[i - params.length];
64 | }
65 | else {
66 | total[i] = params[i];
67 | }
68 | }
69 | return total;
70 | }
71 | public TiToken[] genAccessor(String identifier) throws Exception {
72 | //List & index ID vars
73 | int list = -1;
74 | int refIndex = -1;
75 |
76 | //Loop through identifiers
77 | for(int i = 0; i < identifiers.size(); i++) {
78 | //If the identifier matches
79 | if(identifiers.get(i).equals(identifier)) {
80 | //Set the values to ref it
81 | list = 1;
82 | refIndex = i+1;
83 | //We done
84 | break;
85 | }
86 | }
87 | //Loop through paramters
88 | //We do this 2nd because these should take priority in a name conflict
89 | for(int i = 0; i < parameters.size(); i++) {
90 | //If it matches
91 | if(parameters.get(i).equals(identifier)) {
92 | //Set the values to ref
93 | list = 2;
94 | refIndex = i+1;
95 | //Stop
96 | break;
97 | }
98 | }
99 | //If no matches, something went wrong, so we throw an exception
100 | if(list == -1) {
101 | throw new Exception("No such identifier \""+identifier+"\"");
102 | }
103 |
104 | //Compile the reference
105 | TiCompiler comp = new TiCompiler();
106 | //Compiles to [J]([J](1,5), INDEX)
107 | comp.appendInstruction(TiToken.MATRIX_J);
108 | comp.appendInstruction(TiToken.OPEN_BRACKET);
109 | comp.appendInstruction(TiToken.MATRIX_J);
110 | comp.appendInstruction(TiToken.OPEN_BRACKET);
111 | comp.appendInstruction(TiToken.NUM_1);
112 | comp.appendInstruction(TiToken.COMMA);
113 | comp.appendInstruction(TiToken.NUM_5);
114 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
115 | comp.appendInstruction(TiToken.COMMA);
116 | comp.appendInstruction(TiToken.getNumber(refIndex));
117 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
118 | return comp.getTokens();
119 | }
120 |
121 | public int getFuncID(String function) {
122 | Context scriptCtx = scriptContext();
123 | int id = 0;
124 | for(String func : scriptCtx.functions) {
125 | if(func.equals(function)) {
126 | break;
127 | }
128 | id++;
129 | }
130 | return id;
131 | }
132 | public void addFunction(String name, int funcId) {
133 | functions.add(funcId, name);
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/EFSCompiler.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script;
2 |
3 | import com.efscript.Logger;
4 | import com.efscript.antlr.EFScriptLexer;
5 | import com.efscript.antlr.EFScriptListener;
6 | import com.efscript.antlr.EFScriptParser;
7 | import com.efscript.antlr.EFScriptParser.Add_assign_stmtContext;
8 | import com.efscript.antlr.EFScriptParser.Assign_stmtContext;
9 | import com.efscript.antlr.EFScriptParser.BoolexprContext;
10 | import com.efscript.antlr.EFScriptParser.Dec_stmtContext;
11 | import com.efscript.antlr.EFScriptParser.Div_assign_stmtContext;
12 | import com.efscript.antlr.EFScriptParser.ExpressionContext;
13 | import com.efscript.antlr.EFScriptParser.Func_paramsContext;
14 | import com.efscript.antlr.EFScriptParser.FunctionContext;
15 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
16 | import com.efscript.antlr.EFScriptParser.If_stmtContext;
17 | import com.efscript.antlr.EFScriptParser.Inc_stmtContext;
18 | import com.efscript.antlr.EFScriptParser.MethodcallContext;
19 | import com.efscript.antlr.EFScriptParser.MethodparamsContext;
20 | import com.efscript.antlr.EFScriptParser.Mul_assign_stmtContext;
21 | import com.efscript.antlr.EFScriptParser.NumberContext;
22 | import com.efscript.antlr.EFScriptParser.Return_stmtContext;
23 | import com.efscript.antlr.EFScriptParser.ScriptContext;
24 | import com.efscript.antlr.EFScriptParser.StatementContext;
25 | import com.efscript.antlr.EFScriptParser.Sub_assign_stmtContext;
26 | import com.efscript.antlr.EFScriptParser.ValueContext;
27 | import com.efscript.antlr.EFScriptParser.Var_stmtContext;
28 | import com.efscript.antlr.EFScriptParser.While_stmtContext;
29 | import com.efscript.script.blocks.EFSScriptBlock;
30 | import com.efscript.ti.TiCompiler;
31 | import com.efscript.ti.TiToken;
32 |
33 | import org.antlr.v4.runtime.CharStreams;
34 | import org.antlr.v4.runtime.CommonTokenStream;
35 | import org.antlr.v4.runtime.ParserRuleContext;
36 | import org.antlr.v4.runtime.tree.ErrorNode;
37 | import org.antlr.v4.runtime.tree.TerminalNode;
38 |
39 | public class EFSCompiler {
40 | // Ti-Basic compiler
41 | private TiCompiler compTokens;
42 |
43 | // Initialize the compiler
44 | public EFSCompiler(String code) {
45 | Logger.Log("Parsing script...");
46 | // Parser & Lexer contexts
47 | EFScriptLexer lexer = new EFScriptLexer(CharStreams.fromString(code));
48 | EFScriptParser parser = new EFScriptParser(new CommonTokenStream(lexer));
49 | // Get the script context
50 | parsed = parser.script();
51 | Logger.Log("Script parsed");
52 | }
53 |
54 | // The func that will compile the script start to finish
55 | private ScriptContext parsed;
56 |
57 | public TiToken[] getTokens() throws Exception {
58 | if (parsed == null) {
59 | Logger.Log("You must parse the script first!");
60 | return null;
61 | }
62 |
63 | // Create compiler instance
64 | compTokens = new TiCompiler();
65 |
66 | EFSScriptBlock script = new EFSScriptBlock(parsed);
67 | compTokens.appendInstruction(script.compile());
68 |
69 | return compTokens.getTokens();
70 | }
71 | public byte[] compile() throws Exception {
72 | Logger.Log("Compiling...");
73 | byte[] compiled = new TiCompiler().appendInstruction(getTokens()).compile();
74 | Logger.Log("Compiled!");
75 | return compiled;
76 | }
77 |
78 | public String getMetaScriptName() {
79 | return parsed.header().meta().scriptName().identifier().getText();
80 | }
81 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/IBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script;
2 |
3 | import com.efscript.ti.TiToken;
4 |
5 | public interface IBlock {
6 | public TiToken[] compile() throws Exception;
7 | }
8 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/EFSFunctionBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import com.efscript.Logger;
7 | import com.efscript.antlr.EFScriptParser;
8 | import com.efscript.antlr.EFScriptParser.Func_paramsContext;
9 | import com.efscript.antlr.EFScriptParser.FunctionContext;
10 | import com.efscript.antlr.EFScriptParser.StatementContext;
11 | import com.efscript.script.Context;
12 | import com.efscript.script.IBlock;
13 | import com.efscript.ti.TiCompiler;
14 | import com.efscript.ti.TiToken;
15 |
16 | public class EFSFunctionBlock implements IBlock {
17 |
18 | String name;
19 | List> blocks;
20 | Func_paramsContext parameters;
21 |
22 | // Create a func block from a context
23 | public EFSFunctionBlock(FunctionContext ctx) throws Exception {
24 | // Init vars
25 | this.parameters = ctx.func_params();
26 | this.blocks = new ArrayList<>();
27 | this.name = ctx.identifier().getText();
28 |
29 | boolean isCurl = ctx.statement().OPEN_CURLEY() != null;
30 | StatementContext stmtCtx = ctx.statement();
31 | // If successful
32 | if (isCurl) {
33 | // Iterate sub-contexts
34 | for (StatementContext leCtx : stmtCtx.statement()) {
35 | // Store the code block(s)
36 | EFSStatementBlock> stmtBlock = EFSStatementBlock.getAppropriate(leCtx);
37 | if (stmtBlock == null)
38 | Logger.Log("Null subStmt");
39 | this.blocks.add(stmtBlock);
40 | }
41 | return;
42 | }
43 | // If not, must be a single statement, therefore we
44 | // can just create the appropriate block
45 | // and store that.
46 | EFSStatementBlock> stmtBlock = EFSStatementBlock.getAppropriate(stmtCtx);
47 | if (stmtBlock == null)
48 | throw new Exception("Null statement? Very bad");
49 | this.blocks.add(stmtBlock);
50 | }
51 |
52 | @Override
53 | public TiToken[] compile() throws Exception {
54 | TiCompiler comp = new TiCompiler();
55 |
56 | // Push a new context
57 | Context newCtx = new Context("FUNC: "+this.name);
58 | //Add parameters to the new context
59 | for(EFScriptParser.IdentifierContext iCtx : parameters.identifier()) {
60 | newCtx.addParameter(iCtx.getText());
61 | }
62 | //Push the context
63 | Context.pushContext(newCtx);
64 |
65 | for (EFSStatementBlock> block : this.blocks) {
66 | if (block == null) {
67 | throw new Exception("A code block for a function was null? ");
68 | }
69 | comp.appendInstruction(block.compile());
70 | }
71 |
72 | comp.appendInstruction(TiToken.NEWLINE);
73 |
74 | return comp.getTokens();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/EFSGenericExpression.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks;
2 |
3 | import com.efscript.script.ABlock;
4 | import com.efscript.script.IBlock;
5 | import com.efscript.script.blocks.expressions.EFSExpressionBlock;
6 |
7 | import org.antlr.v4.runtime.ParserRuleContext;
8 |
9 | public abstract class EFSGenericExpression extends EFSStatementBlock {
10 | public EFSGenericExpression(T ctx) {
11 | super(ctx);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/EFSScriptBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks;
2 |
3 | import com.efscript.Logger;
4 | import com.efscript.antlr.EFScriptParser.FunctionContext;
5 | import com.efscript.antlr.EFScriptParser.ScriptContext;
6 | import com.efscript.antlr.EFScriptParser.StatementContext;
7 | import com.efscript.script.ABlock;
8 | import com.efscript.script.Context;
9 | import com.efscript.ti.TiCompiler;
10 | import com.efscript.ti.TiToken;
11 |
12 | public class EFSScriptBlock extends ABlock {
13 |
14 | public EFSScriptBlock(ScriptContext ctx) {
15 | super(ctx);
16 | }
17 |
18 | @Override
19 | public TiToken[] compile() throws Exception {
20 | TiCompiler comp = new TiCompiler();
21 | ScriptContext ctx = this.getCtx();
22 | String scriptMetaName = ctx.header().meta().scriptName().identifier().getText();
23 | Context.pushContext(new Context(scriptMetaName));
24 |
25 | // Pre initialization
26 | // Due to the fact we use matrices now, we need to check the
27 | // dimensions of the matrix to see if its even defined. If its undefined, we should
28 | // define it with 1x1 matrix filled with 0. From then on, the rest of the program
29 | // should safely size the table.
30 | /*
31 | * dim([J])->L1
32 | * If L1(1)=0 or L1(2)=0
33 | * Then
34 | * [[0]]->[J]
35 | * End
36 | */
37 |
38 | // Initialization section
39 | // Basically just reset the registers
40 | // (And hope I=0, otherwise the program will be die)
41 | /*
42 | * If [J](1,1)=0
43 | * Then
44 | * 1->[J](1,1)
45 | * 0->[J](1,2)
46 | * 0->[J](1,3)
47 | * 0->[J](1,4)
48 | * 1->[J](1,5)
49 | * End
50 | */
51 | // IF [J](1,1)=0
52 | // Then
53 | comp.appendInstruction(TiToken.IF);
54 | comp.appendInstruction(TiToken.MATRIX_J);
55 | comp.appendInstruction(TiToken.OPEN_BRACKET);
56 | comp.appendInstruction(TiToken.NUM_1);
57 | comp.appendInstruction(TiToken.COMMA);
58 | comp.appendInstruction(TiToken.NUM_1);
59 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
60 | comp.appendInstruction(TiToken.EQUALS);
61 | comp.appendInstruction(TiToken.NUM_0);
62 | comp.appendInstruction(TiToken.NEWLINE);
63 | comp.appendInstruction(TiToken.THEN);
64 | comp.appendInstruction(TiToken.NEWLINE);
65 | /*
66 | * 1->[J](1,1)
67 | * 0->[J](1,2)
68 | * 0->[J](1,3)
69 | * 0->[J](1,4)
70 | * 1->[J](1,5)
71 | */
72 | // 1->[J](1,1)
73 | comp.appendInstruction(TiToken.NUM_1);
74 | comp.appendInstruction(TiToken.STORE);
75 | comp.appendInstruction(TiToken.MATRIX_J);
76 | comp.appendInstruction(TiToken.OPEN_BRACKET);
77 | comp.appendInstruction(TiToken.NUM_1);
78 | comp.appendInstruction(TiToken.COMMA);
79 | comp.appendInstruction(TiToken.NUM_1);
80 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
81 | comp.appendInstruction(TiToken.NEWLINE);
82 | // 0->[J](1,2)
83 | comp.appendInstruction(TiToken.NUM_0);
84 | comp.appendInstruction(TiToken.STORE);
85 | comp.appendInstruction(TiToken.MATRIX_J);
86 | comp.appendInstruction(TiToken.OPEN_BRACKET);
87 | comp.appendInstruction(TiToken.NUM_1);
88 | comp.appendInstruction(TiToken.COMMA);
89 | comp.appendInstruction(TiToken.NUM_2);
90 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
91 | comp.appendInstruction(TiToken.NEWLINE);
92 | // 0->[J](1,3)
93 | comp.appendInstruction(TiToken.NUM_0);
94 | comp.appendInstruction(TiToken.STORE);
95 | comp.appendInstruction(TiToken.MATRIX_J);
96 | comp.appendInstruction(TiToken.OPEN_BRACKET);
97 | comp.appendInstruction(TiToken.NUM_1);
98 | comp.appendInstruction(TiToken.COMMA);
99 | comp.appendInstruction(TiToken.NUM_3);
100 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
101 | comp.appendInstruction(TiToken.NEWLINE);
102 | // 0->[J](1,4)
103 | comp.appendInstruction(TiToken.NUM_0);
104 | comp.appendInstruction(TiToken.STORE);
105 | comp.appendInstruction(TiToken.MATRIX_J);
106 | comp.appendInstruction(TiToken.OPEN_BRACKET);
107 | comp.appendInstruction(TiToken.NUM_1);
108 | comp.appendInstruction(TiToken.COMMA);
109 | comp.appendInstruction(TiToken.NUM_4);
110 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
111 | comp.appendInstruction(TiToken.NEWLINE);
112 | // 1->[J](1,5)
113 | comp.appendInstruction(TiToken.NUM_1);
114 | comp.appendInstruction(TiToken.STORE);
115 | comp.appendInstruction(TiToken.MATRIX_J);
116 | comp.appendInstruction(TiToken.OPEN_BRACKET);
117 | comp.appendInstruction(TiToken.NUM_1);
118 | comp.appendInstruction(TiToken.COMMA);
119 | comp.appendInstruction(TiToken.NUM_5);
120 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
121 | comp.appendInstruction(TiToken.NEWLINE);
122 | // END
123 | comp.appendInstruction(TiToken.END);
124 | comp.appendInstruction(TiToken.NEWLINE);
125 |
126 | // Function table
127 | /*
128 | * //[J](1,3) determines if a func is called
129 | * If [J](1,3)>0
130 | * //Funcs must be defined at the top of the script
131 | * Then
132 | * //[J](1,2) is which function
133 | * If [J](1,2)=0
134 | * Then
135 | * [J]([J](1,5), 1)+[J]([J](1,5), 2)→C
136 | * End
137 | * End
138 | */
139 | comp.appendInstruction(TiToken.IF);
140 | comp.appendInstruction(TiToken.MATRIX_J);
141 | comp.appendInstruction(TiToken.OPEN_BRACKET);
142 | comp.appendInstruction(TiToken.NUM_1);
143 | comp.appendInstruction(TiToken.COMMA);
144 | comp.appendInstruction(TiToken.NUM_3);
145 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
146 | comp.appendInstruction(TiToken.GREATER_THAN);
147 | comp.appendInstruction(TiToken.NUM_0);
148 | comp.appendInstruction(TiToken.NEWLINE);
149 | comp.appendInstruction(TiToken.THEN);
150 | comp.appendInstruction(TiToken.NEWLINE);
151 |
152 | boolean hasFunc = ctx.function() != null;
153 | if (hasFunc) {
154 | for (int funcId = 0; funcId < ctx.function().size(); funcId++) {
155 | /*
156 | * Compiles to:
157 | * If [J](1,2)=funcId
158 | * Then
159 | *
160 | * End
161 | */
162 | comp.appendInstruction(TiToken.IF);
163 | comp.appendInstruction(TiToken.MATRIX_J);
164 | comp.appendInstruction(TiToken.OPEN_BRACKET);
165 | comp.appendInstruction(TiToken.NUM_1);
166 | comp.appendInstruction(TiToken.COMMA);
167 | comp.appendInstruction(TiToken.NUM_2);
168 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
169 | comp.appendInstruction(TiToken.EQUALS);
170 | comp.appendInstruction(TiToken.getNumber(funcId));
171 | comp.appendInstruction(TiToken.NEWLINE);
172 | comp.appendInstruction(TiToken.THEN);
173 | comp.appendInstruction(TiToken.NEWLINE);
174 |
175 | FunctionContext code = ctx.function(funcId);
176 | EFSFunctionBlock funcBlock = new EFSFunctionBlock(code);
177 | comp.appendInstruction(funcBlock.compile());
178 |
179 | comp.appendInstruction(TiToken.END);
180 | comp.appendInstruction(TiToken.NEWLINE);
181 |
182 | Context.scriptContext().addFunction(code.identifier().getText(), funcId);
183 | }
184 | }
185 | comp.appendInstruction(TiToken.END);
186 | comp.appendInstruction(TiToken.NEWLINE);
187 |
188 | //TODO: Finish updating this file
189 | comp.appendInstruction(TiToken.IF);
190 | comp.appendInstruction(TiToken.LETTER_G);
191 | comp.appendInstruction(TiToken.EQUALS);
192 | comp.appendInstruction(TiToken.NUM_0);
193 | comp.appendInstruction(TiToken.NEWLINE);
194 | comp.appendInstruction(TiToken.THEN);
195 | comp.appendInstruction(TiToken.NEWLINE);
196 | for (StatementContext stmt : ctx.statement()) {
197 | EFSStatementBlock> stmtBlock = EFSStatementBlock.getAppropriate(stmt);
198 | comp.appendInstruction(stmtBlock.compile());
199 | comp.appendInstruction(TiToken.NEWLINE);
200 | }
201 |
202 | comp.appendInstruction(TiToken.END);
203 | comp.appendInstruction(TiToken.NEWLINE);
204 | comp.appendInstruction(TiToken.NUM_0);
205 | comp.appendInstruction(TiToken.STORE);
206 | comp.appendInstruction(TiToken.LETTER_I);
207 |
208 | return comp.getTokens();
209 | }
210 |
211 | }
212 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/EFSStatementBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks;
2 |
3 | import com.efscript.Logger;
4 | import com.efscript.antlr.EFScriptParser.Add_assign_stmtContext;
5 | import com.efscript.antlr.EFScriptParser.Assign_stmtContext;
6 | import com.efscript.antlr.EFScriptParser.Dec_stmtContext;
7 | import com.efscript.antlr.EFScriptParser.Div_assign_stmtContext;
8 | import com.efscript.antlr.EFScriptParser.If_stmtContext;
9 | import com.efscript.antlr.EFScriptParser.Inc_stmtContext;
10 | import com.efscript.antlr.EFScriptParser.Mul_assign_stmtContext;
11 | import com.efscript.antlr.EFScriptParser.Return_stmtContext;
12 | import com.efscript.antlr.EFScriptParser.StatementContext;
13 | import com.efscript.antlr.EFScriptParser.Var_stmtContext;
14 | import com.efscript.antlr.EFScriptParser.While_stmtContext;
15 | import com.efscript.script.ABlock;
16 | import com.efscript.script.IBlock;
17 | import com.efscript.script.blocks.expressions.EFSExpressionBlock;
18 | import com.efscript.script.blocks.statements.*;
19 |
20 | import org.antlr.v4.runtime.ParserRuleContext;
21 |
22 | public abstract class EFSStatementBlock extends ABlock {
23 |
24 | // Create the appropriate block
25 | public static EFSStatementBlock> getAppropriate(StatementContext ctx) throws Exception {
26 | // Check what kind of context it is
27 | boolean isBrack = ctx.OPEN_CURLEY() != null;
28 | boolean isIf = ctx.if_stmt() != null;
29 | boolean isDec = ctx.dec_stmt() != null;
30 | boolean isInc = ctx.inc_stmt() != null;
31 | boolean isVar = ctx.var_stmt() != null;
32 | boolean isWhile = ctx.while_stmt() != null;
33 | boolean isAssign = ctx.assign_stmt() != null;
34 | boolean isReturn = ctx.return_stmt() != null;
35 | boolean isAddAssign = ctx.add_assign_stmt() != null;
36 | boolean isSubAssign = ctx.add_assign_stmt() != null;
37 | boolean isMulAssign = ctx.add_assign_stmt() != null;
38 | boolean isDivAssign = ctx.add_assign_stmt() != null;
39 | boolean isExpression = ctx.expression() != null;
40 | boolean isTIB = ctx.ti_basic_stmt() != null;
41 |
42 | // create that type of block.
43 | if (isIf) {
44 | return new EFSIfBlock(ctx.if_stmt());
45 | }
46 | if (isDec) {
47 | return new EFSDecBlock(ctx.dec_stmt());
48 | }
49 | if (isInc) {
50 | return new EFSIncBlock(ctx.inc_stmt());
51 | }
52 | if (isVar) {
53 | return new EFSVarBlock(ctx.var_stmt());
54 | }
55 | if (isWhile) {
56 | return new EFSWhileBlock(ctx.while_stmt());
57 | }
58 | if (isAssign) {
59 | return new EFSAssignBlock(ctx.assign_stmt());
60 | }
61 | if (isReturn) {
62 | return new EFSReturnBlock(ctx.return_stmt());
63 | }
64 | if (isAddAssign) {
65 | return new EFSAddAssignBlock(ctx.add_assign_stmt());
66 | }
67 | if (isSubAssign) {
68 | return new EFSSubAssignBlock(ctx.sub_assign_stmt());
69 | }
70 | if (isMulAssign) {
71 | return new EFSMulAssignBlock(ctx.mul_assign_stmt());
72 | }
73 | if (isDivAssign) {
74 | return new EFSDivAssignBlock(ctx.div_assign_stmt());
75 | }
76 | if (isExpression) {
77 | return new EFSExpressionBlock(ctx.expression());
78 | }
79 | if(isTIB) {
80 | return new EFSTiBasicBlock(ctx.ti_basic_stmt());
81 | }
82 | if(isBrack) {
83 | return new EFSBracketBlock(ctx);
84 | }
85 | throw new Exception("Unknown statement! Very bad");
86 | }
87 |
88 | public EFSStatementBlock(T ctx) {
89 | super(ctx);
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/EFSValueBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks;
2 |
3 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
4 | import com.efscript.antlr.EFScriptParser.NumberContext;
5 | import com.efscript.antlr.EFScriptParser.ValueContext;
6 | import com.efscript.script.ABlock;
7 | import com.efscript.script.Context;
8 | import com.efscript.ti.TiCompiler;
9 | import com.efscript.ti.TiToken;
10 |
11 | import org.antlr.v4.runtime.tree.TerminalNode;
12 |
13 | public class EFSValueBlock extends ABlock {
14 | public EFSValueBlock(ValueContext ctx) {
15 | super(ctx);
16 | }
17 |
18 | @Override
19 | public TiToken[] compile() throws Exception {
20 | TiCompiler compiler = new TiCompiler();
21 |
22 | ValueContext vctx = this.getCtx();
23 | // Values can be either an identifier
24 | // or a number. Identifiers must be values
25 | // and not function names.
26 | boolean isIdentifier = vctx.identifier() != null;
27 | boolean isNumber = vctx.number() != null;
28 |
29 | if (isIdentifier) {
30 | // Get the identifier context
31 | IdentifierContext ictx = vctx.identifier();
32 | // Get a var token for the identifier
33 | TiToken[] accessor = Context.currentContext().genAccessor(ictx.getText());
34 | // Generate & append the reference code
35 | compiler.appendInstruction(accessor);
36 | }
37 | if (isNumber) {
38 | NumberContext nctx = vctx.number();
39 | // Numbers can be 'pi' or 'e', and
40 | // the calculator already has these mathematical
41 | // constants, might as well use them
42 | boolean isPi = nctx.PI() != null;
43 | boolean isE = nctx.E() != null;
44 | if (isPi) {
45 | compiler.appendInstruction(TiToken.CONST_PI);
46 | } else if (isE) {
47 | compiler.appendInstruction(TiToken.CONST_E);
48 | } else {
49 | // This case it has to be a number
50 | TerminalNode numNode = nctx.NUMBER();
51 | // Get the number as text
52 | String nodeText = numNode.getText();
53 |
54 | // Loop through each char
55 | for (int i = 0; i < nodeText.length(); i++) {
56 | char c = nodeText.charAt(i);
57 | switch (c) {
58 | // If its a -, we have to convert that to a negate token
59 | case '-':
60 | compiler.appendInstruction(TiToken.NEGATE);
61 | break;
62 | // If its a . thats the period token
63 | case '.':
64 | compiler.appendInstruction(TiToken.PERIOD);
65 | break;
66 | // Otherwise just convert the number and append it
67 | default:
68 | int num = Integer.parseInt("" + c);
69 | TiToken next = TiToken.getNumber(num)[0];
70 | compiler.appendInstruction(next);
71 | }
72 | }
73 | }
74 | }
75 |
76 | return compiler.getTokens();
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/expressions/EFSBoolexprBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.expressions;
2 |
3 | import com.efscript.antlr.EFScriptParser.BoolexprContext;
4 | import com.efscript.script.blocks.EFSGenericExpression;
5 | import com.efscript.script.blocks.EFSValueBlock;
6 | import com.efscript.ti.TiCompiler;
7 | import com.efscript.ti.TiToken;
8 |
9 | public class EFSBoolexprBlock extends EFSGenericExpression {
10 |
11 | public EFSBoolexprBlock(BoolexprContext ctx) {
12 | super(ctx);
13 | }
14 |
15 | @Override
16 | public TiToken[] compile() throws Exception {
17 | TiCompiler compiler = new TiCompiler();
18 | BoolexprContext ctx = this.getCtx();
19 |
20 | // Non lo so perche questo non vuole funzionare
21 | if(ctx == null) {
22 | throw new Exception("Null bool ctx");
23 | }
24 |
25 | // Check for value
26 | boolean isValueExpr = ctx.value() != null;
27 | if (isValueExpr) {
28 | // Epic cool cool
29 | EFSValueBlock block = new EFSValueBlock(ctx.value());
30 | compiler.appendInstruction(block.compile());
31 | }
32 |
33 | // If is the 'true' keyword
34 | boolean isTrue = ctx.TRUE() != null;
35 | if (isTrue) {
36 | // 1 is the same as 'true'
37 | compiler.appendInstruction(TiToken.NUM_1);
38 | }
39 | // If is the 'false' keyword
40 | boolean isFalse = ctx.TRUE() != null;
41 | if (isFalse) {
42 | // 0 is the same as 'false'
43 | compiler.appendInstruction(TiToken.NUM_0);
44 | }
45 | // If isnt just true or false, it must start with a value.
46 | if (!isTrue && !isFalse) {
47 | // Value shit
48 | //EFSValueBlock valBlock = new EFSValueBlock(ctx.value());
49 | //compiler.appendInstruction(valBlock.compile());
50 | // Someone come up with a cooler way to do this, please, thanks
51 | boolean isGT = ctx.GREATER_THAN() != null;
52 | boolean isLT = ctx.LESS_THAN() != null;
53 | boolean isET = ctx.EQUAL_TO() != null;
54 | boolean isNET = ctx.NOT_EQUAL_TO() != null;
55 | boolean isGTOE = ctx.GREATER_THAN_OR_EQUAL() != null;
56 | boolean isLTOE = ctx.LESS_THAN_OR_EQUAL() != null;
57 | boolean isOr = ctx.OR() != null;
58 | boolean isAnd = ctx.AND() != null;
59 |
60 | // Bruhzowski
61 | if (isGT) {
62 | compiler.appendInstruction(TiToken.GREATER_THAN);
63 | }
64 | if (isLT) {
65 | compiler.appendInstruction(TiToken.LESS_THAN);
66 | }
67 | if (isET) {
68 | compiler.appendInstruction(TiToken.EQUALS);
69 | }
70 | if (isNET) {
71 | compiler.appendInstruction(TiToken.NOT_EQUAL);
72 | }
73 | if (isGTOE) {
74 | compiler.appendInstruction(TiToken.GREATER_THAN_OR_EQUAL);
75 | }
76 | if (isLTOE) {
77 | compiler.appendInstruction(TiToken.LESS_THAN_OR_EQUAL);
78 | }
79 | if (isOr) {
80 | compiler.appendInstruction(TiToken.OR);
81 | }
82 | if (isAnd) {
83 | compiler.appendInstruction(TiToken.AND);
84 | }
85 |
86 | // The right hand must be another expression
87 | BoolexprContext bCtx = ctx.boolexpr();
88 | if(bCtx != null) {
89 | EFSBoolexprBlock recBlock = new EFSBoolexprBlock(bCtx);
90 | compiler.appendInstruction(recBlock.compile());
91 | }
92 | }
93 |
94 | return compiler.getTokens();
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/expressions/EFSCallBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.expressions;
2 |
3 | import com.efscript.antlr.EFScriptParser.ExpressionContext;
4 | import com.efscript.antlr.EFScriptParser.MethodcallContext;
5 | import com.efscript.antlr.EFScriptParser.MethodparamsContext;
6 | import com.efscript.script.Context;
7 | import com.efscript.script.blocks.EFSGenericExpression;
8 | import com.efscript.ti.TiCompiler;
9 | import com.efscript.ti.TiToken;
10 |
11 | import java.util.List;
12 |
13 | public class EFSCallBlock extends EFSGenericExpression {
14 | public EFSCallBlock(MethodcallContext ctx) {
15 | super(ctx);
16 | }
17 |
18 | @Override
19 | public TiToken[] compile() throws Exception {
20 | TiCompiler comp = new TiCompiler();
21 |
22 | MethodcallContext ctx = this.getCtx();
23 |
24 | //Push parameters
25 | MethodparamsContext pCtx = ctx.methodparams();
26 | List params = pCtx.expression();
27 | //Should be "[J]([J](1, 5), ", which can then be completed with a number and the required closing bracket(s)
28 | //The current context stack location should be placed at [J](1,5) BEFORE this param list is accessed
29 | TiToken[] paramList = {
30 | TiToken.MATRIX_J,
31 | TiToken.OPEN_BRACKET,
32 | TiToken.MATRIX_J,
33 | TiToken.OPEN_BRACKET,
34 | TiToken.NUM_1,
35 | TiToken.COMMA,
36 | TiToken.NUM_5,
37 | TiToken.CLOSE_BRACKET,
38 | TiToken.COMMA
39 | };
40 |
41 | //Increment [J](1,5) to the new stack loc value
42 | TiToken[] stackLoc = {
43 | TiToken.MATRIX_J,
44 | TiToken.OPEN_BRACKET,
45 | TiToken.NUM_1,
46 | TiToken.COMMA,
47 | TiToken.NUM_5,
48 | TiToken.CLOSE_BRACKET
49 | };
50 | comp.appendInstruction(stackLoc);
51 | comp.appendInstruction(TiToken.ADD);
52 | comp.appendInstruction(TiToken.NUM_1);
53 | comp.appendInstruction(TiToken.STORE);
54 | comp.appendInstruction(stackLoc);
55 |
56 | for(int i = 0; i < params.size(); i++) {
57 | ExpressionContext iCtx = params.get(i);
58 | EFSExpressionBlock exprBlock = new EFSExpressionBlock(iCtx);
59 | comp.appendInstruction(exprBlock.compile());
60 | comp.appendInstruction(TiToken.STORE);
61 | comp.appendInstruction(paramList);
62 | //The aforementioned number and closing bracket
63 | comp.appendInstruction(TiToken.getNumber(i + 1));
64 | comp.appendInstruction(TiToken.CLOSE_BRACKET);
65 | comp.appendInstruction(TiToken.NEWLINE);
66 | }
67 |
68 | //Set calling values
69 | comp.appendInstruction(TiToken.NUM_1);
70 | comp.appendInstruction(TiToken.STORE);
71 | comp.appendInstruction(TiToken.LETTER_G);
72 | comp.appendInstruction(TiToken.NEWLINE);
73 |
74 | String funcName = ctx.identifier().getText();
75 | int funcId = Context.scriptContext().getFuncID(funcName);
76 | comp.appendInstruction(TiToken.getNumber(funcId));
77 | comp.appendInstruction(TiToken.STORE);
78 | comp.appendInstruction(TiToken.LETTER_F);
79 | comp.appendInstruction(TiToken.NEWLINE);
80 |
81 | //Call the program again
82 | String scriptName = Context.scriptContext().getName();
83 | TiToken[] scriptText = TiToken.convertText(scriptName);
84 | comp.appendInstruction(TiToken.PRGM);
85 | comp.appendInstruction(scriptText);
86 | comp.appendInstruction(TiToken.NEWLINE);
87 |
88 | //The return value
89 | comp.appendInstruction(TiToken.LETTER_C);
90 |
91 | return comp.getTokens();
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/expressions/EFSExpressionBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.expressions;
2 |
3 | import com.efscript.Logger;
4 | import com.efscript.antlr.EFScriptParser.BoolexprContext;
5 | import com.efscript.antlr.EFScriptParser.ExpressionContext;
6 | import com.efscript.script.blocks.EFSGenericExpression;
7 | import com.efscript.script.blocks.EFSValueBlock;
8 | import com.efscript.ti.TiCompiler;
9 | import com.efscript.ti.TiToken;
10 |
11 | public class EFSExpressionBlock extends EFSGenericExpression {
12 |
13 | public EFSExpressionBlock(ExpressionContext ctx) {
14 | super(ctx);
15 | }
16 |
17 | // Compile the context to Ti-Basic tokens
18 | @Override
19 | public TiToken[] compile() throws Exception {
20 | TiCompiler compiler = new TiCompiler();
21 |
22 | ExpressionContext ctx = this.getCtx();
23 | if (ctx == null) {
24 | throw new Exception("Something went terribly wrong when compiling an expression. (Unknown expression?)");
25 | }
26 |
27 | //If its a method call, we want to create that
28 | boolean isCall = ctx.methodcall() != null;
29 | if(isCall) {
30 | EFSCallBlock callBlock = new EFSCallBlock(ctx.methodcall());
31 | compiler.appendInstruction(callBlock.compile());
32 | }
33 | else {
34 | // If its a value, we want to convert it
35 | // to the right format for the calc
36 | boolean isValueExpr = ctx.value() != null;
37 | if (isValueExpr) {
38 | // Epic cool cool
39 | EFSValueBlock block = new EFSValueBlock(ctx.value());
40 | compiler.appendInstruction(block.compile());
41 | } else {
42 | // Check if its a bracket expression,
43 | // if so, we need to compile the inner expression
44 | // and we can do this recursively
45 | boolean isBrack = ctx.OPEN_BRACKET() != null;
46 | if (isBrack) {
47 | // Create a new block on the current expression
48 | EFSExpressionBlock block = new EFSExpressionBlock(this.getCtx().expression(0));
49 | // Append tokens
50 | compiler.appendInstruction(TiToken.OPEN_BRACKET);
51 | compiler.appendInstruction(block.compile());
52 | compiler.appendInstruction(TiToken.CLOSE_BRACKET);
53 | }
54 | // If its not a bracket expression, we
55 | // Can compile it to Ti-Basic
56 | else {
57 | // If its a bool expression, we want
58 | // to compile it before trying anything
59 | // else
60 | boolean isBoolExpr = ctx.boolexpr() != null;
61 | if (isBoolExpr) {
62 | // Get the boolexpr context
63 | BoolexprContext bectx = ctx.boolexpr();
64 | EFSBoolexprBlock bExpr = new EFSBoolexprBlock(bectx);
65 | compiler.appendInstruction(bExpr.compile());
66 | } else {
67 | // Check what type of expression it is
68 | boolean isAdd = ctx.ADD() != null;
69 | boolean isSub = ctx.SUB() != null;
70 | boolean isMul = ctx.MUL() != null;
71 | boolean isDiv = ctx.DIV() != null;
72 |
73 | // Create a new block on the current expression
74 | // Also compile it so that way operations can be done later
75 | EFSExpressionBlock first_block = new EFSExpressionBlock(ctx.expression(0));
76 | compiler.appendInstruction(first_block.compile());
77 |
78 | // Basic mathematical operations
79 | if (isAdd)
80 | compiler.appendInstruction(TiToken.ADD);
81 | if (isSub)
82 | compiler.appendInstruction(TiToken.SUBTRACT);
83 | if (isMul)
84 | compiler.appendInstruction(TiToken.MULTIPLY);
85 | if (isDiv)
86 | compiler.appendInstruction(TiToken.DIVIDE);
87 |
88 | // The second expression block
89 | EFSExpressionBlock second_block = new EFSExpressionBlock(ctx.expression(1));
90 | compiler.appendInstruction(second_block.compile());
91 | }
92 |
93 | }
94 | }
95 | }
96 |
97 | return compiler.getTokens();
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSAddAssignBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.Add_assign_stmtContext;
4 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
5 | import com.efscript.antlr.EFScriptParser.ValueContext;
6 | import com.efscript.script.Context;
7 | import com.efscript.script.blocks.EFSStatementBlock;
8 | import com.efscript.script.blocks.EFSValueBlock;
9 | import com.efscript.ti.TiCompiler;
10 | import com.efscript.ti.TiToken;
11 |
12 | public class EFSAddAssignBlock extends EFSStatementBlock {
13 | public EFSAddAssignBlock(Add_assign_stmtContext ctx) {
14 | super(ctx);
15 | }
16 |
17 | @Override
18 | public TiToken[] compile() throws Exception {
19 | TiCompiler comp = new TiCompiler();
20 | Add_assign_stmtContext ctx = this.getCtx();
21 |
22 | IdentifierContext iCtx = ctx.identifier();
23 | ValueContext vCtx = ctx.value();
24 |
25 | TiToken[] accessor = Context.currentContext().genAccessor(iCtx.getText());
26 | EFSValueBlock vBlock = new EFSValueBlock(vCtx);
27 |
28 | // L(X)+VALUE->L(X)
29 | comp.appendInstruction(accessor);
30 | comp.appendInstruction(TiToken.ADD);
31 | comp.appendInstruction(vBlock.compile());
32 | comp.appendInstruction(TiToken.STORE);
33 | comp.appendInstruction(accessor);
34 | comp.appendInstruction(TiToken.NEWLINE);
35 |
36 | return comp.getTokens();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSAssignBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.Assign_stmtContext;
4 | import com.efscript.antlr.EFScriptParser.ExpressionContext;
5 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
6 | import com.efscript.script.Context;
7 | import com.efscript.script.blocks.EFSStatementBlock;
8 | import com.efscript.script.blocks.expressions.EFSExpressionBlock;
9 | import com.efscript.ti.TiCompiler;
10 | import com.efscript.ti.TiToken;
11 |
12 | public class EFSAssignBlock extends EFSStatementBlock {
13 |
14 | public EFSAssignBlock(Assign_stmtContext ctx) {
15 | super(ctx);
16 | }
17 |
18 | @Override
19 | public TiToken[] compile() throws Exception {
20 | // Initialize TiCompiler
21 | TiCompiler minComp = new TiCompiler();
22 |
23 | /*
24 | * Generated output should be: ->L1(X)
25 | */
26 |
27 | // Get context
28 | Assign_stmtContext aCtx = this.getCtx();
29 | // Expression to evaluate & store
30 | ExpressionContext eCtx = aCtx.expression();
31 | // Create an expression block instance
32 | EFSExpressionBlock exprBlock = new EFSExpressionBlock(eCtx);
33 | // Compile it
34 | minComp.appendInstruction(exprBlock.compile());
35 | // Store token
36 | minComp.appendInstruction(TiToken.STORE);
37 | // Get the identifier
38 | IdentifierContext iCtx = aCtx.identifier();
39 | // Get the var accessor to store the expression into
40 | TiToken[] accessor = Context.currentContext().genAccessor(iCtx.getText());
41 | // Compile the accessor
42 | minComp.appendInstruction(accessor);
43 | // Return the result
44 | return minComp.getTokens();
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSBracketBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import java.util.List;
4 |
5 | import com.efscript.antlr.EFScriptParser.StatementContext;
6 | import com.efscript.script.blocks.EFSStatementBlock;
7 | import com.efscript.ti.TiCompiler;
8 | import com.efscript.ti.TiToken;
9 |
10 | public class EFSBracketBlock extends EFSStatementBlock {
11 |
12 | public EFSBracketBlock(StatementContext ctx) {
13 | super(ctx);
14 | }
15 |
16 | @Override
17 | public TiToken[] compile() throws Exception {
18 | TiCompiler comp = new TiCompiler();
19 |
20 | StatementContext ctx = this.getCtx();
21 | List stmts = ctx.statement();
22 | for(StatementContext sCtx : stmts) {
23 | EFSStatementBlock> sBlock = EFSStatementBlock.getAppropriate(sCtx);
24 | comp.appendInstruction(sBlock.compile());
25 | }
26 |
27 | return comp.getTokens();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSDecBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.Dec_stmtContext;
4 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
5 | import com.efscript.script.Context;
6 | import com.efscript.script.blocks.EFSStatementBlock;
7 | import com.efscript.ti.TiCompiler;
8 | import com.efscript.ti.TiToken;
9 |
10 | public class EFSDecBlock extends EFSStatementBlock {
11 |
12 | public EFSDecBlock(Dec_stmtContext ctx) {
13 | super(ctx);
14 | }
15 |
16 | @Override
17 | public TiToken[] compile() throws Exception {
18 | TiCompiler miniTiComp = new TiCompiler();
19 | // Get the context
20 | Dec_stmtContext decCtx = this.getCtx();
21 | // Get the identifier
22 | IdentifierContext iCtx = decCtx.identifier();
23 | // The identifier must be a var, and we can assume this.
24 | TiToken[] accessor = Context.currentContext().genAccessor(iCtx.getText());
25 |
26 | /*
27 | * Should compile to: L1(X)-1->L1(X)
28 | */
29 | // Append the accessor
30 | miniTiComp.appendInstruction(accessor);
31 | // Subtract token
32 | miniTiComp.appendInstruction(TiToken.SUBTRACT);
33 | // Num 1
34 | miniTiComp.appendInstruction(TiToken.NUM_1);
35 | // Store token (->)
36 | miniTiComp.appendInstruction(TiToken.STORE);
37 | // The accessor
38 | miniTiComp.appendInstruction(accessor);
39 | return miniTiComp.getTokens();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSDivAssignBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.Div_assign_stmtContext;
4 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
5 | import com.efscript.antlr.EFScriptParser.ValueContext;
6 | import com.efscript.script.Context;
7 | import com.efscript.script.blocks.EFSStatementBlock;
8 | import com.efscript.script.blocks.EFSValueBlock;
9 | import com.efscript.ti.TiCompiler;
10 | import com.efscript.ti.TiToken;
11 |
12 | public class EFSDivAssignBlock extends EFSStatementBlock {
13 |
14 | public EFSDivAssignBlock(Div_assign_stmtContext ctx) {
15 | super(ctx);
16 | }
17 |
18 | @Override
19 | public TiToken[] compile() throws Exception {
20 | TiCompiler comp = new TiCompiler();
21 | Div_assign_stmtContext ctx = this.getCtx();
22 |
23 | IdentifierContext iCtx = ctx.identifier();
24 | ValueContext vCtx = ctx.value();
25 |
26 | TiToken[] accessor = Context.currentContext().genAccessor(iCtx.getText());
27 | EFSValueBlock vBlock = new EFSValueBlock(vCtx);
28 |
29 | // L(X)/VALUE->L(X)
30 | comp.appendInstruction(accessor);
31 | comp.appendInstruction(TiToken.DIVIDE);
32 | comp.appendInstruction(vBlock.compile());
33 | comp.appendInstruction(TiToken.STORE);
34 | comp.appendInstruction(accessor);
35 | comp.appendInstruction(TiToken.NEWLINE);
36 |
37 | return comp.getTokens();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSIfBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.BoolexprContext;
4 | import com.efscript.antlr.EFScriptParser.If_stmtContext;
5 | import com.efscript.antlr.EFScriptParser.StatementContext;
6 | import com.efscript.script.blocks.EFSStatementBlock;
7 | import com.efscript.script.blocks.expressions.EFSBoolexprBlock;
8 | import com.efscript.ti.TiCompiler;
9 | import com.efscript.ti.TiToken;
10 |
11 | public class EFSIfBlock extends EFSStatementBlock {
12 | public EFSIfBlock(If_stmtContext ctx)
13 | {
14 | super(ctx);
15 | }
16 |
17 | @Override
18 | public TiToken[] compile() throws Exception {
19 | TiCompiler comp = new TiCompiler();
20 |
21 | If_stmtContext ctx = this.getCtx();
22 |
23 | comp.appendInstruction(TiToken.IF);
24 | BoolexprContext bctx = ctx.boolexpr();
25 | EFSBoolexprBlock bBlock = new EFSBoolexprBlock(bctx);
26 | comp.appendInstruction(bBlock.compile());
27 | comp.appendInstruction(TiToken.NEWLINE);
28 | comp.appendInstruction(TiToken.THEN);
29 | comp.appendInstruction(TiToken.NEWLINE);
30 |
31 | StatementContext sCtx = ctx.statement();
32 | EFSStatementBlock> sBlock = EFSStatementBlock.getAppropriate(sCtx);
33 | comp.appendInstruction(sBlock.compile());
34 |
35 | comp.appendInstruction(TiToken.END);
36 | comp.appendInstruction(TiToken.NEWLINE);
37 |
38 | return comp.getTokens();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSIncBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
4 | import com.efscript.antlr.EFScriptParser.Inc_stmtContext;
5 | import com.efscript.script.Context;
6 | import com.efscript.script.blocks.EFSStatementBlock;
7 | import com.efscript.ti.TiCompiler;
8 | import com.efscript.ti.TiToken;
9 |
10 | public class EFSIncBlock extends EFSStatementBlock {
11 |
12 | public EFSIncBlock(Inc_stmtContext ctx) {
13 | super(ctx);
14 | }
15 |
16 | @Override
17 | public TiToken[] compile() throws Exception {
18 | TiCompiler miniTiComp = new TiCompiler();
19 | // Get the context
20 | Inc_stmtContext incCtx = this.getCtx();
21 | // Get the identifier
22 | IdentifierContext iCtx = incCtx.identifier();
23 | // The identifier must be a var, and we can assume this.
24 | TiToken[] accessor = Context.currentContext().genAccessor(iCtx.getText());
25 |
26 | /*
27 | * Should compile to: L1(X)+1->L1(X)
28 | */
29 | // Append the accessor
30 | miniTiComp.appendInstruction(accessor);
31 | // Add token
32 | miniTiComp.appendInstruction(TiToken.ADD);
33 | // Num 1
34 | miniTiComp.appendInstruction(TiToken.NUM_1);
35 | // Store token (->)
36 | miniTiComp.appendInstruction(TiToken.STORE);
37 | // The accessor
38 | miniTiComp.appendInstruction(accessor);
39 | return miniTiComp.getTokens();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSMulAssignBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
4 | import com.efscript.antlr.EFScriptParser.Mul_assign_stmtContext;
5 | import com.efscript.antlr.EFScriptParser.ValueContext;
6 | import com.efscript.script.Context;
7 | import com.efscript.script.blocks.EFSStatementBlock;
8 | import com.efscript.script.blocks.EFSValueBlock;
9 | import com.efscript.ti.TiCompiler;
10 | import com.efscript.ti.TiToken;
11 |
12 | public class EFSMulAssignBlock extends EFSStatementBlock {
13 |
14 | public EFSMulAssignBlock(Mul_assign_stmtContext ctx) {
15 | super(ctx);
16 | }
17 |
18 | @Override
19 | public TiToken[] compile() throws Exception {
20 | TiCompiler comp = new TiCompiler();
21 | Mul_assign_stmtContext ctx = this.getCtx();
22 |
23 | IdentifierContext iCtx = ctx.identifier();
24 | ValueContext vCtx = ctx.value();
25 |
26 | TiToken[] accessor = Context.currentContext().genAccessor(iCtx.getText());
27 | EFSValueBlock vBlock = new EFSValueBlock(vCtx);
28 |
29 | // L(X)*VALUE->L(X)
30 | comp.appendInstruction(accessor);
31 | comp.appendInstruction(TiToken.MULTIPLY);
32 | comp.appendInstruction(vBlock.compile());
33 | comp.appendInstruction(TiToken.STORE);
34 | comp.appendInstruction(accessor);
35 | comp.appendInstruction(TiToken.NEWLINE);
36 |
37 | return comp.getTokens();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSReturnBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.ExpressionContext;
4 | import com.efscript.antlr.EFScriptParser.Return_stmtContext;
5 | import com.efscript.script.blocks.EFSStatementBlock;
6 | import com.efscript.script.blocks.expressions.EFSExpressionBlock;
7 | import com.efscript.ti.TiCompiler;
8 | import com.efscript.ti.TiToken;
9 |
10 | public class EFSReturnBlock extends EFSStatementBlock {
11 |
12 | public EFSReturnBlock(Return_stmtContext ctx) {
13 | super(ctx);
14 | }
15 |
16 | @Override
17 | public TiToken[] compile() throws Exception {
18 | TiCompiler miniComp = new TiCompiler();
19 | Return_stmtContext ctx = this.getCtx();
20 |
21 | ExpressionContext expr = ctx.expression();
22 | if(expr != null) {
23 | EFSExpressionBlock expBlock = new EFSExpressionBlock(expr);
24 | TiToken[] exprComp = expBlock.compile();
25 |
26 | miniComp.appendInstruction(exprComp);
27 | }
28 | else {
29 | miniComp.appendInstruction(TiToken.NUM_0); //No return value = return 0;
30 | }
31 | miniComp.appendInstruction(TiToken.STORE);
32 | miniComp.appendInstruction(TiToken.LETTER_C); //The return register ('C')
33 | miniComp.appendInstruction(TiToken.NEWLINE);
34 |
35 | return miniComp.getTokens();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSSubAssignBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
4 | import com.efscript.antlr.EFScriptParser.Sub_assign_stmtContext;
5 | import com.efscript.antlr.EFScriptParser.ValueContext;
6 | import com.efscript.script.Context;
7 | import com.efscript.script.blocks.EFSStatementBlock;
8 | import com.efscript.script.blocks.EFSValueBlock;
9 | import com.efscript.ti.TiCompiler;
10 | import com.efscript.ti.TiToken;
11 |
12 | public class EFSSubAssignBlock extends EFSStatementBlock {
13 | public EFSSubAssignBlock(Sub_assign_stmtContext ctx) {
14 | super(ctx);
15 | }
16 |
17 | @Override
18 | public TiToken[] compile() throws Exception {
19 | TiCompiler comp = new TiCompiler();
20 | Sub_assign_stmtContext ctx = this.getCtx();
21 |
22 | IdentifierContext iCtx = ctx.identifier();
23 | ValueContext vCtx = ctx.value();
24 |
25 | TiToken[] accessor = Context.currentContext().genAccessor(iCtx.getText());
26 | EFSValueBlock vBlock = new EFSValueBlock(vCtx);
27 |
28 | // L(X)-VALUE->L(X)
29 | comp.appendInstruction(accessor);
30 | comp.appendInstruction(TiToken.SUBTRACT);
31 | comp.appendInstruction(vBlock.compile());
32 | comp.appendInstruction(TiToken.STORE);
33 | comp.appendInstruction(accessor);
34 | comp.appendInstruction(TiToken.NEWLINE);
35 |
36 | return comp.getTokens();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSTiBasicBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.Logger;
4 | import com.efscript.antlr.EFScriptParser;
5 | import com.efscript.script.blocks.EFSStatementBlock;
6 | import com.efscript.ti.TiCompiler;
7 | import com.efscript.ti.TiPreProcessor;
8 | import com.efscript.ti.TiToken;
9 |
10 | public class EFSTiBasicBlock extends EFSStatementBlock {
11 |
12 | public EFSTiBasicBlock(EFScriptParser.Ti_basic_stmtContext ctx) {
13 | super(ctx);
14 | }
15 |
16 | @Override
17 | public TiToken[] compile() throws Exception {
18 | String stmtCode = this.getCtx().any().getText();
19 | TiPreProcessor preProcessor = new TiPreProcessor(stmtCode);
20 | String processed = preProcessor.process();
21 | TiCompiler compiler = new TiCompiler(processed);
22 | return compiler.getTokens();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSVarBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.ExpressionContext;
4 | import com.efscript.antlr.EFScriptParser.IdentifierContext;
5 | import com.efscript.antlr.EFScriptParser.Var_stmtContext;
6 | import com.efscript.script.Context;
7 | import com.efscript.script.blocks.EFSStatementBlock;
8 | import com.efscript.script.blocks.expressions.EFSExpressionBlock;
9 | import com.efscript.ti.TiCompiler;
10 | import com.efscript.ti.TiToken;
11 |
12 | public class EFSVarBlock extends EFSStatementBlock {
13 | public EFSVarBlock(Var_stmtContext ctx) {
14 | super(ctx);
15 | }
16 |
17 | @Override
18 | public TiToken[] compile() throws Exception {
19 | // TiCompiler to get de tokens
20 | TiCompiler comp = new TiCompiler();
21 |
22 | // Get the identifier text
23 | IdentifierContext iCtx = this.getCtx().identifier();
24 | String varStr = iCtx.getText();
25 | // Add the var for later reference
26 | Context.currentContext().addIdentifier(varStr);
27 | TiToken[] accessor = Context.currentContext().genAccessor(iCtx.getText());
28 |
29 | // Process the initial value
30 | ExpressionContext exprCtx = this.getCtx().expression();
31 | EFSExpressionBlock exprBlock = new EFSExpressionBlock(exprCtx);
32 |
33 | // Generate the storage code
34 | comp.appendInstruction(exprBlock.compile());
35 | comp.appendInstruction(TiToken.STORE);
36 | comp.appendInstruction(accessor);
37 | comp.appendInstruction(TiToken.NEWLINE);
38 |
39 | return comp.getTokens();
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/script/blocks/statements/EFSWhileBlock.java:
--------------------------------------------------------------------------------
1 | package com.efscript.script.blocks.statements;
2 |
3 | import com.efscript.antlr.EFScriptParser.While_stmtContext;
4 | import com.efscript.script.blocks.EFSStatementBlock;
5 | import com.efscript.ti.TiToken;
6 |
7 | public class EFSWhileBlock extends EFSStatementBlock {
8 |
9 | public EFSWhileBlock(While_stmtContext ctx) {
10 | super(ctx);
11 | }
12 |
13 | @Override
14 | public TiToken[] compile() {
15 | return null;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/ti/ByteArray.java:
--------------------------------------------------------------------------------
1 | package com.efscript.ti;
2 |
3 | import java.util.ArrayList;
4 | import java.nio.ByteBuffer;
5 | import java.nio.charset.StandardCharsets;
6 | import java.nio.charset.Charset;
7 |
8 | public class ByteArray extends ArrayList {
9 | public Byte[] toArray() {
10 | return this.toArray();
11 | }
12 | public byte[] toPrimitiveArray() {
13 | byte[] arr = new byte[this.size()];
14 | for(int i = 0; i < this.size(); i++) {
15 | arr[i] = this.get(i);
16 | }
17 | return arr;
18 | }
19 |
20 | public void add(byte[] bytes) {
21 | for(byte b : bytes) {
22 | this.addByte(b);
23 | }
24 | }
25 |
26 | public void addByte(byte value) {
27 | super.add(value);
28 | }
29 | public void add(short value) {
30 | ByteBuffer buffer = ByteBuffer.allocate(2);
31 | buffer.putShort(value);
32 | byte[] bytes = new byte[2];
33 | //Swap the edianess
34 | bytes[1] = buffer.array()[0];
35 | bytes[0] = buffer.array()[1];
36 | this.add(bytes);
37 | }
38 |
39 | public void add(String text) {
40 | this.add(text, StandardCharsets.US_ASCII, text.length());
41 | }
42 | public void add(String text, int expectedLength) {
43 | //expectedLength--; //Cuz shit starts at 0 and whatever
44 | this.add(text, StandardCharsets.US_ASCII, expectedLength);
45 | }
46 | public void add(String text, Charset charSet, int expectedLength) {
47 | byte[] newArr = new byte[expectedLength];
48 | byte[] textBytes = text.getBytes(charSet);
49 | for(int i = 0; i < expectedLength; i++) {
50 | if(i >= textBytes.length) {
51 | newArr[i] = 0x0;
52 | continue;
53 | }
54 | newArr[i] = textBytes[i];
55 | }
56 | this.add(newArr);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/ti/TiCompiler.java:
--------------------------------------------------------------------------------
1 | package com.efscript.ti;
2 |
3 | import java.util.ArrayList;
4 |
5 | import com.efscript.Logger;
6 | import com.efscript.antlr.TiBasicBaseListener;
7 | import com.efscript.antlr.TiBasicLexer;
8 | import com.efscript.antlr.TiBasicParser;
9 | import org.antlr.v4.runtime.CharStreams;
10 | import org.antlr.v4.runtime.CommonTokenStream;
11 | import org.antlr.v4.runtime.tree.ParseTreeWalker;
12 |
13 | public class TiCompiler extends TiBasicBaseListener {
14 | // List for tokens
15 | ArrayList tokens;
16 |
17 | public TiCompiler() {
18 | tokens = new ArrayList<>();
19 | }
20 |
21 | public TiCompiler(String code) {
22 | this();
23 | Logger.Log("Reading Ti-Basic code...");
24 |
25 | TiBasicLexer lexer = new TiBasicLexer(CharStreams.fromString(code));
26 | TiBasicParser parser = new TiBasicParser(new CommonTokenStream(lexer));
27 |
28 | TiBasicParser.ScriptContext script = parser.script();
29 |
30 | ParseTreeWalker walker = new ParseTreeWalker();
31 | walker.walk(this, script);
32 | }
33 |
34 | // Append a collection of tokens
35 | public TiCompiler appendInstruction(TiToken[] tokens) {
36 | for (TiToken token : tokens) {
37 | appendInstruction(token);
38 | }
39 | return this;
40 | }
41 |
42 | // Append a single token
43 | public TiCompiler appendInstruction(TiToken token) {
44 | tokens.add(token);
45 | return this;
46 | }
47 |
48 | // Get the tokens (not compiled)
49 | public TiToken[] getTokens() {
50 | TiToken[] ret = new TiToken[tokens.size()];
51 | for (int i = 0; i < ret.length; i++) {
52 | ret[i] = tokens.get(i);
53 | }
54 | return ret;
55 | }
56 |
57 | // Compile tokens to bytecode
58 | public byte[] compile() {
59 | Logger.Log("Compiling tokens...");
60 | // Calculate the size
61 | int size = 0;
62 | for (TiToken token : tokens) {
63 | size += token.length;
64 | }
65 | // Allocate a byte array of size
66 | byte[] compiled = new byte[size];
67 | // Compensate for jumped bytes
68 | int jumped = 0;
69 | // Loop through
70 | for (int i = 0; i < compiled.length; i++) {
71 | // Get the current token
72 | TiToken current = tokens.get(i - jumped);
73 | // Set the first byte
74 | compiled[i] = current.hex_high;
75 | // Check for a second byte
76 | if (current.length > 1) {
77 | // Set the second byte
78 | i++;
79 | jumped++;
80 | compiled[i] = current.hex_low;
81 | }
82 | }
83 | // Done
84 | Logger.Log("Tokens compiled");
85 | return compiled;
86 | }
87 |
88 | public String toString() {
89 | StringBuilder build = new StringBuilder();
90 | for(TiToken token : tokens) {
91 | build.append(token.str);
92 | }
93 | return build.toString();
94 | }
95 |
96 | @Override
97 | public void enterToken(TiBasicParser.TokenContext ctx) {
98 | if(ctx.list() != null) {
99 | parseList(ctx.list());
100 | return;
101 | }
102 | String text = ctx.getText();
103 | if(text.equals(";")) {
104 | appendInstruction(TiToken.NEWLINE);
105 | return;
106 | }
107 | TiToken token = TiToken.getToken(text);
108 | appendInstruction(token);
109 | }
110 |
111 | public void parseList(TiBasicParser.ListContext ctx) {
112 | try {
113 | TiToken token = TiToken.getList(Integer.parseInt(ctx.number().getText()));
114 | appendInstruction(token);
115 | } catch (Exception ex) {
116 | ex.printStackTrace();
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/ti/TiDecompiler.java:
--------------------------------------------------------------------------------
1 | package com.efscript.ti;
2 |
3 | import com.efscript.Logger;
4 |
5 | import java.util.ArrayList;
6 |
7 | public class TiDecompiler {
8 | // Bytes for the bytecode
9 | byte[] code;
10 |
11 | // DEPRECATED Decompile a TiFile
12 | //Cant be done with new TiFile format
13 | /*
14 | public TiDecompiler(TiFile source) {
15 | this(source.getProgramCode());
16 | }
17 | */
18 |
19 | // Decompile bytecode directly
20 | public TiDecompiler(byte[] code) {
21 | this.code = code;
22 | Logger.Log("Initialized new TiDecompiler");
23 | }
24 |
25 | // Decompile the bytecode to a TiToken array
26 | public TiToken[] decompile() {
27 | Logger.Log("Decompiling tokens...");
28 | ArrayList tokens = new ArrayList<>();
29 | // loop through bytes
30 | for (int i = 0; i < code.length; i++) {
31 | TiToken token;
32 | // check if the byte requires a 2nd byte
33 | if (TiToken.isLong(code[i])) {
34 | // Get the 2 bytes
35 | byte high = code[i];
36 | i++;
37 | byte low = code[i];
38 | // Find the token
39 | token = TiToken.getToken(high, low);
40 | } else {
41 | // Otherwise it only needs 1
42 | // Get the token
43 | token = TiToken.getToken(code[i]);
44 | }
45 | // Return the decompiled code
46 | tokens.add(token);
47 | }
48 | Logger.Log("Decompiled tokens");
49 |
50 | TiToken[] arr = new TiToken[tokens.size()];
51 | for(int i = 0; i < arr.length; i++) {
52 | arr[i] = tokens.get(i);
53 | }
54 | return arr;
55 | }
56 | // Decompile the bytecode to a String
57 | public String getCode() {
58 | TiToken[] tokens = this.decompile();
59 | StringBuilder build = new StringBuilder();
60 | for(TiToken token : tokens) {
61 | build.append(token.str);
62 | }
63 | return build.toString();
64 | }
65 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/ti/TiFile.java:
--------------------------------------------------------------------------------
1 | package com.efscript.ti;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.DataOutputStream;
5 | import java.io.FileInputStream;
6 | import java.io.IOException;
7 | import java.nio.ByteBuffer;
8 | import java.nio.charset.Charset;
9 | import java.nio.charset.StandardCharsets;
10 | import java.util.ArrayList;
11 |
12 | import com.efscript.Logger;
13 | import com.efscript.ti.VariableEntry;
14 | import com.efscript.ti.VariableData;
15 |
16 | public class TiFile {
17 |
18 | byte[] fileSignature = {'*', '*', 'T', 'I', '8', '3', 'F', '*', 0x1A, 0xA, 0xA};
19 | String comment = "Compiled with DisabledMallis/84Script";
20 | short dataLength = 0;
21 | VariableEntry[] dataSection = {};
22 | short checksum = 0;
23 |
24 | public TiFile() {
25 | dataLength = -0x39;
26 | dataLength += fileSignature.length;
27 | dataLength += comment.length();
28 | dataLength += 2; //Include itself in the filesize
29 |
30 | dataSection = new VariableEntry[0];
31 | }
32 | public TiFile(String name, TiToken[] tokens) {
33 | this();
34 | VariableData data = new VariableData(tokens);
35 | VariableEntry entry = new VariableEntry(name, data);
36 | this.pushVariableEntry(entry);
37 | }
38 |
39 | public void pushVariableEntry(VariableEntry newEntry) {
40 | VariableEntry[] entries = new VariableEntry[dataSection.length+1];
41 | for(int i = 0; i < dataSection.length; i++) {
42 | dataLength += dataSection[i].pack().length;
43 | entries[i] = dataSection[i];
44 | }
45 | entries[entries.length-1] = newEntry;
46 | dataSection = entries;
47 | }
48 |
49 | public byte[] pack() {
50 | ByteArray array = new ByteArray();
51 | array.add(this.fileSignature);
52 | array.add(this.comment, 42);
53 | array.add(dataLength);
54 |
55 | ByteArray varEntryArray = new ByteArray();
56 | for(VariableEntry entry : dataSection) {
57 | varEntryArray.add(entry.pack());
58 | }
59 | long l_checksum = 0;//0x100;
60 | for(byte b : varEntryArray.toPrimitiveArray()){
61 | //System.out.println("Adding "+(b&0xFF));
62 | l_checksum += (b&0xFF);
63 | }
64 | short checksum = (short)(l_checksum);
65 |
66 | array.add(varEntryArray.toPrimitiveArray());
67 | array.add(checksum);
68 |
69 | //We need to adjust the size, my previous size calculations are wrong.
70 | byte[] preFinal = array.toPrimitiveArray();
71 | short fullSize = (short)preFinal.length;
72 | fullSize -= 0x39; //The docs said to do this, dont ask me
73 | ByteArray converter = new ByteArray();
74 | converter.add(fullSize);
75 | preFinal[0x35] = converter.toPrimitiveArray()[0];
76 | preFinal[0x36] = converter.toPrimitiveArray()[1];
77 |
78 | return preFinal;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/ti/TiPreProcessor.java:
--------------------------------------------------------------------------------
1 | package com.efscript.ti;
2 |
3 | import com.efscript.script.Context;
4 |
5 | //This class is to pre process inline Ti-Basic code
6 | public class TiPreProcessor {
7 | private Context currentContext;
8 | private final String code;
9 | public TiPreProcessor(String code) {
10 | this.code = code;
11 | setContext(Context.currentContext());
12 | }
13 |
14 | public void setContext(Context currentContext) {
15 | this.currentContext = currentContext;
16 | }
17 |
18 | public String process() throws Exception {
19 | String processed = code;
20 | for(String var : currentContext.getIdentifiers()) {
21 | TiCompiler comp = new TiCompiler();
22 | comp.appendInstruction(currentContext.genAccessor(var));
23 | processed = processed.replaceAll(var.toString(), comp.toString());
24 | }
25 | return processed;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/ti/TiToken.java:
--------------------------------------------------------------------------------
1 | package com.efscript.ti;
2 |
3 | import com.efscript.Logger;
4 |
5 | import java.lang.Integer;
6 | import java.util.ArrayList;
7 |
8 | public enum TiToken {
9 | TO_DMS(0x1, "TO_DMS"),
10 | TO_DEC(0x2, ">DEC"),
11 | TO_FRAC(0x3, ">FRAC"),
12 | STORE(0x4, "->"),
13 | BOXPLOT(0x5, "BOXPLOT"),
14 | OPEN_SQUARE_BRACKET(0x6, "["),
15 | CLOSE_SQUARE_BRACKET(0x7, "]"),
16 | OPEN_CURLEY_BRACKET(0x8, "{"),
17 | CLOSE_CURLEY_BRACKET(0x9, "}"),
18 | OPEN_BRACKET(0x10, "("),
19 | CLOSE_BRACKET(0x11, ")"),
20 | BLANK(0x29, " "),
21 | QUOTE(0x2A, "\""),
22 | COMMA(0x2B, ","),
23 | EXCLAMATION_MARK(0x2D, "!"),
24 | NUM_0(0x30, "0"),
25 | NUM_1(0x31, "1"),
26 | NUM_2(0x32, "2"),
27 | NUM_3(0x33, "3"),
28 | NUM_4(0x34, "4"),
29 | NUM_5(0x35, "5"),
30 | NUM_6(0x36, "6"),
31 | NUM_7(0x37, "7"),
32 | NUM_8(0x38, "8"),
33 | NUM_9(0x39, "9"),
34 | PERIOD(0x3A, "."),
35 | OR(0x3A, "OR"),
36 | XOR(0x3D, "XOR"),
37 | COLON(0x3E, ":"),
38 | NEWLINE(0x3F, "\n"),
39 | LETTER_A(0x41, "A"),
40 | LETTER_B(0x42, "B"),
41 | LETTER_C(0x43, "C"),
42 | LETTER_D(0x44, "D"),
43 | LETTER_E(0x45, "E"),
44 | LETTER_F(0x46, "F"),
45 | LETTER_G(0x47, "G"),
46 | LETTER_H(0x48, "H"),
47 | LETTER_I(0x49, "I"),
48 | LETTER_J(0x4A, "J"),
49 | LETTER_K(0x4B, "K"),
50 | LETTER_L(0x4C, "L"),
51 | LETTER_M(0x4D, "M"),
52 | LETTER_N(0x4E, "N"),
53 | LETTER_O(0x4F, "O"),
54 | LETTER_P(0x50, "P"),
55 | LETTER_Q(0x51, "Q"),
56 | LETTER_R(0x52, "R"),
57 | LETTER_S(0x53, "S"),
58 | LETTER_T(0x54, "T"),
59 | LETTER_U(0x55, "U"),
60 | LETTER_V(0x56, "V"),
61 | LETTER_W(0x57, "W"),
62 | LETTER_X(0x58, "X"),
63 | LETTER_Y(0x59, "Y"),
64 | LETTER_Z(0x5A, "Z"),
65 | MATRIX_A(0x5C, 0x0, "[A]"),
66 | MATRIX_B(0x5C, 0x1, "[B]"),
67 | MATRIX_C(0x5C, 0x2, "[C]"),
68 | MATRIX_D(0x5C, 0x3, "[D]"),
69 | MATRIX_E(0x5C, 0x4, "[E]"),
70 | MATRIX_F(0x5C, 0x5, "[F]"),
71 | MATRIX_G(0x5C, 0x6, "[G]"),
72 | MATRIX_H(0x5C, 0x7, "[H]"),
73 | MATRIX_I(0x5C, 0x8, "[I]"),
74 | MATRIX_J(0x5C, 0x9, "[J]"),
75 | LIST1(0x5D, 0x0, "LIST1"),
76 | LIST2(0x5D, 0x1, "LIST2"),
77 | LIST3(0x5D, 0x2, "LIST3"),
78 | LIST4(0x5D, 0x3, "LIST4"),
79 | LIST5(0x5D, 0x4, "LIST5"),
80 | LIST6(0x5D, 0x5, "LIST6"),
81 | PRGM(0x5F, "prgm"),
82 | EQUALS(0x6A, "="),
83 | LESS_THAN(0x6B, "<"),
84 | GREATER_THAN(0x6C, ">"),
85 | LESS_THAN_OR_EQUAL(0x6D, "<="),
86 | GREATER_THAN_OR_EQUAL(0x6E, ">="),
87 | NOT_EQUAL(0x6F, "!="),
88 | ADD(0x70, "+"),
89 | SUBTRACT(0x71, "-"),
90 | MULTIPLY(0x82, "*"),
91 | DIVIDE(0x83, "/"),
92 | CONST_PI(0xAC, "pi"),
93 | NEGATE(0xB0, "-"),
94 | CONST_E(0xBB, 0x31, "e"),
95 | AND(0xBB, 0xD4, "&"),
96 | IF(0xCE, "IF"),
97 | THEN(0xCF, "THEN"),
98 | END(0xD4, "END"),
99 | INPUT(0xDC, "INPUT"),
100 | DISP(0xDE, "DISP"),
101 | CLR_LIST(0xFA, "CLR_LIST");
102 |
103 | public byte length;
104 | public byte hex_high;
105 | public byte hex_low;
106 | public String str;
107 |
108 | // 1 byte tokens
109 | TiToken(int hex, String strRep) {
110 | this(hex, 0, strRep);
111 | this.length = 1;
112 | };
113 |
114 | // 2 byte tokens
115 | TiToken(int hex_high, int hex_low, String strRep) {
116 | this((byte) hex_high, (byte) hex_low, strRep);
117 | };
118 |
119 | // 2 byte tokens
120 | TiToken(byte hex_high, byte hex_low, String strRep) {
121 | this.hex_high = hex_high;
122 | this.hex_low = hex_low;
123 | this.length = 2;
124 | this.str = strRep;
125 | };
126 |
127 | // Get the first byte
128 | byte getHighByte() {
129 | return this.hex_high;
130 | };
131 |
132 | byte getLowByte() {
133 | return this.hex_low;
134 | };
135 |
136 | // Check if a byte needs a second
137 | public static boolean isLong(byte b) {
138 | TiToken[] allTokens = values();
139 | for (TiToken tokes : allTokens) {
140 | if (tokes.hex_high == b) {
141 | return tokes.length > 1;
142 | }
143 | }
144 | return false;
145 | }
146 |
147 | // Get a token by its *enum* name
148 | public static TiToken getTokenByName(String token) throws Exception {
149 | for (TiToken t : TiToken.values()) {
150 | if (t.toString().equals(token)) {
151 | return t;
152 | }
153 | }
154 | throw new Exception("Token not found \""+token+"\"");
155 | };
156 |
157 | public static TiToken getList(int id) throws Exception {
158 | return getTokenByName("LIST"+id);
159 | }
160 |
161 | // Get a token by its *string* representation
162 | public static TiToken getToken(String token) {
163 | for (TiToken t : TiToken.values()) {
164 | if (t.str.equals(token)) {
165 | return t;
166 | }
167 | }
168 | return null;
169 | };
170 |
171 | // Get a single byte token
172 | public static TiToken getToken(byte token) {
173 | byte[] arr = new byte[2];
174 | arr[0] = token;
175 | arr[1] = 0;
176 | return getToken(arr);
177 | };
178 |
179 | // Get a 2 byte token
180 | public static TiToken getToken(byte hex_high, byte hex_low) {
181 | byte[] arr = new byte[2];
182 | arr[0] = hex_high;
183 | arr[1] = hex_low;
184 | return getToken(arr);
185 | }
186 |
187 | // Get a token by its byte(s)
188 | public static TiToken getToken(byte[] token) {
189 | for (TiToken t : TiToken.values()) {
190 | if (t.hex_high == token[0] && t.hex_low == token[1]) {
191 | return t;
192 | }
193 | }
194 | return null;
195 | };
196 |
197 | //WARNING: Ascii only!!!
198 | public static TiToken[] convertText(String text) {
199 | ArrayList tokens = new ArrayList<>();
200 |
201 | //Loop the ASCII characters for the respective token
202 | for(char c : text.toCharArray()) {
203 | tokens.add(TiToken.getToken(""+c));
204 | }
205 |
206 | // Create a native array
207 | TiToken[] arr = new TiToken[tokens.size()];
208 | // Add tokens from the ArrayList to the returning array
209 | for (int i = 0; i < arr.length; i++) {
210 | arr[i] = tokens.get(i);
211 | }
212 | // Return the final array
213 | return arr;
214 | }
215 |
216 | // Generate tokens for a number (can be greater than 9)
217 | public static TiToken[] getNumber(int num) throws Exception {
218 | // If the num is more than 9, we gotta deal with that
219 | // Also if its less than 0, we cant do anything with that.
220 | // Only 0-9 we can actually get a token from
221 | if (num > 9 && num > -1) {
222 | // Create an arraylist, we need this for multiple tokens
223 | ArrayList tokens = new ArrayList<>();
224 | // Make the number into a string
225 | String numStr = "" + num;
226 | // Iterate the characters
227 | for (int i = 0; i < numStr.length(); i++) {
228 | // Get a single char num
229 | char c = numStr.charAt(i);
230 | // Parse it, and get the token for the single digit recursively
231 | TiToken[] tkns = getNumber(Integer.parseInt(c + ""));
232 | // Add the tokens to the arraylist
233 | for (TiToken tke : tkns) {
234 | tokens.add(tke);
235 | }
236 | }
237 | // Create a native array
238 | TiToken[] arr = new TiToken[tokens.size()];
239 | // Add tokens from the ArrayList to the returning array
240 | for (int i = 0; i < arr.length; i++) {
241 | arr[i] = tokens.get(i);
242 | }
243 | // Return the final array
244 | return arr;
245 | }
246 | // If its less than 10 & greater than 0, we can get a token
247 | if (num < 10 && num > -1) {
248 | // Create a token array to return the single num
249 | TiToken singleToken = TiToken.valueOf("NUM_" + num);
250 | if(singleToken == null) {
251 | throw new Exception("Cannot find single number \""+num+"\"?");
252 | }
253 | TiToken[] token = new TiToken[] { singleToken };
254 | // Return it
255 | return token;
256 | }
257 | if(num < 0)
258 | throw new Exception("Cannot convert numbers less than 0!");
259 | throw new Exception("Couldnt get number as token!");
260 | };
261 | }
262 |
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/ti/VariableData.java:
--------------------------------------------------------------------------------
1 | package com.efscript.ti;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.DataOutputStream;
5 | import java.io.FileInputStream;
6 | import java.io.IOException;
7 | import java.nio.ByteBuffer;
8 | import java.nio.charset.Charset;
9 | import java.nio.charset.StandardCharsets;
10 | import java.util.ArrayList;
11 |
12 | import com.efscript.ti.VariableEntry;
13 |
14 | public class VariableData {
15 | short dataSize = 0;
16 | byte[] data;
17 |
18 | public VariableData(TiToken[] tokens) {
19 | TiCompiler comp = new TiCompiler();
20 | comp.appendInstruction(tokens);
21 | this.dataSize = (short)comp.compile().length;
22 | this.data = comp.compile();
23 | }
24 |
25 | public byte[] pack() {
26 | ByteArray array = new ByteArray();
27 |
28 | array.add(dataSize);
29 | array.add(data);
30 |
31 | return array.toPrimitiveArray();
32 | }
33 | }
--------------------------------------------------------------------------------
/84Script/src/main/java/com/efscript/ti/VariableEntry.java:
--------------------------------------------------------------------------------
1 | package com.efscript.ti;
2 |
3 | import java.io.ByteArrayOutputStream;
4 | import java.io.DataOutputStream;
5 | import java.io.FileInputStream;
6 | import java.io.IOException;
7 | import java.nio.ByteBuffer;
8 | import java.nio.charset.Charset;
9 | import java.nio.charset.StandardCharsets;
10 | import java.util.ArrayList;
11 |
12 | import com.efscript.ti.VariableData;
13 |
14 | public class VariableEntry {
15 |
16 |
17 | byte[] offset_0 = {0xD,0x0};
18 | short varLength = 0x0;
19 | byte varType = 0x5;
20 | String name = "";
21 | byte version = 0x0;
22 | byte archived = 0x0;
23 | VariableData varData;
24 |
25 | public VariableEntry(String name, VariableData varData) {
26 | this.varLength = (short)varData.pack().length;
27 | this.name = name;
28 | this.varData = varData;
29 |
30 | }
31 |
32 | public byte[] pack() {
33 | ByteArray array = new ByteArray();
34 |
35 | array.add(offset_0);
36 | array.add(varLength);
37 | array.addByte(varType);
38 | array.add(name, 8);
39 | array.addByte(version);
40 | array.addByte(archived);
41 | array.add(varLength);
42 | array.add(varData.pack());
43 |
44 | return array.toPrimitiveArray();
45 | }
46 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 84Script
2 | A C-like programming language that compiles to TI-BASIC
3 |
4 | [Discord](https://discord.gg/rGyzCDaD6W)
5 |
6 | # Why
7 | Idk why not, seems like a neat hobby project
8 |
9 | # Roadmap
10 | Current progress of the project, shows what is currently done and what needs to be done.
11 |
12 | Key:
13 | ✅ - Completed
14 | 🔄 - In progress
15 | ❌ - Incomplete
16 |
17 | ```
18 | 🔄 - TI-Basic
19 | ✅ - 8xp file reading/generation
20 | ✅ - Ti token compilation
21 | ✅ - Ti token decompilation (for debugging)
22 | 🔄 - Complete Ti token enum
23 | 🔄 - 84Script
24 | 🔄 - Antlr
25 | 🔄 - Complete antlr grammar for 84Script
26 | ✅ - Java code generation
27 | 🔄 - Compilation
28 | 🔄 - EFSCompiler.java
29 | ✅ - EFS Statement Block
30 | 🔄 - EFS Script Block
31 | 🔄 - Include other files
32 | 🔄 - Functions
33 | ✅ - Function parsing
34 | ✅ - Function defining
35 | ✅ - Function compiling
36 | ✅ - Function calling
37 | 🔄 - Expressions
38 | ✅ - Bracket expressions "()"
39 | ✅ - Identifier expression
40 | ✅ - Number expression
41 | ✅ - Constant expression (pi, e, ...)
42 | ✅ - Boolean expression
43 | ✅ - True
44 | ✅ - False
45 | ✅ - Greater than
46 | ✅ - Less than
47 | ✅ - Equal to
48 | ✅ - Not equal
49 | ✅ - Greater than or equal to
50 | ✅ - Less than or equal to
51 | ❌ - Text expression
52 | ✅ - Add expression
53 | ✅ - Subtract expression
54 | ✅ - Multiplication expression
55 | ✅ - Division expression
56 | ✅ - Method call expression
57 | 🔄 - Statements
58 | ✅ - Assign statement
59 | ✅ - Add assign statement
60 | ✅ - Subtract assign statement
61 | ✅ - Multiply assign statement
62 | ✅ - Divide assign statement
63 | ✅ - Increment statement
64 | ✅ - Decrement statement
65 | ✅ - If statement
66 | ❌ - While statement
67 | ✅ - Var statement
68 | ✅ - Return statement
69 | 🔄 - TiBasic statement
70 | 🔄 - TiBasic grammar
71 | ✅ - TiBasic parser & lexer (Antlr generated)
72 | 🔄 - TiBasic compiler
73 | ❌ - STIL (Standard TI Library)
74 | ✅ - 8xp from 84Script generation
75 | ✅ - File checksum
76 | ```
77 |
78 | # Using 84Script
79 | 84Script is quite simple to write code with, much like how TI-Basic itself is. If you're already farmiliar with a language such as Python, C, Java, etc. using 84Script should be quite simple.
80 |
81 | ## Functions
82 | Functions can be made using the ``def`` keyword, similarly to Python.
83 | Parameters are only accessible to the current function. They may be passed down to other functions as well.
84 | Example:
85 | ```
86 | def Add(numA, numB)
87 | {
88 | return numA + numB;
89 | }
90 | ```
91 |
92 | ## Multiple files
93 | You can include multiple files using 84Script.
94 | ```
95 | include: STIL.efs
96 | include: anotherFile.efs
97 | ```
98 |
99 | ## Inline Ti-Basic
100 | Much like C++ inline assembly, you can use inline Ti-Basic.
101 | This feature will not be well supported though, and will mostly be used for creating a standard library for 84Script.
102 | ```
103 | def display(myText)
104 | {
105 | __tibasic {
106 | Disp myText;
107 | }
108 | }
109 | ```
110 |
111 | ## Inline assembly
112 | Ti calculators have the ability to run assembly code, I would like to implement some kind of inline assembly at some point. Unfortunately, as far as I'm aware, modern firmwares are restricted from the use of assembly, so this feature may never come to be. If it does come to exist in the future, it will behave much like the "Inline Ti-Basic", but with a ``__asm`` block like you'd find in C++.
113 |
114 | ## STIL
115 | STIL (Standard TI Library) is an 84Script source file you can include in your code to invoke Ti-Basic in a 84Script format. For example, "display". Ti-Basic has a "Disp" token, which will display whatever variable succeeds it. Using it in STIL is as simple as a call to ``display(xyz)`` in your code.
116 | Considering the compiler isnt really done yet, don't expect much here to stay as is. Many compiler features are required for this lib to even be written.
117 |
118 | ## Variables
119 | All variables are only available in their given scope. They may be accessed and modified after their declaration, but not deleted. Keep this in mind when initializing them with repeating code. Variables are always numerical, other types of data, such as strings, are not possible for use with variables. Their numerical abilities are determined by the calculator's settings. If the calculator is in "Real" mode, only real numbers can be stored. Function calls create copies of the variables in each call, meaning recursive calls could fill the parameter stack (``L2``) with multiple of the same variables potentially taking up more memory than needed. In many cases, loops will be preferable to recursive calls.
120 | Variables can be defined using the ``var`` keyword.
121 | Example:
122 | ```
123 | var awesomeVariable = 2.33;
124 | ```
125 |
126 | # Generated structure
127 | This section is about how the generated .8xp file(s) are structured programatically, and how they work. This is important for debugging your code when either you or the compiler makes a mistake.
128 |
129 | ## Program registers
130 | Going forward, use of the A-Z & List variables will be replaced in favor of the [J] matrix. The matrix will store all of the "memory" for the entire program.
131 | * ``[J](1,1)`` - The initialization register. Used for program initialization. Set to true after its used and reset to 0 once program execution has completed.
132 | * ``[J](1,2)`` - The function register. Used to determine which function is being invoked.
133 | * ``[J](1,3)`` - Calling register. Used to determine if a function is meant to be invoked.
134 | * ``[J](1,4)`` - Return register. The value a function returns.
135 | * ``[J](1,5)`` - The current stack "pointer", tells which column of ``[J]`` contains variables for the current context
136 |
137 | The ``1`` column is reserved for the purposes mentioned above. ``2`` and onward will be used for variables starting from the top script scope. A new scope will be pushed on the matrix each function call.
138 |
139 | ## Variables
140 | Since lists are no longer used, the ``[J]`` matrix will hold everything the program needs.
141 | * ``[J](2->?, ?)`` - Holds all variables, starting with the main script scope at ``2``. Function calls create a new scope, push the arguments and execute the function.
142 |
143 | ## Visualization
144 |
145 | | Start |
146 | | :-------: |
147 | | Init |
148 | | Func Table |
149 | | Program |
150 |
151 | Its quite a simple, yet effective structure.
152 |
153 | # Limitations
154 | 84Script is limited by a number of factors, all of which are limitations of Ti-Basic.
155 | * Only 6 strings can be stored at a time
156 | * You can only concatenate strings
157 | * All numeric vars are restricted by calculator settings
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DisabledMallis/84Script/6cef8aed40ca55ae0ce68a4f24148aa194674c78/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file was generated by the Gradle 'init' task.
3 | *
4 | * The settings file is used to specify which projects to include in your build.
5 | *
6 | * Detailed information about configuring a multi-project build in Gradle can be found
7 | * in the user manual at https://docs.gradle.org/6.8.3/userguide/multi_project_builds.html
8 | */
9 |
10 | rootProject.name = 'EFScript'
11 | include('84Script')
12 |
--------------------------------------------------------------------------------