├── .gitignore ├── .idea ├── .gitignore └── vcs.xml ├── README.md ├── build.gradle ├── gradle.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── antlr ├── KotlinLexer.g4 ├── KotlinLexer.tokens ├── KotlinParser.g4 ├── MegaAsmLexer.g4 ├── MegaAsmLexer.tokens ├── MegaAsmParser.g4 ├── PseudoAsmLexer.g4 ├── PseudoAsmLexer.tokens ├── PseudoAsmParser.g4 └── UnicodeClasses.g4 ├── gen ├── KotlinLexer.interp ├── KotlinLexer.java ├── KotlinLexer.tokens ├── KotlinParser.interp ├── KotlinParser.java ├── KotlinParser.tokens ├── KotlinParserBaseListener.java ├── KotlinParserBaseVisitor.java ├── KotlinParserListener.java ├── KotlinParserVisitor.java ├── MegaAsmLexer.interp ├── MegaAsmLexer.java ├── MegaAsmLexer.tokens ├── MegaAsmParser.interp ├── MegaAsmParser.java ├── MegaAsmParser.tokens ├── MegaAsmParserBaseListener.java ├── MegaAsmParserBaseVisitor.java ├── MegaAsmParserListener.java ├── MegaAsmParserVisitor.java ├── PseudoAsmLexer.interp ├── PseudoAsmLexer.java ├── PseudoAsmLexer.tokens ├── PseudoAsmParser.interp ├── PseudoAsmParser.java ├── PseudoAsmParser.tokens ├── PseudoAsmParserBaseListener.java ├── PseudoAsmParserBaseVisitor.java ├── PseudoAsmParserListener.java └── PseudoAsmParserVisitor.java ├── java └── pl │ └── qus │ └── wolin │ ├── KotlinLexer.java │ ├── KotlinLexer.tokens │ ├── KotlinParser.java │ ├── KotlinParser.tokens │ ├── KotlinParserBaseListener.java │ ├── KotlinParserBaseVisitor.java │ ├── KotlinParserListener.java │ ├── KotlinParserVisitor.java │ ├── MegaAsmLexer.java │ ├── MegaAsmLexer.tokens │ ├── MegaAsmParser.java │ ├── MegaAsmParser.tokens │ ├── MegaAsmParserBaseListener.java │ ├── MegaAsmParserBaseVisitor.java │ ├── MegaAsmParserListener.java │ ├── MegaAsmParserVisitor.java │ ├── PseudoAsmLexer.java │ ├── PseudoAsmLexer.tokens │ ├── PseudoAsmParser.java │ ├── PseudoAsmParser.tokens │ ├── PseudoAsmParserBaseListener.java │ ├── PseudoAsmParserBaseVisitor.java │ ├── PseudoAsmParserListener.java │ ├── PseudoAsmParserVisitor.java │ ├── UnicodeClasses.java │ └── UnicodeClasses.tokens ├── kotlin ├── Gui.kt ├── RegisterOps.kt └── pl │ └── qus │ └── wolin │ ├── Debugger2.kt │ ├── Main.kt │ ├── ParseTreeHelper.kt │ ├── PseudoAsmParserVisitor.java │ ├── PseudoAsmStateObject.kt │ ├── PseudoAsmVisitor.kt │ ├── WolinStateObject.kt │ ├── WolinVisitor.kt │ ├── components │ ├── AllocType.kt │ ├── AssignStack.kt │ ├── FieldType.kt │ ├── Funkcja.kt │ ├── Klasa.kt │ ├── Primitives.kt │ ├── RegOper.kt │ ├── Typ.kt │ └── Zmienna.kt │ ├── exception │ ├── FunctionNotFound.kt │ ├── InterruptFunctionWithLocals.kt │ ├── NoRuleException.kt │ ├── RegTypeMismatchException.kt │ ├── ReplaceInArgException.kt │ ├── TypeMismatchException.kt │ ├── UnknownLiteral.kt │ └── VariableNotFound.kt │ ├── optimizer │ ├── FlowNode.kt │ └── NewOptimizerProcessor.kt │ └── steps │ ├── CompilerProcess.kt │ ├── OptimizerStep.kt │ ├── PseudoAsmStep.kt │ ├── SanitizerStep.kt │ └── TargetStep.kt ├── resources └── pl │ └── qus │ └── wolin │ └── MyView.fxml └── wolin ├── c64-asm.cfg ├── c64-overlay.cfg ├── c64.cfg ├── c64.lib ├── ca65.exe ├── cl65.exe ├── examples ├── calling_cc65.ktk ├── kernal_io.ktk ├── misc.ktk ├── objects.ktk ├── raster_irq.ktk ├── screen_array.ktk └── strings.ktk ├── ld65.exe ├── template.asm ├── test.ktk ├── wolincrt0 ├── bezC │ ├── HOWTO.txt │ ├── callmain.o │ ├── callmain.s │ ├── cfg │ │ └── wolin.cfg │ ├── condes.s │ ├── crt0.o │ ├── crt0.s │ ├── exehdr.o │ ├── exehdr.s │ ├── loadaddr.o │ ├── loadaddr.s │ ├── main.o │ ├── main.s │ ├── wolin.inc │ ├── zerobss.o │ ├── zerobss.s │ ├── zeropage.inc │ ├── zeropage.o │ └── zeropage.s └── zC │ ├── HOWTO.txt │ ├── callmain.s │ ├── cfg │ └── wolin.cfg │ ├── condes.s │ ├── crt0.s │ ├── exehdr.s │ ├── loadaddr.s │ ├── zerobss.s │ ├── zeropage.inc │ └── zeropage.s ├── wozniak_float.s ├── wozniak_float.txt ├── x64 - skrót.lnk └── x64 remotedebug.lnk /.gitignore: -------------------------------------------------------------------------------- 1 | /build/* 2 | /.gradle/* 3 | /.idea/* 4 | /gradle/* 5 | 6 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wolin 2 | A modern, minimal Kotlin-like language compiler for MOS 6502 / 6510 3 | 4 | # Features 5 | 6 | Currently supporting: 7 | 8 | - functional programming (lambdas) 9 | - exception handling 10 | - if/else if 11 | - do...while 12 | - when (switch/case on steroids) 13 | - some introductory OO - classes with constructors and methods 14 | - variables at fixed memory locations like `var border: ubyte^53280` 15 | - variables fixed to CPU registers like `var maskInterrupts: bool^CPU.I` 16 | - functions at fixed memory locations with native arguments like `fun setLfs^0xffba(lfn: ubyte^CPU.A, channel: ubyte^CPU.Y, dev: ubyte^CPU.X)` 17 | - getting values from long / fast (1-byte index, 1-byte element) arrays 18 | 19 | Extra perks: 20 | 21 | - whole generated code (apart from function-local variables, globals and objects) operates exclusively on zero page, treating it like a big heap of CPU registers, namely 72 CPU registers in default Wolin configuration for C64. Due to how the regs get freed/allocated I can't really imagine a piece of code that would use beyond this limit 22 | 23 | - Wolin generates assembler code for ca65 with memory config for Commodore 64, it is very easy, though, to port it to other architectures via intermediate code to native code templates 24 | 25 | - Has its own graphic debugger that connects to VICE session 26 | 27 | # TODOs 28 | 29 | - a lot of other language features 30 | - writing elements to all kinds of arrays 31 | 32 | # Architecture 33 | 34 | First the compiler translates Wolin code to intermediate virtual machine assembler that has the following syntax: 35 | 36 | ```mnemonic destination[type] = arg1[type], arg2[type]``` 37 | 38 | 39 | So for example "b++" becomes: 40 | 41 | ```add pl.qus.wolin.test.main..b[word] = pl.qus.wolin.test.main..b[word], #1[byte]``` 42 | 43 | 44 | And then there's "template" file that describes how each "mnemonic type = type,type" combination gets translated into 6510 asm, by matching some patterns: 45 | 46 | ``` 47 | add ?dest[word] = ?src[word], #?val[byte] -> """ 48 | clc 49 | lda {src} 50 | adc #{val} 51 | sta {dest} 52 | lda {src}+1 53 | adc #0 54 | sta {dest}+1 55 | """ 56 | ``` 57 | 58 | which in this case becomes: 59 | 60 | ``` 61 | clc 62 | lda pl_qus_wolin_test_main__b 63 | adc #1 64 | sta pl_qus_wolin_test_main__b 65 | lda pl_qus_wolin_test_main__b+1 66 | adc #0 67 | sta pl_qus_wolin_test_main__b+1 68 | ``` 69 | 70 | # Example code 71 | 72 | ``` 73 | package pl.qus.wolin 74 | 75 | // raster interrupt colour band taken from: 76 | // https://gist.github.com/bremensaki/8f33cd7d67b78377881c7eb7147c0f32 77 | 78 | var interruptRoutineVector: uword^0x314 // this is C64 raster interrupt vector 79 | var cia1InerruptCtrlReg: ubyte^0xDC0D 80 | var vicScreenCtrlReg1: ubyte^0xD011 81 | var vicRasterLine: ubyte^0xD012 82 | var vicInterruptStatusReg: ubyte^0xd019 83 | var vicInterruptCtrlReg: ubyte^0xd01a 84 | var vicBorder: ubyte^53280 85 | var maskInterrupts: bool^CPU.I // this boolean is attached to 6502 I flag 86 | 87 | fun clearScreen^0xe544() // clear screen function in C64 ROM 88 | 89 | fun onRasterGoto(line: ubyte, proc: uword) { 90 | interruptRoutineVector = proc 91 | vicRasterLine = line 92 | } 93 | 94 | interrupt fun backgroundToBlue() { 95 | onRasterGoto(140, backgroundToWhite) 96 | vicBorder = 6 97 | vicInterruptStatusReg = 0xff 98 | return@0xea31 // don't return from this function, continue with ROM routine 99 | } 100 | 101 | interrupt fun backgroundToWhite() { 102 | onRasterGoto(160, backgroundToBlue) 103 | vicBorder = 1 104 | vicInterruptStatusReg = 0xff 105 | return@0xea31 106 | } 107 | 108 | fun main() { 109 | clearScreen() 110 | vicBorder = 6 // Init screen and border to blue 111 | maskInterrupts = true // Suspend interrupts during init 112 | cia1InerruptCtrlReg = 0x7f // Disable CIA 113 | vicInterruptCtrlReg := 1 // Enable raster interrupts 114 | vicScreenCtrlReg1 .= 128 // High bit of raster line cleared, we're only working within single byte ranges 115 | vicRasterLine = 140 // We want an interrupt at the top line 116 | interruptRoutineVector = backgroundToBlue // IRQ vector addresses 117 | maskInterrupts = false // Enable interrupts again 118 | 119 | do {} while (true) // Eternal do-nothing loop, we're done. 120 | } 121 | ``` 122 | 123 | # New syntax 124 | 125 | Syntax different from Kotlin: 126 | 127 | - `variable := 3` set bits 1 and 2 (variable must be readable) 128 | - `variable .= 127` clear bit 7 (variable must be readable) 129 | - `variable & variable` bitwise AND 130 | - `variable | variable` bitwise OR 131 | - `variable &= 3` bitwise in-place AND (variable must be readable) 132 | - `variable |= 3` bitwise in-place OR (variable must be readable) 133 | - `interrupt fun()` denotes interrupt routine function that can RTI instead of RTS 134 | - `fun xxx^location()` function attached to some address (usually ROM functions) 135 | - `var a:type^location` variable attached to some address (I/O registers) 136 | - `uwordVariable = functionName` set `uwordVariable` to address of some function 137 | - `external fun` declaration of a Wolin function written in assembler elsewhere 138 | - `cc65 fun` declaration of external C function compiled by cc65 139 | 140 | # cc65 Interfacing 141 | 142 | To use cc65 functions in Wolin it is enough to declare them with `cc65` decoration with arguments and return values of matching sizes. 143 | 144 | `__fastcall__` fuctions are declared via "attached" parameters, like: 145 | 146 | ``` 147 | // unsigned char __fastcall__ bordercolor (unsigned char color); 148 | cc65 fun bordercolor(col: ubyte^CPU.A): ubyte 149 | // unsigned char __fastcall__ strlen (char* string); 150 | cc65 fun strlen(string: string^CPU.AX): ubyte 151 | ``` 152 | 153 | # Usage 154 | 155 | If you want to play with Wolin first you need to change hardcoded working directory path in `Main` object: 156 | 157 | `val buildPath = "D:\\Projekty\\kotlinek\\src\\main\\wolin\\"` 158 | 159 | Then you can run 160 | 161 | `java -jar wolinName.jar inputFile1 inputFile2... [-o || --output] [-d || --debug]` 162 | 163 | Input files might be either *.ktk (Wolin source files) or *.qasm (Wolin pseudo asm intermediate files, in case you want to correct them by hand). 164 | 165 | If you don't supply `-o` resulting file will be named like first supplied file 166 | 167 | If you add `-d` be sure to have VICE emulator started with `-remotedebug` option to open up a graphic Wolin debugger. 168 | 169 | # Let's talk 170 | 171 | Criticise, discuss, watch progress here: http://forum.6502.org/viewtopic.php?f=2&t=5622 -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'idea' 3 | id 'java' 4 | id 'org.jetbrains.kotlin.jvm' version '1.3.61' 5 | id 'antlr' 6 | } 7 | 8 | group 'pl.qus' 9 | version '1.0-SNAPSHOT' 10 | 11 | sourceCompatibility = 1.8 12 | 13 | repositories { 14 | mavenCentral() 15 | } 16 | 17 | dependencies { 18 | implementation "org.antlr:antlr4-runtime:4.5.1" 19 | antlr "org.antlr:antlr4:4.5.1" 20 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" 21 | implementation 'commons-net:commons-net:3.6' 22 | implementation 'no.tornado:tornadofx:1.7.20' 23 | implementation "com.beust:jcommander:1.78" 24 | 25 | } 26 | 27 | compileKotlin { 28 | kotlinOptions.jvmTarget = "1.8" 29 | } 30 | compileTestKotlin { 31 | kotlinOptions.jvmTarget = "1.8" 32 | } 33 | 34 | compileKotlin.dependsOn generateGrammarSource 35 | 36 | generateGrammarSource { 37 | maxHeapSize="64m" 38 | arguments+=['-package','pl.qus.wolin','-visitor'] 39 | //outputDirectory=new File("generated-src/antlr/main/pl/qus/wolin".toString()) 40 | outputDirectory=new File("src/main/java/pl/qus/wolin".toString()) 41 | } 42 | 43 | sourceSets { 44 | generated { 45 | java.srcDir 'generated-src/antlr/main' 46 | } 47 | } 48 | 49 | compileKotlin.source sourceSets.generated.java, sourceSets.main.java 50 | 51 | idea { 52 | module { 53 | sourceDirs += file('generated-src/antlr/main') 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'wolin' 2 | 3 | -------------------------------------------------------------------------------- /src/main/antlr/KotlinLexer.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | MULT=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | CONJ=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | BIT_ASSIGNMENT=300 34 | BIT_DEASSIGNMENT=300 35 | BIT_OR=301 36 | BIT_AND=302 37 | BIT_OR_ASSIGNMENT=303 38 | BIT_AND_ASSIGNMENT=304 39 | 40 | ARROW=33 41 | DOUBLE_ARROW=34 42 | RANGE=35 43 | CARON=200 44 | COLONCOLON=36 45 | Q_COLONCOLON=37 46 | DOUBLE_SEMICOLON=38 47 | HASH=39 48 | AT=40 49 | QUEST=41 50 | ELVIS=42 51 | LANGLE=43 52 | RANGLE=44 53 | LE=45 54 | GE=46 55 | EXCL_EQ=47 56 | EXCL_EQEQ=48 57 | AS_SAFE=49 58 | EQEQ=50 59 | EQEQEQ=51 60 | SINGLE_QUOTE=52 61 | RETURN_AT=53 62 | CONTINUE_AT=54 63 | BREAK_AT=55 64 | FILE=56 65 | PACKAGE=57 66 | IMPORT=58 67 | CLASS=59 68 | INTERFACE=60 69 | FUN=61 70 | OBJECT=62 71 | VAL=63 72 | VAR=64 73 | TYPE_ALIAS=65 74 | CONSTRUCTOR=66 75 | BY=67 76 | COMPANION=68 77 | INIT=69 78 | THIS=70 79 | SUPER=71 80 | TYPEOF=72 81 | WHERE=73 82 | IF=74 83 | ELSE=75 84 | WHEN=76 85 | TRY=77 86 | CATCH=78 87 | FINALLY=79 88 | FOR=80 89 | DO=81 90 | WHILE=82 91 | THROW=83 92 | RETURN=84 93 | CONTINUE=85 94 | BREAK=86 95 | AS=87 96 | IS=88 97 | IN=89 98 | NOT_IS=90 99 | NOT_IN=91 100 | OUT=92 101 | FIELD=93 102 | PROPERTY=94 103 | GET=95 104 | SET=96 105 | GETTER=97 106 | SETTER=98 107 | RECEIVER=99 108 | PARAM=100 109 | SETPARAM=101 110 | DELEGATE=102 111 | DYNAMIC=103 112 | PUBLIC=104 113 | PRIVATE=105 114 | PROTECTED=106 115 | INTERNAL=107 116 | ENUM=108 117 | SEALED=109 118 | ANNOTATION=110 119 | DATA=111 120 | INNER=112 121 | TAILREC=113 122 | OPERATOR=114 123 | INLINE=115 124 | INFIX=116 125 | EXTERNAL=117 126 | SUSPEND=118 127 | OVERRIDE=119 128 | ABSTRACT=120 129 | FINAL=121 130 | OPEN=122 131 | CONST=123 132 | LATEINIT=124 133 | VARARG=125 134 | NOINLINE=126 135 | CROSSINLINE=127 136 | REIFIED=128 137 | QUOTE_OPEN=129 138 | TRIPLE_QUOTE_OPEN=130 139 | RealLiteral=131 140 | FloatLiteral=132 141 | DoubleLiteral=133 142 | LongLiteral=134 143 | IntegerLiteral=135 144 | HexLiteral=136 145 | BinLiteral=137 146 | BooleanLiteral=138 147 | NullLiteral=139 148 | Identifier=140 149 | LabelReference=141 150 | LabelDefinition=142 151 | FieldIdentifier=143 152 | CharacterLiteral=144 153 | UNICODE_CLASS_LL=145 154 | UNICODE_CLASS_LM=146 155 | UNICODE_CLASS_LO=147 156 | UNICODE_CLASS_LT=148 157 | UNICODE_CLASS_LU=149 158 | UNICODE_CLASS_ND=150 159 | UNICODE_CLASS_NL=151 160 | Inside_Comment=152 161 | Inside_WS=153 162 | Inside_NL=154 163 | QUOTE_CLOSE=155 164 | LineStrRef=156 165 | LineStrText=157 166 | LineStrEscapedChar=158 167 | LineStrExprStart=159 168 | TRIPLE_QUOTE_CLOSE=160 169 | MultiLineStringQuote=161 170 | MultiLineStrRef=162 171 | MultiLineStrText=163 172 | MultiLineStrEscapedChar=164 173 | MultiLineStrExprStart=165 174 | MultiLineNL=166 175 | StrExpr_IN=167 176 | StrExpr_Comment=168 177 | StrExpr_WS=169 178 | StrExpr_NL=170 179 | INTERRUPT=171 180 | CC65=172 181 | '...'=6 182 | '.'=7 183 | ','=8 184 | '('=9 185 | '['=11 186 | '{'=13 187 | '}'=14 188 | '*'=15 189 | '%'=16 190 | '/'=17 191 | '+'=18 192 | '-'=19 193 | '++'=20 194 | '--'=21 195 | '&&'=22 196 | '||'=23 197 | '!'=24 198 | ':'=25 199 | ';'=26 200 | '='=27 201 | '+='=28 202 | '-='=29 203 | '*='=30 204 | '/='=31 205 | '%='=32 206 | '->'=33 207 | '=>'=34 208 | '..'=35 209 | '::'=36 210 | '?::'=37 211 | ';;'=38 212 | '#'=39 213 | '@'=40 214 | '?'=41 215 | '?:'=42 216 | '<'=43 217 | '>'=44 218 | '<='=45 219 | '>='=46 220 | '!='=47 221 | '!=='=48 222 | 'as?'=49 223 | '=='=50 224 | '==='=51 225 | '\''=52 226 | '@file'=56 227 | 'package'=57 228 | 'import'=58 229 | 'class'=59 230 | 'interface'=60 231 | 'fun'=61 232 | 'object'=62 233 | 'val'=63 234 | 'var'=64 235 | 'typealias'=65 236 | 'constructor'=66 237 | 'by'=67 238 | 'companion'=68 239 | 'init'=69 240 | 'this'=70 241 | 'super'=71 242 | 'typeof'=72 243 | 'where'=73 244 | 'if'=74 245 | 'else'=75 246 | 'when'=76 247 | 'try'=77 248 | 'catch'=78 249 | 'finally'=79 250 | 'for'=80 251 | 'do'=81 252 | 'while'=82 253 | 'throw'=83 254 | 'return'=84 255 | 'continue'=85 256 | 'break'=86 257 | 'as'=87 258 | 'is'=88 259 | 'in'=89 260 | 'out'=92 261 | '@field'=93 262 | '@property'=94 263 | '@get'=95 264 | '@set'=96 265 | 'get'=97 266 | 'set'=98 267 | '@receiver'=99 268 | '@param'=100 269 | '@setparam'=101 270 | '@delegate'=102 271 | 'dynamic'=103 272 | 'public'=104 273 | 'private'=105 274 | 'protected'=106 275 | 'internal'=107 276 | 'enum'=108 277 | 'sealed'=109 278 | 'annotation'=110 279 | 'data'=111 280 | 'inner'=112 281 | 'tailrec'=113 282 | 'operator'=114 283 | 'inline'=115 284 | 'infix'=116 285 | 'external'=117 286 | 'suspend'=118 287 | 'override'=119 288 | 'abstract'=120 289 | 'final'=121 290 | 'open'=122 291 | 'const'=123 292 | 'lateinit'=124 293 | 'vararg'=125 294 | 'noinline'=126 295 | 'crossinline'=127 296 | 'reified'=128 297 | '"""'=130 298 | 'null'=139 299 | 'interrupt'=171 300 | 'cc65'=172 -------------------------------------------------------------------------------- /src/main/antlr/MegaAsmLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar MegaAsmLexer; 2 | 3 | import UnicodeClasses; 4 | 5 | DelimitedComment 6 | : '/*' ( DelimitedComment | . )*? '*/' 7 | -> channel(HIDDEN) 8 | ; 9 | 10 | LineComment 11 | : '//' ~[\u000A\u000D]* 12 | -> channel(HIDDEN) 13 | ; 14 | 15 | WS 16 | : [\u0020\u0009\u000C] 17 | -> skip 18 | ; 19 | 20 | NL: '\u000A' | '\u000D' '\u000A' ; 21 | 22 | DOT: '.' ; 23 | HASH: '#' ; 24 | LPAREN: '(' ; 25 | RPAREN: ')' ; 26 | LSQUARE: '[' ; 27 | RSQUARE: ']' ; 28 | ASSIGNMENT: '=' ; 29 | COMMA: ',' ; 30 | QUEST: '?' ; 31 | AT: '@' ; 32 | ARROW: '->' ; 33 | MOD: '%' ; 34 | DOLLAR: '$' ; 35 | REFERENCE: '*' ; 36 | DEREFERENCE: '&' ; 37 | COLON: ':' ; 38 | 39 | QUOTE_OPEN: '"' -> pushMode(LineString) ; 40 | TRIPLE_QUOTE_OPEN: '"""' -> pushMode(MultiLineString) ; 41 | 42 | 43 | fragment HexDigit 44 | : [0-9a-fA-F] 45 | ; 46 | 47 | fragment UniCharacterLiteral 48 | : '\\' 'u' HexDigit HexDigit HexDigit HexDigit 49 | ; 50 | 51 | fragment DecDigit 52 | : UNICODE_CLASS_ND 53 | ; 54 | 55 | fragment DecDigitNoZero 56 | : UNICODE_CLASS_ND_NoZeros 57 | ; 58 | 59 | fragment UNICODE_CLASS_ND_NoZeros 60 | : '\u0031'..'\u0039' 61 | | '\u0661'..'\u0669' 62 | | '\u06f1'..'\u06f9' 63 | | '\u07c1'..'\u07c9' 64 | | '\u0967'..'\u096f' 65 | | '\u09e7'..'\u09ef' 66 | | '\u0a67'..'\u0a6f' 67 | | '\u0ae7'..'\u0aef' 68 | | '\u0b67'..'\u0b6f' 69 | | '\u0be7'..'\u0bef' 70 | | '\u0c67'..'\u0c6f' 71 | | '\u0ce7'..'\u0cef' 72 | | '\u0d67'..'\u0d6f' 73 | | '\u0de7'..'\u0def' 74 | | '\u0e51'..'\u0e59' 75 | | '\u0ed1'..'\u0ed9' 76 | | '\u0f21'..'\u0f29' 77 | | '\u1041'..'\u1049' 78 | | '\u1091'..'\u1099' 79 | | '\u17e1'..'\u17e9' 80 | | '\u1811'..'\u1819' 81 | | '\u1947'..'\u194f' 82 | | '\u19d1'..'\u19d9' 83 | | '\u1a81'..'\u1a89' 84 | | '\u1a91'..'\u1a99' 85 | | '\u1b51'..'\u1b59' 86 | | '\u1bb1'..'\u1bb9' 87 | | '\u1c41'..'\u1c49' 88 | | '\u1c51'..'\u1c59' 89 | | '\ua621'..'\ua629' 90 | | '\ua8d1'..'\ua8d9' 91 | | '\ua901'..'\ua909' 92 | | '\ua9d1'..'\ua9d9' 93 | | '\ua9f1'..'\ua9f9' 94 | | '\uaa51'..'\uaa59' 95 | | '\uabf1'..'\uabf9' 96 | | '\uff11'..'\uff19' 97 | ; 98 | 99 | FloatLiteral 100 | : (DoubleLiteral | IntegerLiteral) [fF] 101 | ; 102 | 103 | DoubleLiteral 104 | : ( (DecDigitNoZero DecDigit*)? '.' 105 | | (DecDigitNoZero (DecDigit | '_')* DecDigit)? '.') 106 | ( DecDigit+ 107 | | DecDigit (DecDigit | '_')+ DecDigit 108 | | DecDigit+ [eE] ('+' | '-')? DecDigit+ 109 | | DecDigit+ [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit 110 | | DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+ 111 | | DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit 112 | ) 113 | ; 114 | 115 | 116 | IntegerLiteral 117 | : ('0' 118 | | '-'? DecDigitNoZero DecDigit* 119 | | '-'? DecDigitNoZero (DecDigit | '_')+ DecDigit 120 | | '-'? DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit+ 121 | | '-'? DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit 122 | | '-'? DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+ 123 | | '-'? DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit 124 | ) 125 | ; 126 | 127 | Identifier 128 | : (Letter | '_') (Letter | '_' | DecDigit)* 129 | | '`' ~('`')+ '`' 130 | ; 131 | 132 | Operator 133 | : '+' 134 | | '-' 135 | | '/' 136 | | '<=' 137 | | '>=' 138 | | '==' 139 | | '!=' 140 | | '<' 141 | | '>' 142 | ; 143 | 144 | fragment Letter 145 | : UNICODE_CLASS_LL 146 | | UNICODE_CLASS_LM 147 | | UNICODE_CLASS_LO 148 | | UNICODE_CLASS_LT 149 | | UNICODE_CLASS_LU 150 | | UNICODE_CLASS_NL 151 | ; 152 | 153 | 154 | mode LineString ; 155 | 156 | QUOTE_CLOSE 157 | : '"' -> popMode 158 | ; 159 | 160 | LineStrText 161 | : ~('\\' | '"' | '$')+ | '$' 162 | ; 163 | 164 | LineStrEscapedChar 165 | : '\\' . 166 | | UniCharacterLiteral 167 | ; 168 | 169 | mode MultiLineString ; 170 | 171 | TRIPLE_QUOTE_CLOSE 172 | : MultiLineStringQuote? '"""' -> popMode 173 | ; 174 | 175 | MultiLineStringQuote 176 | : '"'+ 177 | ; 178 | 179 | 180 | MultiLineStrText 181 | : ~('\\' | '"' | '$')+ | '$' 182 | ; 183 | 184 | MultiLineStrEscapedChar 185 | : '\\' . 186 | ; 187 | 188 | MultiLineNL: NL -> skip ; 189 | 190 | StrExpr_TRIPLE_QUOTE_OPEN: TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) ; 191 | StrExpr_QUOTE_OPEN: QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN) ; 192 | 193 | -------------------------------------------------------------------------------- /src/main/antlr/MegaAsmLexer.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | REFERENCE=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | DEREFERENCE=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | ARROW=33 34 | DOUBLE_ARROW=34 35 | RANGE=35 36 | COLONCOLON=36 37 | Q_COLONCOLON=37 38 | DOUBLE_SEMICOLON=38 39 | HASH=39 40 | AT=40 41 | QUEST=41 42 | ELVIS=42 43 | LE=45 44 | GE=46 45 | EXCL_EQ=47 46 | EXCL_EQEQ=48 47 | AS_SAFE=49 48 | EQEQ=50 49 | EQEQEQ=51 50 | SINGLE_QUOTE=52 51 | RETURN_AT=53 52 | CONTINUE_AT=54 53 | BREAK_AT=55 54 | FILE=56 55 | PACKAGE=57 56 | IMPORT=58 57 | CLASS=59 58 | INTERFACE=60 59 | FUN=61 60 | OBJECT=62 61 | VAL=63 62 | VAR=64 63 | TYPE_ALIAS=65 64 | CONSTRUCTOR=66 65 | BY=67 66 | COMPANION=68 67 | INIT=69 68 | THIS=70 69 | SUPER=71 70 | TYPEOF=72 71 | WHERE=73 72 | IF=74 73 | ELSE=75 74 | WHEN=76 75 | TRY=77 76 | CATCH=78 77 | FINALLY=79 78 | FOR=80 79 | DO=81 80 | WHILE=82 81 | THROW=83 82 | RETURN=84 83 | CONTINUE=85 84 | BREAK=86 85 | AS=87 86 | IS=88 87 | IN=89 88 | NOT_IS=90 89 | NOT_IN=91 90 | OUT=92 91 | FIELD=93 92 | PROPERTY=94 93 | GET=95 94 | SET=96 95 | GETTER=97 96 | SETTER=98 97 | RECEIVER=99 98 | PARAM=100 99 | SETPARAM=101 100 | DELEGATE=102 101 | DYNAMIC=103 102 | PUBLIC=104 103 | PRIVATE=105 104 | PROTECTED=106 105 | INTERNAL=107 106 | ENUM=108 107 | SEALED=109 108 | ANNOTATION=110 109 | DATA=111 110 | INNER=112 111 | TAILREC=113 112 | OPERATOR=114 113 | INLINE=115 114 | INFIX=116 115 | EXTERNAL=117 116 | SUSPEND=118 117 | OVERRIDE=119 118 | ABSTRACT=120 119 | FINAL=121 120 | OPEN=122 121 | CONST=123 122 | LATEINIT=124 123 | VARARG=125 124 | NOINLINE=126 125 | CROSSINLINE=127 126 | REIFIED=128 127 | QUOTE_OPEN=129 128 | TRIPLE_QUOTE_OPEN=130 129 | RealLiteral=131 130 | FloatLiteral=132 131 | DoubleLiteral=133 132 | LongLiteral=134 133 | IntegerLiteral=135 134 | HexLiteral=136 135 | BinLiteral=137 136 | BooleanLiteral=138 137 | NullLiteral=139 138 | Identifier=140 139 | LabelReference=141 140 | LabelDefinition=142 141 | FieldIdentifier=143 142 | CharacterLiteral=144 143 | UNICODE_CLASS_LL=145 144 | UNICODE_CLASS_LM=146 145 | UNICODE_CLASS_LO=147 146 | UNICODE_CLASS_LT=148 147 | UNICODE_CLASS_LU=149 148 | UNICODE_CLASS_ND=150 149 | UNICODE_CLASS_NL=151 150 | Inside_Comment=152 151 | Inside_WS=153 152 | Inside_NL=154 153 | QUOTE_CLOSE=155 154 | LineStrRef=156 155 | LineStrText=157 156 | LineStrEscapedChar=158 157 | LineStrExprStart=159 158 | TRIPLE_QUOTE_CLOSE=160 159 | MultiLineStringQuote=161 160 | MultiLineStrRef=162 161 | MultiLineStrText=163 162 | MultiLineStrEscapedChar=164 163 | MultiLineStrExprStart=165 164 | MultiLineNL=166 165 | StrExpr_IN=167 166 | StrExpr_Comment=168 167 | StrExpr_WS=169 168 | StrExpr_NL=170 169 | DOLLAR=180 170 | '...'=6 171 | '.'=7 172 | ','=8 173 | '('=9 174 | '['=11 175 | '{'=13 176 | '}'=14 177 | '*'=15 178 | '%'=16 179 | '/'=17 180 | '+'=18 181 | '-'=19 182 | '++'=20 183 | '--'=21 184 | '&'=22 185 | '||'=23 186 | '!'=24 187 | ':'=25 188 | ';'=26 189 | '='=27 190 | '+='=28 191 | '-='=29 192 | '*='=30 193 | '/='=31 194 | '%='=32 195 | '->'=33 196 | '=>'=34 197 | '..'=35 198 | '::'=36 199 | '?::'=37 200 | ';;'=38 201 | '#'=39 202 | '@'=40 203 | '?'=41 204 | '?:'=42 205 | '<'=43 206 | '>'=44 207 | '<='=45 208 | '>='=46 209 | '!='=47 210 | '!=='=48 211 | 'as?'=49 212 | '=='=50 213 | '==='=51 214 | '\''=52 215 | '@file'=56 216 | 'package'=57 217 | 'import'=58 218 | 'class'=59 219 | 'interface'=60 220 | 'fun'=61 221 | 'object'=62 222 | 'val'=63 223 | 'var'=64 224 | 'typealias'=65 225 | 'constructor'=66 226 | 'by'=67 227 | 'companion'=68 228 | 'init'=69 229 | 'this'=70 230 | 'super'=71 231 | 'typeof'=72 232 | 'where'=73 233 | 'if'=74 234 | 'else'=75 235 | 'when'=76 236 | 'try'=77 237 | 'catch'=78 238 | 'finally'=79 239 | 'for'=80 240 | 'do'=81 241 | 'while'=82 242 | 'throw'=83 243 | 'return'=84 244 | 'continue'=85 245 | 'break'=86 246 | 'as'=87 247 | 'is'=88 248 | 'in'=89 249 | 'out'=92 250 | '@field'=93 251 | '@property'=94 252 | '@get'=95 253 | '@set'=96 254 | 'get'=97 255 | 'set'=98 256 | '@receiver'=99 257 | '@param'=100 258 | '@setparam'=101 259 | '@delegate'=102 260 | 'dynamic'=103 261 | 'public'=104 262 | 'private'=105 263 | 'protected'=106 264 | 'internal'=107 265 | 'enum'=108 266 | 'sealed'=109 267 | 'annotation'=110 268 | 'data'=111 269 | 'const'=123 270 | 'lateinit'=124 271 | 'vararg'=125 272 | 'noinline'=126 273 | 'crossinline'=127 274 | 'reified'=128 275 | '"""'=130 276 | 'null'=139 277 | '$'=180 278 | Operator=181 -------------------------------------------------------------------------------- /src/main/antlr/MegaAsmParser.g4: -------------------------------------------------------------------------------- 1 | parser grammar MegaAsmParser; 2 | 3 | options { tokenVocab = MegaAsmLexer; } 4 | 5 | pseudoAsmFile 6 | : NL* (linia NL*)* EOF 7 | ; 8 | 9 | referencer 10 | : (REFERENCE | DEREFERENCE); 11 | 12 | operand 13 | : referencer* value typeName*; 14 | 15 | value 16 | : (addressed | immediate | floatimmediate | stringimmediate ); 17 | 18 | addressed 19 | : (absAddress | identifier) (LPAREN index RPAREN)*; 20 | 21 | index 22 | : (IntegerLiteral); 23 | 24 | immediate 25 | : HASH (IntegerLiteral | identifier); 26 | 27 | floatimmediate 28 | : MOD (DoubleLiteral); 29 | 30 | stringimmediate 31 | : DOLLAR (lineStringLiteral); 32 | 33 | absAddress 34 | : IntegerLiteral; 35 | 36 | typeName 37 | : COLON (identifier) referencer* 38 | ; 39 | 40 | instrukcja 41 | : simpleIdentifier 42 | ; 43 | 44 | linia 45 | : instrukcja (target ASSIGNMENT (arg (Operator arg)*))* (ARROW assemblerBody)* NL 46 | | instrukcja arg (COMMA arg)* (ARROW assemblerBody)* NL 47 | ; 48 | 49 | target 50 | : operand 51 | ; 52 | 53 | arg 54 | : operand 55 | ; 56 | 57 | 58 | identifier 59 | : simpleIdentifier (NL* DOT simpleIdentifier*)* 60 | ; 61 | 62 | simpleIdentifier 63 | : Identifier 64 | ; 65 | 66 | 67 | //semi: NL+ | NL* SEMICOLON NL*; 68 | 69 | //anysemi: NL | SEMICOLON; 70 | 71 | assemblerBody 72 | : multiLineStringLiteral 73 | ; 74 | 75 | multiLineStringLiteral 76 | : TRIPLE_QUOTE_OPEN (multiLineStringContent | MultiLineStringQuote)* TRIPLE_QUOTE_CLOSE 77 | ; 78 | 79 | multiLineStringContent 80 | : MultiLineStrText 81 | ; 82 | 83 | lineStringLiteral 84 | : QUOTE_OPEN (lineStringContent)* QUOTE_CLOSE 85 | ; 86 | 87 | lineStringContent 88 | : LineStrText 89 | | LineStrEscapedChar 90 | ; -------------------------------------------------------------------------------- /src/main/antlr/PseudoAsmLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar PseudoAsmLexer; 2 | 3 | import UnicodeClasses; 4 | 5 | DelimitedComment 6 | : '/*' ( DelimitedComment | . )*? '*/' 7 | -> channel(HIDDEN) 8 | ; 9 | 10 | LineComment 11 | : '//' ~[\u000A\u000D]* 12 | -> channel(HIDDEN) 13 | ; 14 | 15 | WS 16 | : [\u0020\u0009\u000C] 17 | -> skip 18 | ; 19 | 20 | NL: '\u000A' | '\u000D' '\u000A' ; 21 | 22 | DOT: '.' ; 23 | HASH: '#' ; 24 | LANGLE: '<' ; 25 | RANGLE: '>' ; 26 | LPAREN: '(' ; 27 | RPAREN: ')' ; 28 | LSQUARE: '[' ; 29 | RSQUARE: ']' ; 30 | ASSIGNMENT: '=' ; 31 | COMMA: ',' ; 32 | QUEST: '?' ; 33 | AT: '@' ; 34 | ARROW: '->' ; 35 | MOD: '%' ; 36 | DOLLAR: '$' ; 37 | REFERENCE: '*' ; 38 | DEREFERENCE: '&' ; 39 | 40 | QUOTE_OPEN: '"' -> pushMode(LineString) ; 41 | TRIPLE_QUOTE_OPEN: '"""' -> pushMode(MultiLineString) ; 42 | 43 | 44 | fragment HexDigit 45 | : [0-9a-fA-F] 46 | ; 47 | 48 | fragment UniCharacterLiteral 49 | : '\\' 'u' HexDigit HexDigit HexDigit HexDigit 50 | ; 51 | 52 | fragment DecDigit 53 | : UNICODE_CLASS_ND 54 | ; 55 | 56 | fragment DecDigitNoZero 57 | : UNICODE_CLASS_ND_NoZeros 58 | ; 59 | 60 | fragment UNICODE_CLASS_ND_NoZeros 61 | : '\u0031'..'\u0039' 62 | | '\u0661'..'\u0669' 63 | | '\u06f1'..'\u06f9' 64 | | '\u07c1'..'\u07c9' 65 | | '\u0967'..'\u096f' 66 | | '\u09e7'..'\u09ef' 67 | | '\u0a67'..'\u0a6f' 68 | | '\u0ae7'..'\u0aef' 69 | | '\u0b67'..'\u0b6f' 70 | | '\u0be7'..'\u0bef' 71 | | '\u0c67'..'\u0c6f' 72 | | '\u0ce7'..'\u0cef' 73 | | '\u0d67'..'\u0d6f' 74 | | '\u0de7'..'\u0def' 75 | | '\u0e51'..'\u0e59' 76 | | '\u0ed1'..'\u0ed9' 77 | | '\u0f21'..'\u0f29' 78 | | '\u1041'..'\u1049' 79 | | '\u1091'..'\u1099' 80 | | '\u17e1'..'\u17e9' 81 | | '\u1811'..'\u1819' 82 | | '\u1947'..'\u194f' 83 | | '\u19d1'..'\u19d9' 84 | | '\u1a81'..'\u1a89' 85 | | '\u1a91'..'\u1a99' 86 | | '\u1b51'..'\u1b59' 87 | | '\u1bb1'..'\u1bb9' 88 | | '\u1c41'..'\u1c49' 89 | | '\u1c51'..'\u1c59' 90 | | '\ua621'..'\ua629' 91 | | '\ua8d1'..'\ua8d9' 92 | | '\ua901'..'\ua909' 93 | | '\ua9d1'..'\ua9d9' 94 | | '\ua9f1'..'\ua9f9' 95 | | '\uaa51'..'\uaa59' 96 | | '\uabf1'..'\uabf9' 97 | | '\uff11'..'\uff19' 98 | ; 99 | 100 | FloatLiteral 101 | : (DoubleLiteral | IntegerLiteral) [fF] 102 | ; 103 | 104 | DoubleLiteral 105 | : ( (DecDigitNoZero DecDigit*)? '.' 106 | | (DecDigitNoZero (DecDigit | '_')* DecDigit)? '.') 107 | ( DecDigit+ 108 | | DecDigit (DecDigit | '_')+ DecDigit 109 | | DecDigit+ [eE] ('+' | '-')? DecDigit+ 110 | | DecDigit+ [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit 111 | | DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+ 112 | | DecDigit (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit 113 | ) 114 | ; 115 | 116 | 117 | IntegerLiteral 118 | : ('0' 119 | | '-'? DecDigitNoZero DecDigit* 120 | | '-'? DecDigitNoZero (DecDigit | '_')+ DecDigit 121 | | '-'? DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit+ 122 | | '-'? DecDigitNoZero DecDigit* [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit 123 | | '-'? DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit+ 124 | | '-'? DecDigitNoZero (DecDigit | '_')+ DecDigit [eE] ('+' | '-')? DecDigit (DecDigit | '_')+ DecDigit 125 | ) 126 | ; 127 | 128 | Identifier 129 | : (Letter | '_') (Letter | '_' | DecDigit)* 130 | | '`' ~('`')+ '`' 131 | ; 132 | 133 | fragment Letter 134 | : UNICODE_CLASS_LL 135 | | UNICODE_CLASS_LM 136 | | UNICODE_CLASS_LO 137 | | UNICODE_CLASS_LT 138 | | UNICODE_CLASS_LU 139 | | UNICODE_CLASS_NL 140 | ; 141 | 142 | 143 | mode LineString ; 144 | 145 | QUOTE_CLOSE 146 | : '"' -> popMode 147 | ; 148 | 149 | LineStrText 150 | : ~('\\' | '"' | '$')+ | '$' 151 | ; 152 | 153 | LineStrEscapedChar 154 | : '\\' . 155 | | UniCharacterLiteral 156 | ; 157 | 158 | mode MultiLineString ; 159 | 160 | TRIPLE_QUOTE_CLOSE 161 | : MultiLineStringQuote? '"""' -> popMode 162 | ; 163 | 164 | MultiLineStringQuote 165 | : '"'+ 166 | ; 167 | 168 | 169 | MultiLineStrText 170 | : ~('\\' | '"' | '$')+ | '$' 171 | ; 172 | 173 | MultiLineStrEscapedChar 174 | : '\\' . 175 | ; 176 | 177 | MultiLineNL: NL -> skip ; 178 | 179 | StrExpr_TRIPLE_QUOTE_OPEN: TRIPLE_QUOTE_OPEN -> pushMode(MultiLineString), type(TRIPLE_QUOTE_OPEN) ; 180 | StrExpr_QUOTE_OPEN: QUOTE_OPEN -> pushMode(LineString), type(QUOTE_OPEN) ; 181 | 182 | -------------------------------------------------------------------------------- /src/main/antlr/PseudoAsmLexer.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | REFERENCE=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | DEREFERENCE=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | ARROW=33 34 | DOUBLE_ARROW=34 35 | RANGE=35 36 | COLONCOLON=36 37 | Q_COLONCOLON=37 38 | DOUBLE_SEMICOLON=38 39 | HASH=39 40 | AT=40 41 | QUEST=41 42 | ELVIS=42 43 | LANGLE=43 44 | RANGLE=44 45 | LE=45 46 | GE=46 47 | EXCL_EQ=47 48 | EXCL_EQEQ=48 49 | AS_SAFE=49 50 | EQEQ=50 51 | EQEQEQ=51 52 | SINGLE_QUOTE=52 53 | RETURN_AT=53 54 | CONTINUE_AT=54 55 | BREAK_AT=55 56 | FILE=56 57 | PACKAGE=57 58 | IMPORT=58 59 | CLASS=59 60 | INTERFACE=60 61 | FUN=61 62 | OBJECT=62 63 | VAL=63 64 | VAR=64 65 | TYPE_ALIAS=65 66 | CONSTRUCTOR=66 67 | BY=67 68 | COMPANION=68 69 | INIT=69 70 | THIS=70 71 | SUPER=71 72 | TYPEOF=72 73 | WHERE=73 74 | IF=74 75 | ELSE=75 76 | WHEN=76 77 | TRY=77 78 | CATCH=78 79 | FINALLY=79 80 | FOR=80 81 | DO=81 82 | WHILE=82 83 | THROW=83 84 | RETURN=84 85 | CONTINUE=85 86 | BREAK=86 87 | AS=87 88 | IS=88 89 | IN=89 90 | NOT_IS=90 91 | NOT_IN=91 92 | OUT=92 93 | FIELD=93 94 | PROPERTY=94 95 | GET=95 96 | SET=96 97 | GETTER=97 98 | SETTER=98 99 | RECEIVER=99 100 | PARAM=100 101 | SETPARAM=101 102 | DELEGATE=102 103 | DYNAMIC=103 104 | PUBLIC=104 105 | PRIVATE=105 106 | PROTECTED=106 107 | INTERNAL=107 108 | ENUM=108 109 | SEALED=109 110 | ANNOTATION=110 111 | DATA=111 112 | INNER=112 113 | TAILREC=113 114 | OPERATOR=114 115 | INLINE=115 116 | INFIX=116 117 | EXTERNAL=117 118 | SUSPEND=118 119 | OVERRIDE=119 120 | ABSTRACT=120 121 | FINAL=121 122 | OPEN=122 123 | CONST=123 124 | LATEINIT=124 125 | VARARG=125 126 | NOINLINE=126 127 | CROSSINLINE=127 128 | REIFIED=128 129 | QUOTE_OPEN=129 130 | TRIPLE_QUOTE_OPEN=130 131 | RealLiteral=131 132 | FloatLiteral=132 133 | DoubleLiteral=133 134 | LongLiteral=134 135 | IntegerLiteral=135 136 | HexLiteral=136 137 | BinLiteral=137 138 | BooleanLiteral=138 139 | NullLiteral=139 140 | Identifier=140 141 | LabelReference=141 142 | LabelDefinition=142 143 | FieldIdentifier=143 144 | CharacterLiteral=144 145 | UNICODE_CLASS_LL=145 146 | UNICODE_CLASS_LM=146 147 | UNICODE_CLASS_LO=147 148 | UNICODE_CLASS_LT=148 149 | UNICODE_CLASS_LU=149 150 | UNICODE_CLASS_ND=150 151 | UNICODE_CLASS_NL=151 152 | Inside_Comment=152 153 | Inside_WS=153 154 | Inside_NL=154 155 | QUOTE_CLOSE=155 156 | LineStrRef=156 157 | LineStrText=157 158 | LineStrEscapedChar=158 159 | LineStrExprStart=159 160 | TRIPLE_QUOTE_CLOSE=160 161 | MultiLineStringQuote=161 162 | MultiLineStrRef=162 163 | MultiLineStrText=163 164 | MultiLineStrEscapedChar=164 165 | MultiLineStrExprStart=165 166 | MultiLineNL=166 167 | StrExpr_IN=167 168 | StrExpr_Comment=168 169 | StrExpr_WS=169 170 | StrExpr_NL=170 171 | DOLLAR=180 172 | '...'=6 173 | '.'=7 174 | ','=8 175 | '('=9 176 | '['=11 177 | '{'=13 178 | '}'=14 179 | '*'=15 180 | '%'=16 181 | '/'=17 182 | '+'=18 183 | '-'=19 184 | '++'=20 185 | '--'=21 186 | '&'=22 187 | '||'=23 188 | '!'=24 189 | ':'=25 190 | ';'=26 191 | '='=27 192 | '+='=28 193 | '-='=29 194 | '*='=30 195 | '/='=31 196 | '%='=32 197 | '->'=33 198 | '=>'=34 199 | '..'=35 200 | '::'=36 201 | '?::'=37 202 | ';;'=38 203 | '#'=39 204 | '@'=40 205 | '?'=41 206 | '?:'=42 207 | '<'=43 208 | '>'=44 209 | '<='=45 210 | '>='=46 211 | '!='=47 212 | '!=='=48 213 | 'as?'=49 214 | '=='=50 215 | '==='=51 216 | '\''=52 217 | '@file'=56 218 | 'package'=57 219 | 'import'=58 220 | 'class'=59 221 | 'interface'=60 222 | 'fun'=61 223 | 'object'=62 224 | 'val'=63 225 | 'var'=64 226 | 'typealias'=65 227 | 'constructor'=66 228 | 'by'=67 229 | 'companion'=68 230 | 'init'=69 231 | 'this'=70 232 | 'super'=71 233 | 'typeof'=72 234 | 'where'=73 235 | 'if'=74 236 | 'else'=75 237 | 'when'=76 238 | 'try'=77 239 | 'catch'=78 240 | 'finally'=79 241 | 'for'=80 242 | 'do'=81 243 | 'while'=82 244 | 'throw'=83 245 | 'return'=84 246 | 'continue'=85 247 | 'break'=86 248 | 'as'=87 249 | 'is'=88 250 | 'in'=89 251 | 'out'=92 252 | '@field'=93 253 | '@property'=94 254 | '@get'=95 255 | '@set'=96 256 | 'get'=97 257 | 'set'=98 258 | '@receiver'=99 259 | '@param'=100 260 | '@setparam'=101 261 | '@delegate'=102 262 | 'dynamic'=103 263 | 'public'=104 264 | 'private'=105 265 | 'protected'=106 266 | 'internal'=107 267 | 'enum'=108 268 | 'sealed'=109 269 | 'annotation'=110 270 | 'data'=111 271 | 'inner'=112 272 | 'tailrec'=113 273 | 'operator'=114 274 | 'inline'=115 275 | 'infix'=116 276 | 'external'=117 277 | 'suspend'=118 278 | 'override'=119 279 | 'abstract'=120 280 | 'final'=121 281 | 'open'=122 282 | 'const'=123 283 | 'lateinit'=124 284 | 'vararg'=125 285 | 'noinline'=126 286 | 'crossinline'=127 287 | 'reified'=128 288 | '"""'=130 289 | 'null'=139 290 | '$'=180 291 | -------------------------------------------------------------------------------- /src/main/antlr/PseudoAsmParser.g4: -------------------------------------------------------------------------------- 1 | parser grammar PseudoAsmParser; 2 | 3 | options { tokenVocab = PseudoAsmLexer; } 4 | 5 | pseudoAsmFile 6 | : NL* (linia NL*)* EOF 7 | ; 8 | 9 | jocker 10 | : QUEST simpleIdentifier; 11 | 12 | referencer 13 | : (REFERENCE | DEREFERENCE); 14 | 15 | operand 16 | : referencer* value name* typeName*; 17 | 18 | value 19 | : (addressed | immediate | floatimmediate | stringimmediate ); 20 | 21 | addressed 22 | : (jocker | absAddress | identifier) (LPAREN index RPAREN)*; 23 | 24 | index 25 | : (jocker | IntegerLiteral); 26 | 27 | immediate 28 | : HASH (jocker | IntegerLiteral | identifier); 29 | 30 | floatimmediate 31 | : MOD (jocker | DoubleLiteral); 32 | 33 | stringimmediate 34 | : DOLLAR (jocker | lineStringLiteral); 35 | 36 | absAddress 37 | : IntegerLiteral; 38 | 39 | name 40 | : LANGLE identifier RANGLE 41 | ; 42 | 43 | typeName 44 | : LSQUARE (jocker | identifier) referencer* RSQUARE 45 | ; 46 | 47 | instrukcja 48 | : simpleIdentifier 49 | ; 50 | 51 | linia 52 | : instrukcja (target ASSIGNMENT (arg (COMMA arg)*))* (ARROW assemblerBody)* NL 53 | | instrukcja arg (COMMA arg)* (ARROW assemblerBody)* NL 54 | ; 55 | 56 | target 57 | : operand 58 | ; 59 | 60 | arg 61 | : operand 62 | ; 63 | 64 | 65 | identifier 66 | : simpleIdentifier (NL* DOT simpleIdentifier*)* 67 | ; 68 | 69 | simpleIdentifier 70 | : Identifier 71 | ; 72 | 73 | 74 | //semi: NL+ | NL* SEMICOLON NL*; 75 | 76 | //anysemi: NL | SEMICOLON; 77 | 78 | assemblerBody 79 | : multiLineStringLiteral 80 | ; 81 | 82 | multiLineStringLiteral 83 | : TRIPLE_QUOTE_OPEN (multiLineStringContent | MultiLineStringQuote)* TRIPLE_QUOTE_CLOSE 84 | ; 85 | 86 | multiLineStringContent 87 | : MultiLineStrText 88 | ; 89 | 90 | lineStringLiteral 91 | : QUOTE_OPEN (lineStringContent)* QUOTE_CLOSE 92 | ; 93 | 94 | lineStringContent 95 | : LineStrText 96 | | LineStrEscapedChar 97 | ; -------------------------------------------------------------------------------- /src/main/gen/KotlinLexer.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | MULT=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | CONJ=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | BIT_ASSIGNMENT=33 34 | BIT_DEASSIGNMENT=34 35 | ARROW=35 36 | DOUBLE_ARROW=36 37 | RANGE=37 38 | COLONCOLON=38 39 | Q_COLONCOLON=39 40 | DOUBLE_SEMICOLON=40 41 | HASH=41 42 | AT=42 43 | CARON=43 44 | QUEST=44 45 | ELVIS=45 46 | LANGLE=46 47 | RANGLE=47 48 | LE=48 49 | GE=49 50 | EXCL_EQ=50 51 | EXCL_EQEQ=51 52 | AS_SAFE=52 53 | EQEQ=53 54 | EQEQEQ=54 55 | SINGLE_QUOTE=55 56 | BIT_OR=56 57 | BIT_AND=57 58 | BIT_OR_ASSIGNMENT=58 59 | BIT_AND_ASSIGNMENT=59 60 | RETURN_AT=60 61 | CONTINUE_AT=61 62 | BREAK_AT=62 63 | FILE=63 64 | PACKAGE=64 65 | IMPORT=65 66 | CLASS=66 67 | INTERFACE=67 68 | FUN=68 69 | OBJECT=69 70 | VAL=70 71 | VAR=71 72 | TYPE_ALIAS=72 73 | CONSTRUCTOR=73 74 | BY=74 75 | COMPANION=75 76 | INIT=76 77 | THIS=77 78 | SUPER=78 79 | TYPEOF=79 80 | WHERE=80 81 | IF=81 82 | ELSE=82 83 | WHEN=83 84 | TRY=84 85 | CATCH=85 86 | FINALLY=86 87 | FOR=87 88 | DO=88 89 | WHILE=89 90 | THROW=90 91 | RETURN=91 92 | CONTINUE=92 93 | BREAK=93 94 | AS=94 95 | IS=95 96 | IN=96 97 | NOT_IS=97 98 | NOT_IN=98 99 | OUT=99 100 | FIELD=100 101 | PROPERTY=101 102 | GET=102 103 | SET=103 104 | GETTER=104 105 | SETTER=105 106 | RECEIVER=106 107 | PARAM=107 108 | SETPARAM=108 109 | DELEGATE=109 110 | DYNAMIC=110 111 | PUBLIC=111 112 | PRIVATE=112 113 | PROTECTED=113 114 | INTERNAL=114 115 | ENUM=115 116 | SEALED=116 117 | ANNOTATION=117 118 | DATA=118 119 | INNER=119 120 | TAILREC=120 121 | OPERATOR=121 122 | INLINE=122 123 | INFIX=123 124 | EXTERNAL=124 125 | SUSPEND=125 126 | INTERRUPT=126 127 | CC65=127 128 | OVERRIDE=128 129 | ABSTRACT=129 130 | FINAL=130 131 | OPEN=131 132 | CONST=132 133 | LATEINIT=133 134 | VARARG=134 135 | NOINLINE=135 136 | CROSSINLINE=136 137 | REIFIED=137 138 | QUOTE_OPEN=138 139 | TRIPLE_QUOTE_OPEN=139 140 | RealLiteral=140 141 | FloatLiteral=141 142 | DoubleLiteral=142 143 | LongLiteral=143 144 | IntegerLiteral=144 145 | HexLiteral=145 146 | BinLiteral=146 147 | BooleanLiteral=147 148 | NullLiteral=148 149 | Identifier=149 150 | LabelReference=150 151 | LabelDefinition=151 152 | FieldIdentifier=152 153 | CharacterLiteral=153 154 | UNICODE_CLASS_LL=154 155 | UNICODE_CLASS_LM=155 156 | UNICODE_CLASS_LO=156 157 | UNICODE_CLASS_LT=157 158 | UNICODE_CLASS_LU=158 159 | UNICODE_CLASS_ND=159 160 | UNICODE_CLASS_NL=160 161 | Inside_Comment=161 162 | Inside_WS=162 163 | Inside_NL=163 164 | QUOTE_CLOSE=164 165 | LineStrRef=165 166 | LineStrText=166 167 | LineStrEscapedChar=167 168 | LineStrExprStart=168 169 | TRIPLE_QUOTE_CLOSE=169 170 | MultiLineStringQuote=170 171 | MultiLineStrRef=171 172 | MultiLineStrText=172 173 | MultiLineStrEscapedChar=173 174 | MultiLineStrExprStart=174 175 | MultiLineNL=175 176 | StrExpr_IN=176 177 | StrExpr_Comment=177 178 | StrExpr_WS=178 179 | StrExpr_NL=179 180 | '...'=6 181 | '.'=7 182 | ','=8 183 | '('=9 184 | '['=11 185 | '{'=13 186 | '}'=14 187 | '*'=15 188 | '%'=16 189 | '/'=17 190 | '+'=18 191 | '-'=19 192 | '++'=20 193 | '--'=21 194 | '&&'=22 195 | '||'=23 196 | '!'=24 197 | ':'=25 198 | ';'=26 199 | '='=27 200 | '+='=28 201 | '-='=29 202 | '*='=30 203 | '/='=31 204 | '%='=32 205 | ':='=33 206 | '.='=34 207 | '->'=35 208 | '=>'=36 209 | '..'=37 210 | '::'=38 211 | '?::'=39 212 | ';;'=40 213 | '#'=41 214 | '@'=42 215 | '^'=43 216 | '?'=44 217 | '?:'=45 218 | '<'=46 219 | '>'=47 220 | '<='=48 221 | '>='=49 222 | '!='=50 223 | '!=='=51 224 | 'as?'=52 225 | '=='=53 226 | '==='=54 227 | '\''=55 228 | '|'=56 229 | '&'=57 230 | '|='=58 231 | '&='=59 232 | '@file'=63 233 | 'package'=64 234 | 'import'=65 235 | 'class'=66 236 | 'interface'=67 237 | 'fun'=68 238 | 'object'=69 239 | 'val'=70 240 | 'var'=71 241 | 'typealias'=72 242 | 'constructor'=73 243 | 'by'=74 244 | 'companion'=75 245 | 'init'=76 246 | 'this'=77 247 | 'super'=78 248 | 'typeof'=79 249 | 'where'=80 250 | 'if'=81 251 | 'else'=82 252 | 'when'=83 253 | 'try'=84 254 | 'catch'=85 255 | 'finally'=86 256 | 'for'=87 257 | 'do'=88 258 | 'while'=89 259 | 'throw'=90 260 | 'return'=91 261 | 'continue'=92 262 | 'break'=93 263 | 'as'=94 264 | 'is'=95 265 | 'in'=96 266 | 'out'=99 267 | '@field'=100 268 | '@property'=101 269 | '@get'=102 270 | '@set'=103 271 | 'get'=104 272 | 'set'=105 273 | '@receiver'=106 274 | '@param'=107 275 | '@setparam'=108 276 | '@delegate'=109 277 | 'dynamic'=110 278 | 'public'=111 279 | 'private'=112 280 | 'protected'=113 281 | 'internal'=114 282 | 'enum'=115 283 | 'sealed'=116 284 | 'annotation'=117 285 | 'data'=118 286 | 'inner'=119 287 | 'tailrec'=120 288 | 'operator'=121 289 | 'inline'=122 290 | 'infix'=123 291 | 'external'=124 292 | 'suspend'=125 293 | 'interrupt'=126 294 | 'cc65'=127 295 | 'override'=128 296 | 'abstract'=129 297 | 'final'=130 298 | 'open'=131 299 | 'const'=132 300 | 'lateinit'=133 301 | 'vararg'=134 302 | 'noinline'=135 303 | 'crossinline'=136 304 | 'reified'=137 305 | '"""'=139 306 | 'null'=148 307 | -------------------------------------------------------------------------------- /src/main/gen/KotlinParser.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | MULT=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | CONJ=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | BIT_ASSIGNMENT=300 34 | BIT_DEASSIGNMENT=300 35 | BIT_OR=301 36 | BIT_AND=302 37 | BIT_OR_ASSIGNMENT=303 38 | BIT_AND_ASSIGNMENT=304 39 | ARROW=33 40 | DOUBLE_ARROW=34 41 | RANGE=35 42 | CARON=200 43 | COLONCOLON=36 44 | Q_COLONCOLON=37 45 | DOUBLE_SEMICOLON=38 46 | HASH=39 47 | AT=40 48 | QUEST=41 49 | ELVIS=42 50 | LANGLE=43 51 | RANGLE=44 52 | LE=45 53 | GE=46 54 | EXCL_EQ=47 55 | EXCL_EQEQ=48 56 | AS_SAFE=49 57 | EQEQ=50 58 | EQEQEQ=51 59 | SINGLE_QUOTE=52 60 | RETURN_AT=53 61 | CONTINUE_AT=54 62 | BREAK_AT=55 63 | FILE=56 64 | PACKAGE=57 65 | IMPORT=58 66 | CLASS=59 67 | INTERFACE=60 68 | FUN=61 69 | OBJECT=62 70 | VAL=63 71 | VAR=64 72 | TYPE_ALIAS=65 73 | CONSTRUCTOR=66 74 | BY=67 75 | COMPANION=68 76 | INIT=69 77 | THIS=70 78 | SUPER=71 79 | TYPEOF=72 80 | WHERE=73 81 | IF=74 82 | ELSE=75 83 | WHEN=76 84 | TRY=77 85 | CATCH=78 86 | FINALLY=79 87 | FOR=80 88 | DO=81 89 | WHILE=82 90 | THROW=83 91 | RETURN=84 92 | CONTINUE=85 93 | BREAK=86 94 | AS=87 95 | IS=88 96 | IN=89 97 | NOT_IS=90 98 | NOT_IN=91 99 | OUT=92 100 | FIELD=93 101 | PROPERTY=94 102 | GET=95 103 | SET=96 104 | GETTER=97 105 | SETTER=98 106 | RECEIVER=99 107 | PARAM=100 108 | SETPARAM=101 109 | DELEGATE=102 110 | DYNAMIC=103 111 | PUBLIC=104 112 | PRIVATE=105 113 | PROTECTED=106 114 | INTERNAL=107 115 | ENUM=108 116 | SEALED=109 117 | ANNOTATION=110 118 | DATA=111 119 | INNER=112 120 | TAILREC=113 121 | OPERATOR=114 122 | INLINE=115 123 | INFIX=116 124 | EXTERNAL=117 125 | SUSPEND=118 126 | OVERRIDE=119 127 | ABSTRACT=120 128 | FINAL=121 129 | OPEN=122 130 | CONST=123 131 | LATEINIT=124 132 | VARARG=125 133 | NOINLINE=126 134 | CROSSINLINE=127 135 | REIFIED=128 136 | QUOTE_OPEN=129 137 | TRIPLE_QUOTE_OPEN=130 138 | RealLiteral=131 139 | FloatLiteral=132 140 | DoubleLiteral=133 141 | LongLiteral=134 142 | IntegerLiteral=135 143 | HexLiteral=136 144 | BinLiteral=137 145 | BooleanLiteral=138 146 | NullLiteral=139 147 | Identifier=140 148 | LabelReference=141 149 | LabelDefinition=142 150 | FieldIdentifier=143 151 | CharacterLiteral=144 152 | UNICODE_CLASS_LL=145 153 | UNICODE_CLASS_LM=146 154 | UNICODE_CLASS_LO=147 155 | UNICODE_CLASS_LT=148 156 | UNICODE_CLASS_LU=149 157 | UNICODE_CLASS_ND=150 158 | UNICODE_CLASS_NL=151 159 | Inside_Comment=152 160 | Inside_WS=153 161 | Inside_NL=154 162 | QUOTE_CLOSE=155 163 | LineStrRef=156 164 | LineStrText=157 165 | LineStrEscapedChar=158 166 | LineStrExprStart=159 167 | TRIPLE_QUOTE_CLOSE=160 168 | MultiLineStringQuote=161 169 | MultiLineStrRef=162 170 | MultiLineStrText=163 171 | MultiLineStrEscapedChar=164 172 | MultiLineStrExprStart=165 173 | MultiLineNL=166 174 | StrExpr_IN=167 175 | StrExpr_Comment=168 176 | StrExpr_WS=169 177 | StrExpr_NL=170 178 | INTERRUPT=171 179 | ASSEMBLER_INSTRUCTION=500 180 | ASMSTRING=501 181 | ASMNAME=502 182 | ASMNUMBER=503 183 | ASMCOMMENT=504 184 | ADC=505 185 | AND=506 186 | ASL=507 187 | BCC=508 188 | BCS=509 189 | BEQ=510 190 | BIT=511 191 | BMI=512 192 | BNE=513 193 | BPL=514 194 | BRA=515 195 | BRK=516 196 | BVC=517 197 | BVS=518 198 | CLC=519 199 | CLD=520 200 | CLI=521 201 | CLV=522 202 | CMP=523 203 | CPX=524 204 | CPY=525 205 | DEC=526 206 | DEX=527 207 | DEY=528 208 | EOR=529 209 | INC=530 210 | INX=531 211 | INY=532 212 | JMP=533 213 | JSR=534 214 | LDA=535 215 | LDY=536 216 | LDX=537 217 | LSR=538 218 | NOP=539 219 | ORA=540 220 | PHA=541 221 | PHX=542 222 | PHY=543 223 | PHP=544 224 | PLA=545 225 | PLP=546 226 | PLY=547 227 | ROL=548 228 | ROR=549 229 | RTI=550 230 | RTS=551 231 | SBC=552 232 | SEC=553 233 | SED=554 234 | SEI=555 235 | STA=556 236 | STX=557 237 | STY=558 238 | STZ=559 239 | TAX=560 240 | TAY=561 241 | TSX=562 242 | TXA=563 243 | TXS=564 244 | TYA=565 245 | '...'=6 246 | '.'=7 247 | ','=8 248 | '('=9 249 | '['=11 250 | '{'=13 251 | '}'=14 252 | '*'=15 253 | '%'=16 254 | '/'=17 255 | '+'=18 256 | '-'=19 257 | '++'=20 258 | '--'=21 259 | '&&'=22 260 | '||'=23 261 | '!'=24 262 | ':'=25 263 | ';'=26 264 | '='=27 265 | '+='=28 266 | '-='=29 267 | '*='=30 268 | '/='=31 269 | '%='=32 270 | '->'=33 271 | '=>'=34 272 | '..'=35 273 | '::'=36 274 | '?::'=37 275 | ';;'=38 276 | '#'=39 277 | '@'=40 278 | '?'=41 279 | '?:'=42 280 | '<'=43 281 | '>'=44 282 | '<='=45 283 | '>='=46 284 | '!='=47 285 | '!=='=48 286 | 'as?'=49 287 | '=='=50 288 | '==='=51 289 | '\''=52 290 | '@file'=56 291 | 'package'=57 292 | 'import'=58 293 | 'class'=59 294 | 'interface'=60 295 | 'fun'=61 296 | 'object'=62 297 | 'val'=63 298 | 'var'=64 299 | 'typealias'=65 300 | 'constructor'=66 301 | 'by'=67 302 | 'companion'=68 303 | 'init'=69 304 | 'this'=70 305 | 'super'=71 306 | 'typeof'=72 307 | 'where'=73 308 | 'if'=74 309 | 'else'=75 310 | 'when'=76 311 | 'try'=77 312 | 'catch'=78 313 | 'finally'=79 314 | 'for'=80 315 | 'do'=81 316 | 'while'=82 317 | 'throw'=83 318 | 'return'=84 319 | 'continue'=85 320 | 'break'=86 321 | 'as'=87 322 | 'is'=88 323 | 'in'=89 324 | 'out'=92 325 | '@field'=93 326 | '@property'=94 327 | '@get'=95 328 | '@set'=96 329 | 'get'=97 330 | 'set'=98 331 | '@receiver'=99 332 | '@param'=100 333 | '@setparam'=101 334 | '@delegate'=102 335 | 'dynamic'=103 336 | 'public'=104 337 | 'private'=105 338 | 'protected'=106 339 | 'internal'=107 340 | 'enum'=108 341 | 'sealed'=109 342 | 'annotation'=110 343 | 'data'=111 344 | 'inner'=112 345 | 'tailrec'=113 346 | 'operator'=114 347 | 'inline'=115 348 | 'infix'=116 349 | 'external'=117 350 | 'suspend'=118 351 | 'override'=119 352 | 'abstract'=120 353 | 'final'=121 354 | 'open'=122 355 | 'const'=123 356 | 'lateinit'=124 357 | 'vararg'=125 358 | 'noinline'=126 359 | 'crossinline'=127 360 | 'reified'=128 361 | '"""'=130 362 | 'null'=139 363 | 'interrupt'=171 364 | -------------------------------------------------------------------------------- /src/main/gen/MegaAsmLexer.tokens: -------------------------------------------------------------------------------- 1 | DelimitedComment=1 2 | LineComment=2 3 | WS=3 4 | NL=4 5 | DOT=5 6 | HASH=6 7 | LPAREN=7 8 | RPAREN=8 9 | LSQUARE=9 10 | RSQUARE=10 11 | ASSIGNMENT=11 12 | COMMA=12 13 | QUEST=13 14 | AT=14 15 | ARROW=15 16 | MOD=16 17 | DOLLAR=17 18 | REFERENCE=18 19 | DEREFERENCE=19 20 | COLON=20 21 | QUOTE_OPEN=21 22 | TRIPLE_QUOTE_OPEN=22 23 | FloatLiteral=23 24 | DoubleLiteral=24 25 | IntegerLiteral=25 26 | Identifier=26 27 | Operator=27 28 | UNICODE_CLASS_LL=28 29 | UNICODE_CLASS_LM=29 30 | UNICODE_CLASS_LO=30 31 | UNICODE_CLASS_LT=31 32 | UNICODE_CLASS_LU=32 33 | UNICODE_CLASS_ND=33 34 | UNICODE_CLASS_NL=34 35 | QUOTE_CLOSE=35 36 | LineStrText=36 37 | LineStrEscapedChar=37 38 | TRIPLE_QUOTE_CLOSE=38 39 | MultiLineStringQuote=39 40 | MultiLineStrText=40 41 | MultiLineStrEscapedChar=41 42 | MultiLineNL=42 43 | '.'=5 44 | '#'=6 45 | '('=7 46 | ')'=8 47 | '['=9 48 | ']'=10 49 | '='=11 50 | ','=12 51 | '?'=13 52 | '@'=14 53 | '->'=15 54 | '%'=16 55 | '$'=17 56 | '*'=18 57 | '&'=19 58 | ':'=20 59 | '"""'=22 60 | -------------------------------------------------------------------------------- /src/main/gen/MegaAsmParser.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | REFERENCE=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | DEREFERENCE=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | ARROW=33 34 | DOUBLE_ARROW=34 35 | RANGE=35 36 | COLONCOLON=36 37 | Q_COLONCOLON=37 38 | DOUBLE_SEMICOLON=38 39 | HASH=39 40 | AT=40 41 | QUEST=41 42 | ELVIS=42 43 | LE=45 44 | GE=46 45 | EXCL_EQ=47 46 | EXCL_EQEQ=48 47 | AS_SAFE=49 48 | EQEQ=50 49 | EQEQEQ=51 50 | SINGLE_QUOTE=52 51 | RETURN_AT=53 52 | CONTINUE_AT=54 53 | BREAK_AT=55 54 | FILE=56 55 | PACKAGE=57 56 | IMPORT=58 57 | CLASS=59 58 | INTERFACE=60 59 | FUN=61 60 | OBJECT=62 61 | VAL=63 62 | VAR=64 63 | TYPE_ALIAS=65 64 | CONSTRUCTOR=66 65 | BY=67 66 | COMPANION=68 67 | INIT=69 68 | THIS=70 69 | SUPER=71 70 | TYPEOF=72 71 | WHERE=73 72 | IF=74 73 | ELSE=75 74 | WHEN=76 75 | TRY=77 76 | CATCH=78 77 | FINALLY=79 78 | FOR=80 79 | DO=81 80 | WHILE=82 81 | THROW=83 82 | RETURN=84 83 | CONTINUE=85 84 | BREAK=86 85 | AS=87 86 | IS=88 87 | IN=89 88 | NOT_IS=90 89 | NOT_IN=91 90 | OUT=92 91 | FIELD=93 92 | PROPERTY=94 93 | GET=95 94 | SET=96 95 | GETTER=97 96 | SETTER=98 97 | RECEIVER=99 98 | PARAM=100 99 | SETPARAM=101 100 | DELEGATE=102 101 | DYNAMIC=103 102 | PUBLIC=104 103 | PRIVATE=105 104 | PROTECTED=106 105 | INTERNAL=107 106 | ENUM=108 107 | SEALED=109 108 | ANNOTATION=110 109 | DATA=111 110 | INNER=112 111 | TAILREC=113 112 | OPERATOR=114 113 | INLINE=115 114 | INFIX=116 115 | EXTERNAL=117 116 | SUSPEND=118 117 | OVERRIDE=119 118 | ABSTRACT=120 119 | FINAL=121 120 | OPEN=122 121 | CONST=123 122 | LATEINIT=124 123 | VARARG=125 124 | NOINLINE=126 125 | CROSSINLINE=127 126 | REIFIED=128 127 | QUOTE_OPEN=129 128 | TRIPLE_QUOTE_OPEN=130 129 | RealLiteral=131 130 | FloatLiteral=132 131 | DoubleLiteral=133 132 | LongLiteral=134 133 | IntegerLiteral=135 134 | HexLiteral=136 135 | BinLiteral=137 136 | BooleanLiteral=138 137 | NullLiteral=139 138 | Identifier=140 139 | LabelReference=141 140 | LabelDefinition=142 141 | FieldIdentifier=143 142 | CharacterLiteral=144 143 | UNICODE_CLASS_LL=145 144 | UNICODE_CLASS_LM=146 145 | UNICODE_CLASS_LO=147 146 | UNICODE_CLASS_LT=148 147 | UNICODE_CLASS_LU=149 148 | UNICODE_CLASS_ND=150 149 | UNICODE_CLASS_NL=151 150 | Inside_Comment=152 151 | Inside_WS=153 152 | Inside_NL=154 153 | QUOTE_CLOSE=155 154 | LineStrRef=156 155 | LineStrText=157 156 | LineStrEscapedChar=158 157 | LineStrExprStart=159 158 | TRIPLE_QUOTE_CLOSE=160 159 | MultiLineStringQuote=161 160 | MultiLineStrRef=162 161 | MultiLineStrText=163 162 | MultiLineStrEscapedChar=164 163 | MultiLineStrExprStart=165 164 | MultiLineNL=166 165 | StrExpr_IN=167 166 | StrExpr_Comment=168 167 | StrExpr_WS=169 168 | StrExpr_NL=170 169 | DOLLAR=180 170 | Operator=181 171 | '...'=6 172 | '.'=7 173 | ','=8 174 | '('=9 175 | '['=11 176 | '{'=13 177 | '}'=14 178 | '*'=15 179 | '%'=16 180 | '/'=17 181 | '+'=18 182 | '-'=19 183 | '++'=20 184 | '--'=21 185 | '&'=22 186 | '||'=23 187 | '!'=24 188 | ':'=25 189 | ';'=26 190 | '='=27 191 | '+='=28 192 | '-='=29 193 | '*='=30 194 | '/='=31 195 | '%='=32 196 | '->'=33 197 | '=>'=34 198 | '..'=35 199 | '::'=36 200 | '?::'=37 201 | ';;'=38 202 | '#'=39 203 | '@'=40 204 | '?'=41 205 | '?:'=42 206 | '<'=43 207 | '>'=44 208 | '<='=45 209 | '>='=46 210 | '!='=47 211 | '!=='=48 212 | 'as?'=49 213 | '=='=50 214 | '==='=51 215 | '\''=52 216 | '@file'=56 217 | 'package'=57 218 | 'import'=58 219 | 'class'=59 220 | 'interface'=60 221 | 'fun'=61 222 | 'object'=62 223 | 'val'=63 224 | 'var'=64 225 | 'typealias'=65 226 | 'constructor'=66 227 | 'by'=67 228 | 'companion'=68 229 | 'init'=69 230 | 'this'=70 231 | 'super'=71 232 | 'typeof'=72 233 | 'where'=73 234 | 'if'=74 235 | 'else'=75 236 | 'when'=76 237 | 'try'=77 238 | 'catch'=78 239 | 'finally'=79 240 | 'for'=80 241 | 'do'=81 242 | 'while'=82 243 | 'throw'=83 244 | 'return'=84 245 | 'continue'=85 246 | 'break'=86 247 | 'as'=87 248 | 'is'=88 249 | 'in'=89 250 | 'out'=92 251 | '@field'=93 252 | '@property'=94 253 | '@get'=95 254 | '@set'=96 255 | 'get'=97 256 | 'set'=98 257 | '@receiver'=99 258 | '@param'=100 259 | '@setparam'=101 260 | '@delegate'=102 261 | 'dynamic'=103 262 | 'public'=104 263 | 'private'=105 264 | 'protected'=106 265 | 'internal'=107 266 | 'enum'=108 267 | 'sealed'=109 268 | 'annotation'=110 269 | 'data'=111 270 | 'const'=123 271 | 'lateinit'=124 272 | 'vararg'=125 273 | 'noinline'=126 274 | 'crossinline'=127 275 | 'reified'=128 276 | '"""'=130 277 | 'null'=139 278 | '$'=180 279 | -------------------------------------------------------------------------------- /src/main/gen/MegaAsmParserBaseVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from D:/Projekty/kotlinek/src/main/antlr\MegaAsmParser.g4 by ANTLR 4.8 2 | import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; 3 | 4 | /** 5 | * This class provides an empty implementation of {@link MegaAsmParserVisitor}, 6 | * which can be extended to create a visitor which only needs to handle a subset 7 | * of the available methods. 8 | * 9 | * @param The return type of the visit operation. Use {@link Void} for 10 | * operations with no return type. 11 | */ 12 | public class MegaAsmParserBaseVisitor extends AbstractParseTreeVisitor implements MegaAsmParserVisitor { 13 | /** 14 | * {@inheritDoc} 15 | * 16 | *

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

18 | */ 19 | @Override public T visitPseudoAsmFile(MegaAsmParser.PseudoAsmFileContext ctx) { return visitChildren(ctx); } 20 | /** 21 | * {@inheritDoc} 22 | * 23 | *

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

25 | */ 26 | @Override public T visitReferencer(MegaAsmParser.ReferencerContext ctx) { return visitChildren(ctx); } 27 | /** 28 | * {@inheritDoc} 29 | * 30 | *

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

32 | */ 33 | @Override public T visitOperand(MegaAsmParser.OperandContext ctx) { return visitChildren(ctx); } 34 | /** 35 | * {@inheritDoc} 36 | * 37 | *

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

39 | */ 40 | @Override public T visitValue(MegaAsmParser.ValueContext ctx) { return visitChildren(ctx); } 41 | /** 42 | * {@inheritDoc} 43 | * 44 | *

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

46 | */ 47 | @Override public T visitAddressed(MegaAsmParser.AddressedContext ctx) { return visitChildren(ctx); } 48 | /** 49 | * {@inheritDoc} 50 | * 51 | *

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

53 | */ 54 | @Override public T visitIndex(MegaAsmParser.IndexContext ctx) { return visitChildren(ctx); } 55 | /** 56 | * {@inheritDoc} 57 | * 58 | *

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

60 | */ 61 | @Override public T visitImmediate(MegaAsmParser.ImmediateContext ctx) { return visitChildren(ctx); } 62 | /** 63 | * {@inheritDoc} 64 | * 65 | *

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

67 | */ 68 | @Override public T visitFloatimmediate(MegaAsmParser.FloatimmediateContext ctx) { return visitChildren(ctx); } 69 | /** 70 | * {@inheritDoc} 71 | * 72 | *

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

74 | */ 75 | @Override public T visitStringimmediate(MegaAsmParser.StringimmediateContext ctx) { return visitChildren(ctx); } 76 | /** 77 | * {@inheritDoc} 78 | * 79 | *

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

81 | */ 82 | @Override public T visitAbsAddress(MegaAsmParser.AbsAddressContext ctx) { return visitChildren(ctx); } 83 | /** 84 | * {@inheritDoc} 85 | * 86 | *

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

88 | */ 89 | @Override public T visitTypeName(MegaAsmParser.TypeNameContext ctx) { return visitChildren(ctx); } 90 | /** 91 | * {@inheritDoc} 92 | * 93 | *

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

95 | */ 96 | @Override public T visitInstrukcja(MegaAsmParser.InstrukcjaContext ctx) { return visitChildren(ctx); } 97 | /** 98 | * {@inheritDoc} 99 | * 100 | *

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

102 | */ 103 | @Override public T visitLinia(MegaAsmParser.LiniaContext ctx) { return visitChildren(ctx); } 104 | /** 105 | * {@inheritDoc} 106 | * 107 | *

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

109 | */ 110 | @Override public T visitTarget(MegaAsmParser.TargetContext ctx) { return visitChildren(ctx); } 111 | /** 112 | * {@inheritDoc} 113 | * 114 | *

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

116 | */ 117 | @Override public T visitArg(MegaAsmParser.ArgContext ctx) { return visitChildren(ctx); } 118 | /** 119 | * {@inheritDoc} 120 | * 121 | *

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

123 | */ 124 | @Override public T visitIdentifier(MegaAsmParser.IdentifierContext ctx) { return visitChildren(ctx); } 125 | /** 126 | * {@inheritDoc} 127 | * 128 | *

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

130 | */ 131 | @Override public T visitSimpleIdentifier(MegaAsmParser.SimpleIdentifierContext ctx) { return visitChildren(ctx); } 132 | /** 133 | * {@inheritDoc} 134 | * 135 | *

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

137 | */ 138 | @Override public T visitAssemblerBody(MegaAsmParser.AssemblerBodyContext ctx) { return visitChildren(ctx); } 139 | /** 140 | * {@inheritDoc} 141 | * 142 | *

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

144 | */ 145 | @Override public T visitMultiLineStringLiteral(MegaAsmParser.MultiLineStringLiteralContext ctx) { return visitChildren(ctx); } 146 | /** 147 | * {@inheritDoc} 148 | * 149 | *

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

151 | */ 152 | @Override public T visitMultiLineStringContent(MegaAsmParser.MultiLineStringContentContext ctx) { return visitChildren(ctx); } 153 | /** 154 | * {@inheritDoc} 155 | * 156 | *

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

158 | */ 159 | @Override public T visitLineStringLiteral(MegaAsmParser.LineStringLiteralContext ctx) { return visitChildren(ctx); } 160 | /** 161 | * {@inheritDoc} 162 | * 163 | *

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

165 | */ 166 | @Override public T visitLineStringContent(MegaAsmParser.LineStringContentContext ctx) { return visitChildren(ctx); } 167 | } -------------------------------------------------------------------------------- /src/main/gen/MegaAsmParserVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from D:/Projekty/kotlinek/src/main/antlr\MegaAsmParser.g4 by ANTLR 4.8 2 | import org.antlr.v4.runtime.tree.ParseTreeVisitor; 3 | 4 | /** 5 | * This interface defines a complete generic visitor for a parse tree produced 6 | * by {@link MegaAsmParser}. 7 | * 8 | * @param The return type of the visit operation. Use {@link Void} for 9 | * operations with no return type. 10 | */ 11 | public interface MegaAsmParserVisitor extends ParseTreeVisitor { 12 | /** 13 | * Visit a parse tree produced by {@link MegaAsmParser#pseudoAsmFile}. 14 | * @param ctx the parse tree 15 | * @return the visitor result 16 | */ 17 | T visitPseudoAsmFile(MegaAsmParser.PseudoAsmFileContext ctx); 18 | /** 19 | * Visit a parse tree produced by {@link MegaAsmParser#referencer}. 20 | * @param ctx the parse tree 21 | * @return the visitor result 22 | */ 23 | T visitReferencer(MegaAsmParser.ReferencerContext ctx); 24 | /** 25 | * Visit a parse tree produced by {@link MegaAsmParser#operand}. 26 | * @param ctx the parse tree 27 | * @return the visitor result 28 | */ 29 | T visitOperand(MegaAsmParser.OperandContext ctx); 30 | /** 31 | * Visit a parse tree produced by {@link MegaAsmParser#value}. 32 | * @param ctx the parse tree 33 | * @return the visitor result 34 | */ 35 | T visitValue(MegaAsmParser.ValueContext ctx); 36 | /** 37 | * Visit a parse tree produced by {@link MegaAsmParser#addressed}. 38 | * @param ctx the parse tree 39 | * @return the visitor result 40 | */ 41 | T visitAddressed(MegaAsmParser.AddressedContext ctx); 42 | /** 43 | * Visit a parse tree produced by {@link MegaAsmParser#index}. 44 | * @param ctx the parse tree 45 | * @return the visitor result 46 | */ 47 | T visitIndex(MegaAsmParser.IndexContext ctx); 48 | /** 49 | * Visit a parse tree produced by {@link MegaAsmParser#immediate}. 50 | * @param ctx the parse tree 51 | * @return the visitor result 52 | */ 53 | T visitImmediate(MegaAsmParser.ImmediateContext ctx); 54 | /** 55 | * Visit a parse tree produced by {@link MegaAsmParser#floatimmediate}. 56 | * @param ctx the parse tree 57 | * @return the visitor result 58 | */ 59 | T visitFloatimmediate(MegaAsmParser.FloatimmediateContext ctx); 60 | /** 61 | * Visit a parse tree produced by {@link MegaAsmParser#stringimmediate}. 62 | * @param ctx the parse tree 63 | * @return the visitor result 64 | */ 65 | T visitStringimmediate(MegaAsmParser.StringimmediateContext ctx); 66 | /** 67 | * Visit a parse tree produced by {@link MegaAsmParser#absAddress}. 68 | * @param ctx the parse tree 69 | * @return the visitor result 70 | */ 71 | T visitAbsAddress(MegaAsmParser.AbsAddressContext ctx); 72 | /** 73 | * Visit a parse tree produced by {@link MegaAsmParser#typeName}. 74 | * @param ctx the parse tree 75 | * @return the visitor result 76 | */ 77 | T visitTypeName(MegaAsmParser.TypeNameContext ctx); 78 | /** 79 | * Visit a parse tree produced by {@link MegaAsmParser#instrukcja}. 80 | * @param ctx the parse tree 81 | * @return the visitor result 82 | */ 83 | T visitInstrukcja(MegaAsmParser.InstrukcjaContext ctx); 84 | /** 85 | * Visit a parse tree produced by {@link MegaAsmParser#linia}. 86 | * @param ctx the parse tree 87 | * @return the visitor result 88 | */ 89 | T visitLinia(MegaAsmParser.LiniaContext ctx); 90 | /** 91 | * Visit a parse tree produced by {@link MegaAsmParser#target}. 92 | * @param ctx the parse tree 93 | * @return the visitor result 94 | */ 95 | T visitTarget(MegaAsmParser.TargetContext ctx); 96 | /** 97 | * Visit a parse tree produced by {@link MegaAsmParser#arg}. 98 | * @param ctx the parse tree 99 | * @return the visitor result 100 | */ 101 | T visitArg(MegaAsmParser.ArgContext ctx); 102 | /** 103 | * Visit a parse tree produced by {@link MegaAsmParser#identifier}. 104 | * @param ctx the parse tree 105 | * @return the visitor result 106 | */ 107 | T visitIdentifier(MegaAsmParser.IdentifierContext ctx); 108 | /** 109 | * Visit a parse tree produced by {@link MegaAsmParser#simpleIdentifier}. 110 | * @param ctx the parse tree 111 | * @return the visitor result 112 | */ 113 | T visitSimpleIdentifier(MegaAsmParser.SimpleIdentifierContext ctx); 114 | /** 115 | * Visit a parse tree produced by {@link MegaAsmParser#assemblerBody}. 116 | * @param ctx the parse tree 117 | * @return the visitor result 118 | */ 119 | T visitAssemblerBody(MegaAsmParser.AssemblerBodyContext ctx); 120 | /** 121 | * Visit a parse tree produced by {@link MegaAsmParser#multiLineStringLiteral}. 122 | * @param ctx the parse tree 123 | * @return the visitor result 124 | */ 125 | T visitMultiLineStringLiteral(MegaAsmParser.MultiLineStringLiteralContext ctx); 126 | /** 127 | * Visit a parse tree produced by {@link MegaAsmParser#multiLineStringContent}. 128 | * @param ctx the parse tree 129 | * @return the visitor result 130 | */ 131 | T visitMultiLineStringContent(MegaAsmParser.MultiLineStringContentContext ctx); 132 | /** 133 | * Visit a parse tree produced by {@link MegaAsmParser#lineStringLiteral}. 134 | * @param ctx the parse tree 135 | * @return the visitor result 136 | */ 137 | T visitLineStringLiteral(MegaAsmParser.LineStringLiteralContext ctx); 138 | /** 139 | * Visit a parse tree produced by {@link MegaAsmParser#lineStringContent}. 140 | * @param ctx the parse tree 141 | * @return the visitor result 142 | */ 143 | T visitLineStringContent(MegaAsmParser.LineStringContentContext ctx); 144 | } -------------------------------------------------------------------------------- /src/main/gen/PseudoAsmLexer.tokens: -------------------------------------------------------------------------------- 1 | DelimitedComment=1 2 | LineComment=2 3 | WS=3 4 | NL=4 5 | DOT=5 6 | HASH=6 7 | LANGLE=7 8 | RANGLE=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | ASSIGNMENT=13 14 | COMMA=14 15 | QUEST=15 16 | AT=16 17 | ARROW=17 18 | MOD=18 19 | DOLLAR=19 20 | REFERENCE=20 21 | DEREFERENCE=21 22 | QUOTE_OPEN=22 23 | TRIPLE_QUOTE_OPEN=23 24 | FloatLiteral=24 25 | DoubleLiteral=25 26 | IntegerLiteral=26 27 | Identifier=27 28 | UNICODE_CLASS_LL=28 29 | UNICODE_CLASS_LM=29 30 | UNICODE_CLASS_LO=30 31 | UNICODE_CLASS_LT=31 32 | UNICODE_CLASS_LU=32 33 | UNICODE_CLASS_ND=33 34 | UNICODE_CLASS_NL=34 35 | QUOTE_CLOSE=35 36 | LineStrText=36 37 | LineStrEscapedChar=37 38 | TRIPLE_QUOTE_CLOSE=38 39 | MultiLineStringQuote=39 40 | MultiLineStrText=40 41 | MultiLineStrEscapedChar=41 42 | MultiLineNL=42 43 | '.'=5 44 | '#'=6 45 | '<'=7 46 | '>'=8 47 | '('=9 48 | ')'=10 49 | '['=11 50 | ']'=12 51 | '='=13 52 | ','=14 53 | '?'=15 54 | '@'=16 55 | '->'=17 56 | '%'=18 57 | '$'=19 58 | '*'=20 59 | '&'=21 60 | '"""'=23 61 | -------------------------------------------------------------------------------- /src/main/gen/PseudoAsmParser.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | REFERENCE=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | DEREFERENCE=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | ARROW=33 34 | DOUBLE_ARROW=34 35 | RANGE=35 36 | COLONCOLON=36 37 | Q_COLONCOLON=37 38 | DOUBLE_SEMICOLON=38 39 | HASH=39 40 | AT=40 41 | QUEST=41 42 | ELVIS=42 43 | LANGLE=43 44 | RANGLE=44 45 | LE=45 46 | GE=46 47 | EXCL_EQ=47 48 | EXCL_EQEQ=48 49 | AS_SAFE=49 50 | EQEQ=50 51 | EQEQEQ=51 52 | SINGLE_QUOTE=52 53 | RETURN_AT=53 54 | CONTINUE_AT=54 55 | BREAK_AT=55 56 | FILE=56 57 | PACKAGE=57 58 | IMPORT=58 59 | CLASS=59 60 | INTERFACE=60 61 | FUN=61 62 | OBJECT=62 63 | VAL=63 64 | VAR=64 65 | TYPE_ALIAS=65 66 | CONSTRUCTOR=66 67 | BY=67 68 | COMPANION=68 69 | INIT=69 70 | THIS=70 71 | SUPER=71 72 | TYPEOF=72 73 | WHERE=73 74 | IF=74 75 | ELSE=75 76 | WHEN=76 77 | TRY=77 78 | CATCH=78 79 | FINALLY=79 80 | FOR=80 81 | DO=81 82 | WHILE=82 83 | THROW=83 84 | RETURN=84 85 | CONTINUE=85 86 | BREAK=86 87 | AS=87 88 | IS=88 89 | IN=89 90 | NOT_IS=90 91 | NOT_IN=91 92 | OUT=92 93 | FIELD=93 94 | PROPERTY=94 95 | GET=95 96 | SET=96 97 | GETTER=97 98 | SETTER=98 99 | RECEIVER=99 100 | PARAM=100 101 | SETPARAM=101 102 | DELEGATE=102 103 | DYNAMIC=103 104 | PUBLIC=104 105 | PRIVATE=105 106 | PROTECTED=106 107 | INTERNAL=107 108 | ENUM=108 109 | SEALED=109 110 | ANNOTATION=110 111 | DATA=111 112 | INNER=112 113 | TAILREC=113 114 | OPERATOR=114 115 | INLINE=115 116 | INFIX=116 117 | EXTERNAL=117 118 | SUSPEND=118 119 | OVERRIDE=119 120 | ABSTRACT=120 121 | FINAL=121 122 | OPEN=122 123 | CONST=123 124 | LATEINIT=124 125 | VARARG=125 126 | NOINLINE=126 127 | CROSSINLINE=127 128 | REIFIED=128 129 | QUOTE_OPEN=129 130 | TRIPLE_QUOTE_OPEN=130 131 | RealLiteral=131 132 | FloatLiteral=132 133 | DoubleLiteral=133 134 | LongLiteral=134 135 | IntegerLiteral=135 136 | HexLiteral=136 137 | BinLiteral=137 138 | BooleanLiteral=138 139 | NullLiteral=139 140 | Identifier=140 141 | LabelReference=141 142 | LabelDefinition=142 143 | FieldIdentifier=143 144 | CharacterLiteral=144 145 | UNICODE_CLASS_LL=145 146 | UNICODE_CLASS_LM=146 147 | UNICODE_CLASS_LO=147 148 | UNICODE_CLASS_LT=148 149 | UNICODE_CLASS_LU=149 150 | UNICODE_CLASS_ND=150 151 | UNICODE_CLASS_NL=151 152 | Inside_Comment=152 153 | Inside_WS=153 154 | Inside_NL=154 155 | QUOTE_CLOSE=155 156 | LineStrRef=156 157 | LineStrText=157 158 | LineStrEscapedChar=158 159 | LineStrExprStart=159 160 | TRIPLE_QUOTE_CLOSE=160 161 | MultiLineStringQuote=161 162 | MultiLineStrRef=162 163 | MultiLineStrText=163 164 | MultiLineStrEscapedChar=164 165 | MultiLineStrExprStart=165 166 | MultiLineNL=166 167 | StrExpr_IN=167 168 | StrExpr_Comment=168 169 | StrExpr_WS=169 170 | StrExpr_NL=170 171 | DOLLAR=180 172 | '...'=6 173 | '.'=7 174 | ','=8 175 | '('=9 176 | '['=11 177 | '{'=13 178 | '}'=14 179 | '*'=15 180 | '%'=16 181 | '/'=17 182 | '+'=18 183 | '-'=19 184 | '++'=20 185 | '--'=21 186 | '&'=22 187 | '||'=23 188 | '!'=24 189 | ':'=25 190 | ';'=26 191 | '='=27 192 | '+='=28 193 | '-='=29 194 | '*='=30 195 | '/='=31 196 | '%='=32 197 | '->'=33 198 | '=>'=34 199 | '..'=35 200 | '::'=36 201 | '?::'=37 202 | ';;'=38 203 | '#'=39 204 | '@'=40 205 | '?'=41 206 | '?:'=42 207 | '<'=43 208 | '>'=44 209 | '<='=45 210 | '>='=46 211 | '!='=47 212 | '!=='=48 213 | 'as?'=49 214 | '=='=50 215 | '==='=51 216 | '\''=52 217 | '@file'=56 218 | 'package'=57 219 | 'import'=58 220 | 'class'=59 221 | 'interface'=60 222 | 'fun'=61 223 | 'object'=62 224 | 'val'=63 225 | 'var'=64 226 | 'typealias'=65 227 | 'constructor'=66 228 | 'by'=67 229 | 'companion'=68 230 | 'init'=69 231 | 'this'=70 232 | 'super'=71 233 | 'typeof'=72 234 | 'where'=73 235 | 'if'=74 236 | 'else'=75 237 | 'when'=76 238 | 'try'=77 239 | 'catch'=78 240 | 'finally'=79 241 | 'for'=80 242 | 'do'=81 243 | 'while'=82 244 | 'throw'=83 245 | 'return'=84 246 | 'continue'=85 247 | 'break'=86 248 | 'as'=87 249 | 'is'=88 250 | 'in'=89 251 | 'out'=92 252 | '@field'=93 253 | '@property'=94 254 | '@get'=95 255 | '@set'=96 256 | 'get'=97 257 | 'set'=98 258 | '@receiver'=99 259 | '@param'=100 260 | '@setparam'=101 261 | '@delegate'=102 262 | 'dynamic'=103 263 | 'public'=104 264 | 'private'=105 265 | 'protected'=106 266 | 'internal'=107 267 | 'enum'=108 268 | 'sealed'=109 269 | 'annotation'=110 270 | 'data'=111 271 | 'inner'=112 272 | 'tailrec'=113 273 | 'operator'=114 274 | 'inline'=115 275 | 'infix'=116 276 | 'external'=117 277 | 'suspend'=118 278 | 'override'=119 279 | 'abstract'=120 280 | 'final'=121 281 | 'open'=122 282 | 'const'=123 283 | 'lateinit'=124 284 | 'vararg'=125 285 | 'noinline'=126 286 | 'crossinline'=127 287 | 'reified'=128 288 | '"""'=130 289 | 'null'=139 290 | '$'=180 291 | -------------------------------------------------------------------------------- /src/main/gen/PseudoAsmParserBaseVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from L:/Projekty/kotlinek/src/main/antlr\PseudoAsmParser.g4 by ANTLR 4.7.2 2 | import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; 3 | 4 | /** 5 | * This class provides an empty implementation of {@link PseudoAsmParserVisitor}, 6 | * which can be extended to create a visitor which only needs to handle a subset 7 | * of the available methods. 8 | * 9 | * @param The return type of the visit operation. Use {@link Void} for 10 | * operations with no return type. 11 | */ 12 | public class PseudoAsmParserBaseVisitor extends AbstractParseTreeVisitor implements PseudoAsmParserVisitor { 13 | /** 14 | * {@inheritDoc} 15 | * 16 | *

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

18 | */ 19 | @Override public T visitPseudoAsmFile(PseudoAsmParser.PseudoAsmFileContext ctx) { return visitChildren(ctx); } 20 | /** 21 | * {@inheritDoc} 22 | * 23 | *

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

25 | */ 26 | @Override public T visitJocker(PseudoAsmParser.JockerContext ctx) { return visitChildren(ctx); } 27 | /** 28 | * {@inheritDoc} 29 | * 30 | *

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

32 | */ 33 | @Override public T visitReferencer(PseudoAsmParser.ReferencerContext ctx) { return visitChildren(ctx); } 34 | /** 35 | * {@inheritDoc} 36 | * 37 | *

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

39 | */ 40 | @Override public T visitOperand(PseudoAsmParser.OperandContext ctx) { return visitChildren(ctx); } 41 | /** 42 | * {@inheritDoc} 43 | * 44 | *

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

46 | */ 47 | @Override public T visitValue(PseudoAsmParser.ValueContext ctx) { return visitChildren(ctx); } 48 | /** 49 | * {@inheritDoc} 50 | * 51 | *

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

53 | */ 54 | @Override public T visitAddressed(PseudoAsmParser.AddressedContext ctx) { return visitChildren(ctx); } 55 | /** 56 | * {@inheritDoc} 57 | * 58 | *

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

60 | */ 61 | @Override public T visitIndex(PseudoAsmParser.IndexContext ctx) { return visitChildren(ctx); } 62 | /** 63 | * {@inheritDoc} 64 | * 65 | *

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

67 | */ 68 | @Override public T visitImmediate(PseudoAsmParser.ImmediateContext ctx) { return visitChildren(ctx); } 69 | /** 70 | * {@inheritDoc} 71 | * 72 | *

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

74 | */ 75 | @Override public T visitFloatimmediate(PseudoAsmParser.FloatimmediateContext ctx) { return visitChildren(ctx); } 76 | /** 77 | * {@inheritDoc} 78 | * 79 | *

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

81 | */ 82 | @Override public T visitStringimmediate(PseudoAsmParser.StringimmediateContext ctx) { return visitChildren(ctx); } 83 | /** 84 | * {@inheritDoc} 85 | * 86 | *

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

88 | */ 89 | @Override public T visitAbsAddress(PseudoAsmParser.AbsAddressContext ctx) { return visitChildren(ctx); } 90 | /** 91 | * {@inheritDoc} 92 | * 93 | *

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

95 | */ 96 | @Override public T visitName(PseudoAsmParser.NameContext ctx) { return visitChildren(ctx); } 97 | /** 98 | * {@inheritDoc} 99 | * 100 | *

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

102 | */ 103 | @Override public T visitTypeName(PseudoAsmParser.TypeNameContext ctx) { return visitChildren(ctx); } 104 | /** 105 | * {@inheritDoc} 106 | * 107 | *

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

109 | */ 110 | @Override public T visitInstrukcja(PseudoAsmParser.InstrukcjaContext ctx) { return visitChildren(ctx); } 111 | /** 112 | * {@inheritDoc} 113 | * 114 | *

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

116 | */ 117 | @Override public T visitLinia(PseudoAsmParser.LiniaContext ctx) { return visitChildren(ctx); } 118 | /** 119 | * {@inheritDoc} 120 | * 121 | *

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

123 | */ 124 | @Override public T visitTarget(PseudoAsmParser.TargetContext ctx) { return visitChildren(ctx); } 125 | /** 126 | * {@inheritDoc} 127 | * 128 | *

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

130 | */ 131 | @Override public T visitArg(PseudoAsmParser.ArgContext ctx) { return visitChildren(ctx); } 132 | /** 133 | * {@inheritDoc} 134 | * 135 | *

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

137 | */ 138 | @Override public T visitIdentifier(PseudoAsmParser.IdentifierContext ctx) { return visitChildren(ctx); } 139 | /** 140 | * {@inheritDoc} 141 | * 142 | *

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

144 | */ 145 | @Override public T visitSimpleIdentifier(PseudoAsmParser.SimpleIdentifierContext ctx) { return visitChildren(ctx); } 146 | /** 147 | * {@inheritDoc} 148 | * 149 | *

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

151 | */ 152 | @Override public T visitAssemblerBody(PseudoAsmParser.AssemblerBodyContext ctx) { return visitChildren(ctx); } 153 | /** 154 | * {@inheritDoc} 155 | * 156 | *

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

158 | */ 159 | @Override public T visitMultiLineStringLiteral(PseudoAsmParser.MultiLineStringLiteralContext ctx) { return visitChildren(ctx); } 160 | /** 161 | * {@inheritDoc} 162 | * 163 | *

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

165 | */ 166 | @Override public T visitMultiLineStringContent(PseudoAsmParser.MultiLineStringContentContext ctx) { return visitChildren(ctx); } 167 | /** 168 | * {@inheritDoc} 169 | * 170 | *

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

172 | */ 173 | @Override public T visitLineStringLiteral(PseudoAsmParser.LineStringLiteralContext ctx) { return visitChildren(ctx); } 174 | /** 175 | * {@inheritDoc} 176 | * 177 | *

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

179 | */ 180 | @Override public T visitLineStringContent(PseudoAsmParser.LineStringContentContext ctx) { return visitChildren(ctx); } 181 | } -------------------------------------------------------------------------------- /src/main/gen/PseudoAsmParserVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from L:/Projekty/kotlinek/src/main/antlr\PseudoAsmParser.g4 by ANTLR 4.7.2 2 | import org.antlr.v4.runtime.tree.ParseTreeVisitor; 3 | 4 | /** 5 | * This interface defines a complete generic visitor for a parse tree produced 6 | * by {@link PseudoAsmParser}. 7 | * 8 | * @param The return type of the visit operation. Use {@link Void} for 9 | * operations with no return type. 10 | */ 11 | public interface PseudoAsmParserVisitor extends ParseTreeVisitor { 12 | /** 13 | * Visit a parse tree produced by {@link PseudoAsmParser#pseudoAsmFile}. 14 | * @param ctx the parse tree 15 | * @return the visitor result 16 | */ 17 | T visitPseudoAsmFile(PseudoAsmParser.PseudoAsmFileContext ctx); 18 | /** 19 | * Visit a parse tree produced by {@link PseudoAsmParser#jocker}. 20 | * @param ctx the parse tree 21 | * @return the visitor result 22 | */ 23 | T visitJocker(PseudoAsmParser.JockerContext ctx); 24 | /** 25 | * Visit a parse tree produced by {@link PseudoAsmParser#referencer}. 26 | * @param ctx the parse tree 27 | * @return the visitor result 28 | */ 29 | T visitReferencer(PseudoAsmParser.ReferencerContext ctx); 30 | /** 31 | * Visit a parse tree produced by {@link PseudoAsmParser#operand}. 32 | * @param ctx the parse tree 33 | * @return the visitor result 34 | */ 35 | T visitOperand(PseudoAsmParser.OperandContext ctx); 36 | /** 37 | * Visit a parse tree produced by {@link PseudoAsmParser#value}. 38 | * @param ctx the parse tree 39 | * @return the visitor result 40 | */ 41 | T visitValue(PseudoAsmParser.ValueContext ctx); 42 | /** 43 | * Visit a parse tree produced by {@link PseudoAsmParser#addressed}. 44 | * @param ctx the parse tree 45 | * @return the visitor result 46 | */ 47 | T visitAddressed(PseudoAsmParser.AddressedContext ctx); 48 | /** 49 | * Visit a parse tree produced by {@link PseudoAsmParser#index}. 50 | * @param ctx the parse tree 51 | * @return the visitor result 52 | */ 53 | T visitIndex(PseudoAsmParser.IndexContext ctx); 54 | /** 55 | * Visit a parse tree produced by {@link PseudoAsmParser#immediate}. 56 | * @param ctx the parse tree 57 | * @return the visitor result 58 | */ 59 | T visitImmediate(PseudoAsmParser.ImmediateContext ctx); 60 | /** 61 | * Visit a parse tree produced by {@link PseudoAsmParser#floatimmediate}. 62 | * @param ctx the parse tree 63 | * @return the visitor result 64 | */ 65 | T visitFloatimmediate(PseudoAsmParser.FloatimmediateContext ctx); 66 | /** 67 | * Visit a parse tree produced by {@link PseudoAsmParser#stringimmediate}. 68 | * @param ctx the parse tree 69 | * @return the visitor result 70 | */ 71 | T visitStringimmediate(PseudoAsmParser.StringimmediateContext ctx); 72 | /** 73 | * Visit a parse tree produced by {@link PseudoAsmParser#absAddress}. 74 | * @param ctx the parse tree 75 | * @return the visitor result 76 | */ 77 | T visitAbsAddress(PseudoAsmParser.AbsAddressContext ctx); 78 | /** 79 | * Visit a parse tree produced by {@link PseudoAsmParser#name}. 80 | * @param ctx the parse tree 81 | * @return the visitor result 82 | */ 83 | T visitName(PseudoAsmParser.NameContext ctx); 84 | /** 85 | * Visit a parse tree produced by {@link PseudoAsmParser#typeName}. 86 | * @param ctx the parse tree 87 | * @return the visitor result 88 | */ 89 | T visitTypeName(PseudoAsmParser.TypeNameContext ctx); 90 | /** 91 | * Visit a parse tree produced by {@link PseudoAsmParser#instrukcja}. 92 | * @param ctx the parse tree 93 | * @return the visitor result 94 | */ 95 | T visitInstrukcja(PseudoAsmParser.InstrukcjaContext ctx); 96 | /** 97 | * Visit a parse tree produced by {@link PseudoAsmParser#linia}. 98 | * @param ctx the parse tree 99 | * @return the visitor result 100 | */ 101 | T visitLinia(PseudoAsmParser.LiniaContext ctx); 102 | /** 103 | * Visit a parse tree produced by {@link PseudoAsmParser#target}. 104 | * @param ctx the parse tree 105 | * @return the visitor result 106 | */ 107 | T visitTarget(PseudoAsmParser.TargetContext ctx); 108 | /** 109 | * Visit a parse tree produced by {@link PseudoAsmParser#arg}. 110 | * @param ctx the parse tree 111 | * @return the visitor result 112 | */ 113 | T visitArg(PseudoAsmParser.ArgContext ctx); 114 | /** 115 | * Visit a parse tree produced by {@link PseudoAsmParser#identifier}. 116 | * @param ctx the parse tree 117 | * @return the visitor result 118 | */ 119 | T visitIdentifier(PseudoAsmParser.IdentifierContext ctx); 120 | /** 121 | * Visit a parse tree produced by {@link PseudoAsmParser#simpleIdentifier}. 122 | * @param ctx the parse tree 123 | * @return the visitor result 124 | */ 125 | T visitSimpleIdentifier(PseudoAsmParser.SimpleIdentifierContext ctx); 126 | /** 127 | * Visit a parse tree produced by {@link PseudoAsmParser#assemblerBody}. 128 | * @param ctx the parse tree 129 | * @return the visitor result 130 | */ 131 | T visitAssemblerBody(PseudoAsmParser.AssemblerBodyContext ctx); 132 | /** 133 | * Visit a parse tree produced by {@link PseudoAsmParser#multiLineStringLiteral}. 134 | * @param ctx the parse tree 135 | * @return the visitor result 136 | */ 137 | T visitMultiLineStringLiteral(PseudoAsmParser.MultiLineStringLiteralContext ctx); 138 | /** 139 | * Visit a parse tree produced by {@link PseudoAsmParser#multiLineStringContent}. 140 | * @param ctx the parse tree 141 | * @return the visitor result 142 | */ 143 | T visitMultiLineStringContent(PseudoAsmParser.MultiLineStringContentContext ctx); 144 | /** 145 | * Visit a parse tree produced by {@link PseudoAsmParser#lineStringLiteral}. 146 | * @param ctx the parse tree 147 | * @return the visitor result 148 | */ 149 | T visitLineStringLiteral(PseudoAsmParser.LineStringLiteralContext ctx); 150 | /** 151 | * Visit a parse tree produced by {@link PseudoAsmParser#lineStringContent}. 152 | * @param ctx the parse tree 153 | * @return the visitor result 154 | */ 155 | T visitLineStringContent(PseudoAsmParser.LineStringContentContext ctx); 156 | } -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/KotlinLexer.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | MULT=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | CONJ=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | BIT_ASSIGNMENT=33 34 | BIT_DEASSIGNMENT=34 35 | ARROW=35 36 | DOUBLE_ARROW=36 37 | RANGE=37 38 | COLONCOLON=38 39 | Q_COLONCOLON=39 40 | DOUBLE_SEMICOLON=40 41 | HASH=41 42 | AT=42 43 | CARON=43 44 | QUEST=44 45 | ELVIS=45 46 | LANGLE=46 47 | RANGLE=47 48 | LE=48 49 | GE=49 50 | EXCL_EQ=50 51 | EXCL_EQEQ=51 52 | AS_SAFE=52 53 | EQEQ=53 54 | EQEQEQ=54 55 | SINGLE_QUOTE=55 56 | BIT_OR=56 57 | BIT_AND=57 58 | BIT_OR_ASSIGNMENT=58 59 | BIT_AND_ASSIGNMENT=59 60 | RETURN_AT=60 61 | CONTINUE_AT=61 62 | BREAK_AT=62 63 | FILE=63 64 | PACKAGE=64 65 | IMPORT=65 66 | CLASS=66 67 | INTERFACE=67 68 | FUN=68 69 | OBJECT=69 70 | VAL=70 71 | VAR=71 72 | TYPE_ALIAS=72 73 | CONSTRUCTOR=73 74 | BY=74 75 | COMPANION=75 76 | INIT=76 77 | THIS=77 78 | SUPER=78 79 | TYPEOF=79 80 | WHERE=80 81 | IF=81 82 | ELSE=82 83 | WHEN=83 84 | TRY=84 85 | CATCH=85 86 | FINALLY=86 87 | FOR=87 88 | DO=88 89 | WHILE=89 90 | THROW=90 91 | RETURN=91 92 | CONTINUE=92 93 | BREAK=93 94 | AS=94 95 | IS=95 96 | IN=96 97 | NOT_IS=97 98 | NOT_IN=98 99 | OUT=99 100 | FIELD=100 101 | PROPERTY=101 102 | GET=102 103 | SET=103 104 | GETTER=104 105 | SETTER=105 106 | RECEIVER=106 107 | PARAM=107 108 | SETPARAM=108 109 | DELEGATE=109 110 | DYNAMIC=110 111 | PUBLIC=111 112 | PRIVATE=112 113 | PROTECTED=113 114 | INTERNAL=114 115 | ENUM=115 116 | SEALED=116 117 | ANNOTATION=117 118 | DATA=118 119 | INNER=119 120 | TAILREC=120 121 | OPERATOR=121 122 | INLINE=122 123 | INFIX=123 124 | EXTERNAL=124 125 | SUSPEND=125 126 | INTERRUPT=126 127 | CC65=127 128 | OVERRIDE=128 129 | ABSTRACT=129 130 | FINAL=130 131 | OPEN=131 132 | CONST=132 133 | LATEINIT=133 134 | VARARG=134 135 | NOINLINE=135 136 | CROSSINLINE=136 137 | REIFIED=137 138 | QUOTE_OPEN=138 139 | TRIPLE_QUOTE_OPEN=139 140 | RealLiteral=140 141 | FloatLiteral=141 142 | DoubleLiteral=142 143 | LongLiteral=143 144 | IntegerLiteral=144 145 | HexLiteral=145 146 | BinLiteral=146 147 | BooleanLiteral=147 148 | NullLiteral=148 149 | Identifier=149 150 | LabelReference=150 151 | LabelDefinition=151 152 | FieldIdentifier=152 153 | CharacterLiteral=153 154 | UNICODE_CLASS_LL=154 155 | UNICODE_CLASS_LM=155 156 | UNICODE_CLASS_LO=156 157 | UNICODE_CLASS_LT=157 158 | UNICODE_CLASS_LU=158 159 | UNICODE_CLASS_ND=159 160 | UNICODE_CLASS_NL=160 161 | Inside_Comment=161 162 | Inside_WS=162 163 | Inside_NL=163 164 | QUOTE_CLOSE=164 165 | LineStrRef=165 166 | LineStrText=166 167 | LineStrEscapedChar=167 168 | LineStrExprStart=168 169 | TRIPLE_QUOTE_CLOSE=169 170 | MultiLineStringQuote=170 171 | MultiLineStrRef=171 172 | MultiLineStrText=172 173 | MultiLineStrEscapedChar=173 174 | MultiLineStrExprStart=174 175 | MultiLineNL=175 176 | StrExpr_IN=176 177 | StrExpr_Comment=177 178 | StrExpr_WS=178 179 | StrExpr_NL=179 180 | '...'=6 181 | '.'=7 182 | ','=8 183 | '('=9 184 | '['=11 185 | '{'=13 186 | '}'=14 187 | '*'=15 188 | '%'=16 189 | '/'=17 190 | '+'=18 191 | '-'=19 192 | '++'=20 193 | '--'=21 194 | '&&'=22 195 | '||'=23 196 | '!'=24 197 | ':'=25 198 | ';'=26 199 | '='=27 200 | '+='=28 201 | '-='=29 202 | '*='=30 203 | '/='=31 204 | '%='=32 205 | ':='=33 206 | '.='=34 207 | '->'=35 208 | '=>'=36 209 | '..'=37 210 | '::'=38 211 | '?::'=39 212 | ';;'=40 213 | '#'=41 214 | '@'=42 215 | '^'=43 216 | '?'=44 217 | '?:'=45 218 | '<'=46 219 | '>'=47 220 | '<='=48 221 | '>='=49 222 | '!='=50 223 | '!=='=51 224 | 'as?'=52 225 | '=='=53 226 | '==='=54 227 | '\''=55 228 | '|'=56 229 | '&'=57 230 | '|='=58 231 | '&='=59 232 | '@file'=63 233 | 'package'=64 234 | 'import'=65 235 | 'class'=66 236 | 'interface'=67 237 | 'fun'=68 238 | 'object'=69 239 | 'val'=70 240 | 'var'=71 241 | 'typealias'=72 242 | 'constructor'=73 243 | 'by'=74 244 | 'companion'=75 245 | 'init'=76 246 | 'this'=77 247 | 'super'=78 248 | 'typeof'=79 249 | 'where'=80 250 | 'if'=81 251 | 'else'=82 252 | 'when'=83 253 | 'try'=84 254 | 'catch'=85 255 | 'finally'=86 256 | 'for'=87 257 | 'do'=88 258 | 'while'=89 259 | 'throw'=90 260 | 'return'=91 261 | 'continue'=92 262 | 'break'=93 263 | 'as'=94 264 | 'is'=95 265 | 'in'=96 266 | 'out'=99 267 | '@field'=100 268 | '@property'=101 269 | '@get'=102 270 | '@set'=103 271 | 'get'=104 272 | 'set'=105 273 | '@receiver'=106 274 | '@param'=107 275 | '@setparam'=108 276 | '@delegate'=109 277 | 'dynamic'=110 278 | 'public'=111 279 | 'private'=112 280 | 'protected'=113 281 | 'internal'=114 282 | 'enum'=115 283 | 'sealed'=116 284 | 'annotation'=117 285 | 'data'=118 286 | 'inner'=119 287 | 'tailrec'=120 288 | 'operator'=121 289 | 'inline'=122 290 | 'infix'=123 291 | 'external'=124 292 | 'suspend'=125 293 | 'interrupt'=126 294 | 'cc65'=127 295 | 'override'=128 296 | 'abstract'=129 297 | 'final'=130 298 | 'open'=131 299 | 'const'=132 300 | 'lateinit'=133 301 | 'vararg'=134 302 | 'noinline'=135 303 | 'crossinline'=136 304 | 'reified'=137 305 | '"""'=139 306 | 'null'=148 307 | -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/KotlinParser.tokens: -------------------------------------------------------------------------------- 1 | ShebangLine=1 2 | DelimitedComment=2 3 | LineComment=3 4 | WS=4 5 | NL=5 6 | RESERVED=6 7 | DOT=7 8 | COMMA=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | LCURL=13 14 | RCURL=14 15 | MULT=15 16 | MOD=16 17 | DIV=17 18 | ADD=18 19 | SUB=19 20 | INCR=20 21 | DECR=21 22 | CONJ=22 23 | DISJ=23 24 | EXCL=24 25 | COLON=25 26 | SEMICOLON=26 27 | ASSIGNMENT=27 28 | ADD_ASSIGNMENT=28 29 | SUB_ASSIGNMENT=29 30 | MULT_ASSIGNMENT=30 31 | DIV_ASSIGNMENT=31 32 | MOD_ASSIGNMENT=32 33 | BIT_ASSIGNMENT=33 34 | BIT_DEASSIGNMENT=34 35 | ARROW=35 36 | DOUBLE_ARROW=36 37 | RANGE=37 38 | COLONCOLON=38 39 | Q_COLONCOLON=39 40 | DOUBLE_SEMICOLON=40 41 | HASH=41 42 | AT=42 43 | CARON=43 44 | QUEST=44 45 | ELVIS=45 46 | LANGLE=46 47 | RANGLE=47 48 | LE=48 49 | GE=49 50 | EXCL_EQ=50 51 | EXCL_EQEQ=51 52 | AS_SAFE=52 53 | EQEQ=53 54 | EQEQEQ=54 55 | SINGLE_QUOTE=55 56 | BIT_OR=56 57 | BIT_AND=57 58 | BIT_OR_ASSIGNMENT=58 59 | BIT_AND_ASSIGNMENT=59 60 | RETURN_AT=60 61 | CONTINUE_AT=61 62 | BREAK_AT=62 63 | FILE=63 64 | PACKAGE=64 65 | IMPORT=65 66 | CLASS=66 67 | INTERFACE=67 68 | FUN=68 69 | OBJECT=69 70 | VAL=70 71 | VAR=71 72 | TYPE_ALIAS=72 73 | CONSTRUCTOR=73 74 | BY=74 75 | COMPANION=75 76 | INIT=76 77 | THIS=77 78 | SUPER=78 79 | TYPEOF=79 80 | WHERE=80 81 | IF=81 82 | ELSE=82 83 | WHEN=83 84 | TRY=84 85 | CATCH=85 86 | FINALLY=86 87 | FOR=87 88 | DO=88 89 | WHILE=89 90 | THROW=90 91 | RETURN=91 92 | CONTINUE=92 93 | BREAK=93 94 | AS=94 95 | IS=95 96 | IN=96 97 | NOT_IS=97 98 | NOT_IN=98 99 | OUT=99 100 | FIELD=100 101 | PROPERTY=101 102 | GET=102 103 | SET=103 104 | GETTER=104 105 | SETTER=105 106 | RECEIVER=106 107 | PARAM=107 108 | SETPARAM=108 109 | DELEGATE=109 110 | DYNAMIC=110 111 | PUBLIC=111 112 | PRIVATE=112 113 | PROTECTED=113 114 | INTERNAL=114 115 | ENUM=115 116 | SEALED=116 117 | ANNOTATION=117 118 | DATA=118 119 | INNER=119 120 | TAILREC=120 121 | OPERATOR=121 122 | INLINE=122 123 | INFIX=123 124 | EXTERNAL=124 125 | SUSPEND=125 126 | INTERRUPT=126 127 | CC65=127 128 | OVERRIDE=128 129 | ABSTRACT=129 130 | FINAL=130 131 | OPEN=131 132 | CONST=132 133 | LATEINIT=133 134 | VARARG=134 135 | NOINLINE=135 136 | CROSSINLINE=136 137 | REIFIED=137 138 | QUOTE_OPEN=138 139 | TRIPLE_QUOTE_OPEN=139 140 | RealLiteral=140 141 | FloatLiteral=141 142 | DoubleLiteral=142 143 | LongLiteral=143 144 | IntegerLiteral=144 145 | HexLiteral=145 146 | BinLiteral=146 147 | BooleanLiteral=147 148 | NullLiteral=148 149 | Identifier=149 150 | LabelReference=150 151 | LabelDefinition=151 152 | FieldIdentifier=152 153 | CharacterLiteral=153 154 | UNICODE_CLASS_LL=154 155 | UNICODE_CLASS_LM=155 156 | UNICODE_CLASS_LO=156 157 | UNICODE_CLASS_LT=157 158 | UNICODE_CLASS_LU=158 159 | UNICODE_CLASS_ND=159 160 | UNICODE_CLASS_NL=160 161 | Inside_Comment=161 162 | Inside_WS=162 163 | Inside_NL=163 164 | QUOTE_CLOSE=164 165 | LineStrRef=165 166 | LineStrText=166 167 | LineStrEscapedChar=167 168 | LineStrExprStart=168 169 | TRIPLE_QUOTE_CLOSE=169 170 | MultiLineStringQuote=170 171 | MultiLineStrRef=171 172 | MultiLineStrText=172 173 | MultiLineStrEscapedChar=173 174 | MultiLineStrExprStart=174 175 | MultiLineNL=175 176 | StrExpr_IN=176 177 | StrExpr_Comment=177 178 | StrExpr_WS=178 179 | StrExpr_NL=179 180 | '...'=6 181 | '.'=7 182 | ','=8 183 | '('=9 184 | '['=11 185 | '{'=13 186 | '}'=14 187 | '*'=15 188 | '%'=16 189 | '/'=17 190 | '+'=18 191 | '-'=19 192 | '++'=20 193 | '--'=21 194 | '&&'=22 195 | '||'=23 196 | '!'=24 197 | ':'=25 198 | ';'=26 199 | '='=27 200 | '+='=28 201 | '-='=29 202 | '*='=30 203 | '/='=31 204 | '%='=32 205 | ':='=33 206 | '.='=34 207 | '->'=35 208 | '=>'=36 209 | '..'=37 210 | '::'=38 211 | '?::'=39 212 | ';;'=40 213 | '#'=41 214 | '@'=42 215 | '^'=43 216 | '?'=44 217 | '?:'=45 218 | '<'=46 219 | '>'=47 220 | '<='=48 221 | '>='=49 222 | '!='=50 223 | '!=='=51 224 | 'as?'=52 225 | '=='=53 226 | '==='=54 227 | '\''=55 228 | '|'=56 229 | '&'=57 230 | '|='=58 231 | '&='=59 232 | '@file'=63 233 | 'package'=64 234 | 'import'=65 235 | 'class'=66 236 | 'interface'=67 237 | 'fun'=68 238 | 'object'=69 239 | 'val'=70 240 | 'var'=71 241 | 'typealias'=72 242 | 'constructor'=73 243 | 'by'=74 244 | 'companion'=75 245 | 'init'=76 246 | 'this'=77 247 | 'super'=78 248 | 'typeof'=79 249 | 'where'=80 250 | 'if'=81 251 | 'else'=82 252 | 'when'=83 253 | 'try'=84 254 | 'catch'=85 255 | 'finally'=86 256 | 'for'=87 257 | 'do'=88 258 | 'while'=89 259 | 'throw'=90 260 | 'return'=91 261 | 'continue'=92 262 | 'break'=93 263 | 'as'=94 264 | 'is'=95 265 | 'in'=96 266 | 'out'=99 267 | '@field'=100 268 | '@property'=101 269 | '@get'=102 270 | '@set'=103 271 | 'get'=104 272 | 'set'=105 273 | '@receiver'=106 274 | '@param'=107 275 | '@setparam'=108 276 | '@delegate'=109 277 | 'dynamic'=110 278 | 'public'=111 279 | 'private'=112 280 | 'protected'=113 281 | 'internal'=114 282 | 'enum'=115 283 | 'sealed'=116 284 | 'annotation'=117 285 | 'data'=118 286 | 'inner'=119 287 | 'tailrec'=120 288 | 'operator'=121 289 | 'inline'=122 290 | 'infix'=123 291 | 'external'=124 292 | 'suspend'=125 293 | 'interrupt'=126 294 | 'cc65'=127 295 | 'override'=128 296 | 'abstract'=129 297 | 'final'=130 298 | 'open'=131 299 | 'const'=132 300 | 'lateinit'=133 301 | 'vararg'=134 302 | 'noinline'=135 303 | 'crossinline'=136 304 | 'reified'=137 305 | '"""'=139 306 | 'null'=148 307 | -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/MegaAsmLexer.tokens: -------------------------------------------------------------------------------- 1 | DelimitedComment=1 2 | LineComment=2 3 | WS=3 4 | NL=4 5 | DOT=5 6 | HASH=6 7 | LPAREN=7 8 | RPAREN=8 9 | LSQUARE=9 10 | RSQUARE=10 11 | ASSIGNMENT=11 12 | COMMA=12 13 | QUEST=13 14 | AT=14 15 | ARROW=15 16 | MOD=16 17 | DOLLAR=17 18 | REFERENCE=18 19 | DEREFERENCE=19 20 | COLON=20 21 | QUOTE_OPEN=21 22 | TRIPLE_QUOTE_OPEN=22 23 | FloatLiteral=23 24 | DoubleLiteral=24 25 | IntegerLiteral=25 26 | Identifier=26 27 | Operator=27 28 | UNICODE_CLASS_LL=28 29 | UNICODE_CLASS_LM=29 30 | UNICODE_CLASS_LO=30 31 | UNICODE_CLASS_LT=31 32 | UNICODE_CLASS_LU=32 33 | UNICODE_CLASS_ND=33 34 | UNICODE_CLASS_NL=34 35 | QUOTE_CLOSE=35 36 | LineStrText=36 37 | LineStrEscapedChar=37 38 | TRIPLE_QUOTE_CLOSE=38 39 | MultiLineStringQuote=39 40 | MultiLineStrText=40 41 | MultiLineStrEscapedChar=41 42 | MultiLineNL=42 43 | '.'=5 44 | '#'=6 45 | '('=7 46 | ')'=8 47 | '['=9 48 | ']'=10 49 | '='=11 50 | ','=12 51 | '?'=13 52 | '@'=14 53 | '->'=15 54 | '%'=16 55 | '$'=17 56 | '*'=18 57 | '&'=19 58 | ':'=20 59 | '"""'=22 60 | -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/MegaAsmParser.tokens: -------------------------------------------------------------------------------- 1 | DelimitedComment=1 2 | LineComment=2 3 | WS=3 4 | NL=4 5 | DOT=5 6 | HASH=6 7 | LPAREN=7 8 | RPAREN=8 9 | LSQUARE=9 10 | RSQUARE=10 11 | ASSIGNMENT=11 12 | COMMA=12 13 | QUEST=13 14 | AT=14 15 | ARROW=15 16 | MOD=16 17 | DOLLAR=17 18 | REFERENCE=18 19 | DEREFERENCE=19 20 | COLON=20 21 | QUOTE_OPEN=21 22 | TRIPLE_QUOTE_OPEN=22 23 | FloatLiteral=23 24 | DoubleLiteral=24 25 | IntegerLiteral=25 26 | Identifier=26 27 | Operator=27 28 | UNICODE_CLASS_LL=28 29 | UNICODE_CLASS_LM=29 30 | UNICODE_CLASS_LO=30 31 | UNICODE_CLASS_LT=31 32 | UNICODE_CLASS_LU=32 33 | UNICODE_CLASS_ND=33 34 | UNICODE_CLASS_NL=34 35 | QUOTE_CLOSE=35 36 | LineStrText=36 37 | LineStrEscapedChar=37 38 | TRIPLE_QUOTE_CLOSE=38 39 | MultiLineStringQuote=39 40 | MultiLineStrText=40 41 | MultiLineStrEscapedChar=41 42 | MultiLineNL=42 43 | '.'=5 44 | '#'=6 45 | '('=7 46 | ')'=8 47 | '['=9 48 | ']'=10 49 | '='=11 50 | ','=12 51 | '?'=13 52 | '@'=14 53 | '->'=15 54 | '%'=16 55 | '$'=17 56 | '*'=18 57 | '&'=19 58 | ':'=20 59 | '"""'=22 60 | -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/MegaAsmParserBaseVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from MegaAsmParser.g4 by ANTLR 4.5.1 2 | package pl.qus.wolin; 3 | import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; 4 | 5 | /** 6 | * This class provides an empty implementation of {@link MegaAsmParserVisitor}, 7 | * which can be extended to create a visitor which only needs to handle a subset 8 | * of the available methods. 9 | * 10 | * @param The return type of the visit operation. Use {@link Void} for 11 | * operations with no return type. 12 | */ 13 | public class MegaAsmParserBaseVisitor extends AbstractParseTreeVisitor implements MegaAsmParserVisitor { 14 | /** 15 | * {@inheritDoc} 16 | * 17 | *

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

19 | */ 20 | @Override public T visitPseudoAsmFile(MegaAsmParser.PseudoAsmFileContext ctx) { return visitChildren(ctx); } 21 | /** 22 | * {@inheritDoc} 23 | * 24 | *

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

26 | */ 27 | @Override public T visitReferencer(MegaAsmParser.ReferencerContext ctx) { return visitChildren(ctx); } 28 | /** 29 | * {@inheritDoc} 30 | * 31 | *

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

33 | */ 34 | @Override public T visitOperand(MegaAsmParser.OperandContext ctx) { return visitChildren(ctx); } 35 | /** 36 | * {@inheritDoc} 37 | * 38 | *

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

40 | */ 41 | @Override public T visitValue(MegaAsmParser.ValueContext ctx) { return visitChildren(ctx); } 42 | /** 43 | * {@inheritDoc} 44 | * 45 | *

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

47 | */ 48 | @Override public T visitAddressed(MegaAsmParser.AddressedContext ctx) { return visitChildren(ctx); } 49 | /** 50 | * {@inheritDoc} 51 | * 52 | *

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

54 | */ 55 | @Override public T visitIndex(MegaAsmParser.IndexContext ctx) { return visitChildren(ctx); } 56 | /** 57 | * {@inheritDoc} 58 | * 59 | *

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

61 | */ 62 | @Override public T visitImmediate(MegaAsmParser.ImmediateContext ctx) { return visitChildren(ctx); } 63 | /** 64 | * {@inheritDoc} 65 | * 66 | *

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

68 | */ 69 | @Override public T visitFloatimmediate(MegaAsmParser.FloatimmediateContext ctx) { return visitChildren(ctx); } 70 | /** 71 | * {@inheritDoc} 72 | * 73 | *

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

75 | */ 76 | @Override public T visitStringimmediate(MegaAsmParser.StringimmediateContext ctx) { return visitChildren(ctx); } 77 | /** 78 | * {@inheritDoc} 79 | * 80 | *

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

82 | */ 83 | @Override public T visitAbsAddress(MegaAsmParser.AbsAddressContext ctx) { return visitChildren(ctx); } 84 | /** 85 | * {@inheritDoc} 86 | * 87 | *

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

89 | */ 90 | @Override public T visitTypeName(MegaAsmParser.TypeNameContext ctx) { return visitChildren(ctx); } 91 | /** 92 | * {@inheritDoc} 93 | * 94 | *

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

96 | */ 97 | @Override public T visitInstrukcja(MegaAsmParser.InstrukcjaContext ctx) { return visitChildren(ctx); } 98 | /** 99 | * {@inheritDoc} 100 | * 101 | *

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

103 | */ 104 | @Override public T visitLinia(MegaAsmParser.LiniaContext ctx) { return visitChildren(ctx); } 105 | /** 106 | * {@inheritDoc} 107 | * 108 | *

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

110 | */ 111 | @Override public T visitTarget(MegaAsmParser.TargetContext ctx) { return visitChildren(ctx); } 112 | /** 113 | * {@inheritDoc} 114 | * 115 | *

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

117 | */ 118 | @Override public T visitArg(MegaAsmParser.ArgContext ctx) { return visitChildren(ctx); } 119 | /** 120 | * {@inheritDoc} 121 | * 122 | *

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

124 | */ 125 | @Override public T visitIdentifier(MegaAsmParser.IdentifierContext ctx) { return visitChildren(ctx); } 126 | /** 127 | * {@inheritDoc} 128 | * 129 | *

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

131 | */ 132 | @Override public T visitSimpleIdentifier(MegaAsmParser.SimpleIdentifierContext ctx) { return visitChildren(ctx); } 133 | /** 134 | * {@inheritDoc} 135 | * 136 | *

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

138 | */ 139 | @Override public T visitAssemblerBody(MegaAsmParser.AssemblerBodyContext ctx) { return visitChildren(ctx); } 140 | /** 141 | * {@inheritDoc} 142 | * 143 | *

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

145 | */ 146 | @Override public T visitMultiLineStringLiteral(MegaAsmParser.MultiLineStringLiteralContext ctx) { return visitChildren(ctx); } 147 | /** 148 | * {@inheritDoc} 149 | * 150 | *

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

152 | */ 153 | @Override public T visitMultiLineStringContent(MegaAsmParser.MultiLineStringContentContext ctx) { return visitChildren(ctx); } 154 | /** 155 | * {@inheritDoc} 156 | * 157 | *

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

159 | */ 160 | @Override public T visitLineStringLiteral(MegaAsmParser.LineStringLiteralContext ctx) { return visitChildren(ctx); } 161 | /** 162 | * {@inheritDoc} 163 | * 164 | *

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

166 | */ 167 | @Override public T visitLineStringContent(MegaAsmParser.LineStringContentContext ctx) { return visitChildren(ctx); } 168 | } -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/MegaAsmParserVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from MegaAsmParser.g4 by ANTLR 4.5.1 2 | package pl.qus.wolin; 3 | import org.antlr.v4.runtime.tree.ParseTreeVisitor; 4 | 5 | /** 6 | * This interface defines a complete generic visitor for a parse tree produced 7 | * by {@link MegaAsmParser}. 8 | * 9 | * @param The return type of the visit operation. Use {@link Void} for 10 | * operations with no return type. 11 | */ 12 | public interface MegaAsmParserVisitor extends ParseTreeVisitor { 13 | /** 14 | * Visit a parse tree produced by {@link MegaAsmParser#pseudoAsmFile}. 15 | * @param ctx the parse tree 16 | * @return the visitor result 17 | */ 18 | T visitPseudoAsmFile(MegaAsmParser.PseudoAsmFileContext ctx); 19 | /** 20 | * Visit a parse tree produced by {@link MegaAsmParser#referencer}. 21 | * @param ctx the parse tree 22 | * @return the visitor result 23 | */ 24 | T visitReferencer(MegaAsmParser.ReferencerContext ctx); 25 | /** 26 | * Visit a parse tree produced by {@link MegaAsmParser#operand}. 27 | * @param ctx the parse tree 28 | * @return the visitor result 29 | */ 30 | T visitOperand(MegaAsmParser.OperandContext ctx); 31 | /** 32 | * Visit a parse tree produced by {@link MegaAsmParser#value}. 33 | * @param ctx the parse tree 34 | * @return the visitor result 35 | */ 36 | T visitValue(MegaAsmParser.ValueContext ctx); 37 | /** 38 | * Visit a parse tree produced by {@link MegaAsmParser#addressed}. 39 | * @param ctx the parse tree 40 | * @return the visitor result 41 | */ 42 | T visitAddressed(MegaAsmParser.AddressedContext ctx); 43 | /** 44 | * Visit a parse tree produced by {@link MegaAsmParser#index}. 45 | * @param ctx the parse tree 46 | * @return the visitor result 47 | */ 48 | T visitIndex(MegaAsmParser.IndexContext ctx); 49 | /** 50 | * Visit a parse tree produced by {@link MegaAsmParser#immediate}. 51 | * @param ctx the parse tree 52 | * @return the visitor result 53 | */ 54 | T visitImmediate(MegaAsmParser.ImmediateContext ctx); 55 | /** 56 | * Visit a parse tree produced by {@link MegaAsmParser#floatimmediate}. 57 | * @param ctx the parse tree 58 | * @return the visitor result 59 | */ 60 | T visitFloatimmediate(MegaAsmParser.FloatimmediateContext ctx); 61 | /** 62 | * Visit a parse tree produced by {@link MegaAsmParser#stringimmediate}. 63 | * @param ctx the parse tree 64 | * @return the visitor result 65 | */ 66 | T visitStringimmediate(MegaAsmParser.StringimmediateContext ctx); 67 | /** 68 | * Visit a parse tree produced by {@link MegaAsmParser#absAddress}. 69 | * @param ctx the parse tree 70 | * @return the visitor result 71 | */ 72 | T visitAbsAddress(MegaAsmParser.AbsAddressContext ctx); 73 | /** 74 | * Visit a parse tree produced by {@link MegaAsmParser#typeName}. 75 | * @param ctx the parse tree 76 | * @return the visitor result 77 | */ 78 | T visitTypeName(MegaAsmParser.TypeNameContext ctx); 79 | /** 80 | * Visit a parse tree produced by {@link MegaAsmParser#instrukcja}. 81 | * @param ctx the parse tree 82 | * @return the visitor result 83 | */ 84 | T visitInstrukcja(MegaAsmParser.InstrukcjaContext ctx); 85 | /** 86 | * Visit a parse tree produced by {@link MegaAsmParser#linia}. 87 | * @param ctx the parse tree 88 | * @return the visitor result 89 | */ 90 | T visitLinia(MegaAsmParser.LiniaContext ctx); 91 | /** 92 | * Visit a parse tree produced by {@link MegaAsmParser#target}. 93 | * @param ctx the parse tree 94 | * @return the visitor result 95 | */ 96 | T visitTarget(MegaAsmParser.TargetContext ctx); 97 | /** 98 | * Visit a parse tree produced by {@link MegaAsmParser#arg}. 99 | * @param ctx the parse tree 100 | * @return the visitor result 101 | */ 102 | T visitArg(MegaAsmParser.ArgContext ctx); 103 | /** 104 | * Visit a parse tree produced by {@link MegaAsmParser#identifier}. 105 | * @param ctx the parse tree 106 | * @return the visitor result 107 | */ 108 | T visitIdentifier(MegaAsmParser.IdentifierContext ctx); 109 | /** 110 | * Visit a parse tree produced by {@link MegaAsmParser#simpleIdentifier}. 111 | * @param ctx the parse tree 112 | * @return the visitor result 113 | */ 114 | T visitSimpleIdentifier(MegaAsmParser.SimpleIdentifierContext ctx); 115 | /** 116 | * Visit a parse tree produced by {@link MegaAsmParser#assemblerBody}. 117 | * @param ctx the parse tree 118 | * @return the visitor result 119 | */ 120 | T visitAssemblerBody(MegaAsmParser.AssemblerBodyContext ctx); 121 | /** 122 | * Visit a parse tree produced by {@link MegaAsmParser#multiLineStringLiteral}. 123 | * @param ctx the parse tree 124 | * @return the visitor result 125 | */ 126 | T visitMultiLineStringLiteral(MegaAsmParser.MultiLineStringLiteralContext ctx); 127 | /** 128 | * Visit a parse tree produced by {@link MegaAsmParser#multiLineStringContent}. 129 | * @param ctx the parse tree 130 | * @return the visitor result 131 | */ 132 | T visitMultiLineStringContent(MegaAsmParser.MultiLineStringContentContext ctx); 133 | /** 134 | * Visit a parse tree produced by {@link MegaAsmParser#lineStringLiteral}. 135 | * @param ctx the parse tree 136 | * @return the visitor result 137 | */ 138 | T visitLineStringLiteral(MegaAsmParser.LineStringLiteralContext ctx); 139 | /** 140 | * Visit a parse tree produced by {@link MegaAsmParser#lineStringContent}. 141 | * @param ctx the parse tree 142 | * @return the visitor result 143 | */ 144 | T visitLineStringContent(MegaAsmParser.LineStringContentContext ctx); 145 | } -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/PseudoAsmLexer.tokens: -------------------------------------------------------------------------------- 1 | DelimitedComment=1 2 | LineComment=2 3 | WS=3 4 | NL=4 5 | DOT=5 6 | HASH=6 7 | LANGLE=7 8 | RANGLE=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | ASSIGNMENT=13 14 | COMMA=14 15 | QUEST=15 16 | AT=16 17 | ARROW=17 18 | MOD=18 19 | DOLLAR=19 20 | REFERENCE=20 21 | DEREFERENCE=21 22 | QUOTE_OPEN=22 23 | TRIPLE_QUOTE_OPEN=23 24 | FloatLiteral=24 25 | DoubleLiteral=25 26 | IntegerLiteral=26 27 | Identifier=27 28 | UNICODE_CLASS_LL=28 29 | UNICODE_CLASS_LM=29 30 | UNICODE_CLASS_LO=30 31 | UNICODE_CLASS_LT=31 32 | UNICODE_CLASS_LU=32 33 | UNICODE_CLASS_ND=33 34 | UNICODE_CLASS_NL=34 35 | QUOTE_CLOSE=35 36 | LineStrText=36 37 | LineStrEscapedChar=37 38 | TRIPLE_QUOTE_CLOSE=38 39 | MultiLineStringQuote=39 40 | MultiLineStrText=40 41 | MultiLineStrEscapedChar=41 42 | MultiLineNL=42 43 | '.'=5 44 | '#'=6 45 | '<'=7 46 | '>'=8 47 | '('=9 48 | ')'=10 49 | '['=11 50 | ']'=12 51 | '='=13 52 | ','=14 53 | '?'=15 54 | '@'=16 55 | '->'=17 56 | '%'=18 57 | '$'=19 58 | '*'=20 59 | '&'=21 60 | '"""'=23 61 | -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/PseudoAsmParser.tokens: -------------------------------------------------------------------------------- 1 | DelimitedComment=1 2 | LineComment=2 3 | WS=3 4 | NL=4 5 | DOT=5 6 | HASH=6 7 | LANGLE=7 8 | RANGLE=8 9 | LPAREN=9 10 | RPAREN=10 11 | LSQUARE=11 12 | RSQUARE=12 13 | ASSIGNMENT=13 14 | COMMA=14 15 | QUEST=15 16 | AT=16 17 | ARROW=17 18 | MOD=18 19 | DOLLAR=19 20 | REFERENCE=20 21 | DEREFERENCE=21 22 | QUOTE_OPEN=22 23 | TRIPLE_QUOTE_OPEN=23 24 | FloatLiteral=24 25 | DoubleLiteral=25 26 | IntegerLiteral=26 27 | Identifier=27 28 | UNICODE_CLASS_LL=28 29 | UNICODE_CLASS_LM=29 30 | UNICODE_CLASS_LO=30 31 | UNICODE_CLASS_LT=31 32 | UNICODE_CLASS_LU=32 33 | UNICODE_CLASS_ND=33 34 | UNICODE_CLASS_NL=34 35 | QUOTE_CLOSE=35 36 | LineStrText=36 37 | LineStrEscapedChar=37 38 | TRIPLE_QUOTE_CLOSE=38 39 | MultiLineStringQuote=39 40 | MultiLineStrText=40 41 | MultiLineStrEscapedChar=41 42 | MultiLineNL=42 43 | '.'=5 44 | '#'=6 45 | '<'=7 46 | '>'=8 47 | '('=9 48 | ')'=10 49 | '['=11 50 | ']'=12 51 | '='=13 52 | ','=14 53 | '?'=15 54 | '@'=16 55 | '->'=17 56 | '%'=18 57 | '$'=19 58 | '*'=20 59 | '&'=21 60 | '"""'=23 61 | -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/PseudoAsmParserVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from PseudoAsmParser.g4 by ANTLR 4.5.1 2 | package pl.qus.wolin; 3 | import org.antlr.v4.runtime.tree.ParseTreeVisitor; 4 | 5 | /** 6 | * This interface defines a complete generic visitor for a parse tree produced 7 | * by {@link PseudoAsmParser}. 8 | * 9 | * @param The return type of the visit operation. Use {@link Void} for 10 | * operations with no return type. 11 | */ 12 | public interface PseudoAsmParserVisitor extends ParseTreeVisitor { 13 | /** 14 | * Visit a parse tree produced by {@link PseudoAsmParser#pseudoAsmFile}. 15 | * @param ctx the parse tree 16 | * @return the visitor result 17 | */ 18 | T visitPseudoAsmFile(PseudoAsmParser.PseudoAsmFileContext ctx); 19 | /** 20 | * Visit a parse tree produced by {@link PseudoAsmParser#jocker}. 21 | * @param ctx the parse tree 22 | * @return the visitor result 23 | */ 24 | T visitJocker(PseudoAsmParser.JockerContext ctx); 25 | /** 26 | * Visit a parse tree produced by {@link PseudoAsmParser#referencer}. 27 | * @param ctx the parse tree 28 | * @return the visitor result 29 | */ 30 | T visitReferencer(PseudoAsmParser.ReferencerContext ctx); 31 | /** 32 | * Visit a parse tree produced by {@link PseudoAsmParser#operand}. 33 | * @param ctx the parse tree 34 | * @return the visitor result 35 | */ 36 | T visitOperand(PseudoAsmParser.OperandContext ctx); 37 | /** 38 | * Visit a parse tree produced by {@link PseudoAsmParser#value}. 39 | * @param ctx the parse tree 40 | * @return the visitor result 41 | */ 42 | T visitValue(PseudoAsmParser.ValueContext ctx); 43 | /** 44 | * Visit a parse tree produced by {@link PseudoAsmParser#addressed}. 45 | * @param ctx the parse tree 46 | * @return the visitor result 47 | */ 48 | T visitAddressed(PseudoAsmParser.AddressedContext ctx); 49 | /** 50 | * Visit a parse tree produced by {@link PseudoAsmParser#index}. 51 | * @param ctx the parse tree 52 | * @return the visitor result 53 | */ 54 | T visitIndex(PseudoAsmParser.IndexContext ctx); 55 | /** 56 | * Visit a parse tree produced by {@link PseudoAsmParser#immediate}. 57 | * @param ctx the parse tree 58 | * @return the visitor result 59 | */ 60 | T visitImmediate(PseudoAsmParser.ImmediateContext ctx); 61 | /** 62 | * Visit a parse tree produced by {@link PseudoAsmParser#floatimmediate}. 63 | * @param ctx the parse tree 64 | * @return the visitor result 65 | */ 66 | T visitFloatimmediate(PseudoAsmParser.FloatimmediateContext ctx); 67 | /** 68 | * Visit a parse tree produced by {@link PseudoAsmParser#stringimmediate}. 69 | * @param ctx the parse tree 70 | * @return the visitor result 71 | */ 72 | T visitStringimmediate(PseudoAsmParser.StringimmediateContext ctx); 73 | /** 74 | * Visit a parse tree produced by {@link PseudoAsmParser#absAddress}. 75 | * @param ctx the parse tree 76 | * @return the visitor result 77 | */ 78 | T visitAbsAddress(PseudoAsmParser.AbsAddressContext ctx); 79 | /** 80 | * Visit a parse tree produced by {@link PseudoAsmParser#name}. 81 | * @param ctx the parse tree 82 | * @return the visitor result 83 | */ 84 | T visitName(PseudoAsmParser.NameContext ctx); 85 | /** 86 | * Visit a parse tree produced by {@link PseudoAsmParser#typeName}. 87 | * @param ctx the parse tree 88 | * @return the visitor result 89 | */ 90 | T visitTypeName(PseudoAsmParser.TypeNameContext ctx); 91 | /** 92 | * Visit a parse tree produced by {@link PseudoAsmParser#instrukcja}. 93 | * @param ctx the parse tree 94 | * @return the visitor result 95 | */ 96 | T visitInstrukcja(PseudoAsmParser.InstrukcjaContext ctx); 97 | /** 98 | * Visit a parse tree produced by {@link PseudoAsmParser#linia}. 99 | * @param ctx the parse tree 100 | * @return the visitor result 101 | */ 102 | T visitLinia(PseudoAsmParser.LiniaContext ctx); 103 | /** 104 | * Visit a parse tree produced by {@link PseudoAsmParser#target}. 105 | * @param ctx the parse tree 106 | * @return the visitor result 107 | */ 108 | T visitTarget(PseudoAsmParser.TargetContext ctx); 109 | /** 110 | * Visit a parse tree produced by {@link PseudoAsmParser#arg}. 111 | * @param ctx the parse tree 112 | * @return the visitor result 113 | */ 114 | T visitArg(PseudoAsmParser.ArgContext ctx); 115 | /** 116 | * Visit a parse tree produced by {@link PseudoAsmParser#identifier}. 117 | * @param ctx the parse tree 118 | * @return the visitor result 119 | */ 120 | T visitIdentifier(PseudoAsmParser.IdentifierContext ctx); 121 | /** 122 | * Visit a parse tree produced by {@link PseudoAsmParser#simpleIdentifier}. 123 | * @param ctx the parse tree 124 | * @return the visitor result 125 | */ 126 | T visitSimpleIdentifier(PseudoAsmParser.SimpleIdentifierContext ctx); 127 | /** 128 | * Visit a parse tree produced by {@link PseudoAsmParser#assemblerBody}. 129 | * @param ctx the parse tree 130 | * @return the visitor result 131 | */ 132 | T visitAssemblerBody(PseudoAsmParser.AssemblerBodyContext ctx); 133 | /** 134 | * Visit a parse tree produced by {@link PseudoAsmParser#multiLineStringLiteral}. 135 | * @param ctx the parse tree 136 | * @return the visitor result 137 | */ 138 | T visitMultiLineStringLiteral(PseudoAsmParser.MultiLineStringLiteralContext ctx); 139 | /** 140 | * Visit a parse tree produced by {@link PseudoAsmParser#multiLineStringContent}. 141 | * @param ctx the parse tree 142 | * @return the visitor result 143 | */ 144 | T visitMultiLineStringContent(PseudoAsmParser.MultiLineStringContentContext ctx); 145 | /** 146 | * Visit a parse tree produced by {@link PseudoAsmParser#lineStringLiteral}. 147 | * @param ctx the parse tree 148 | * @return the visitor result 149 | */ 150 | T visitLineStringLiteral(PseudoAsmParser.LineStringLiteralContext ctx); 151 | /** 152 | * Visit a parse tree produced by {@link PseudoAsmParser#lineStringContent}. 153 | * @param ctx the parse tree 154 | * @return the visitor result 155 | */ 156 | T visitLineStringContent(PseudoAsmParser.LineStringContentContext ctx); 157 | } -------------------------------------------------------------------------------- /src/main/java/pl/qus/wolin/UnicodeClasses.tokens: -------------------------------------------------------------------------------- 1 | UNICODE_CLASS_LL=1 2 | UNICODE_CLASS_LM=2 3 | UNICODE_CLASS_LO=3 4 | UNICODE_CLASS_LT=4 5 | UNICODE_CLASS_LU=5 6 | UNICODE_CLASS_ND=6 7 | UNICODE_CLASS_NL=7 8 | -------------------------------------------------------------------------------- /src/main/kotlin/Gui.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin 2 | 3 | import javafx.application.Platform 4 | import javafx.beans.property.SimpleStringProperty 5 | import javafx.collections.FXCollections 6 | import javafx.scene.control.* 7 | import javafx.scene.layout.VBox 8 | import javafx.scene.text.Font 9 | import org.apache.commons.net.telnet.TelnetClient 10 | import tornadofx.* 11 | import java.io.PrintStream 12 | import kotlin.system.exitProcess 13 | 14 | class MyApp : App(MyView::class) 15 | 16 | class MyView : View() { 17 | companion object { 18 | const val inputFieldId = "inputField" 19 | } 20 | 21 | override val root: VBox by fxml() 22 | 23 | val spDump: TextArea by fxid() 24 | val spfDump: TextArea by fxid() 25 | val cpuDump: TextArea by fxid() 26 | val commandLine: TextField by fxid() 27 | val debugList: ListView by fxid() 28 | val sourceList: ListView by fxid() 29 | 30 | val stepOver: Button by fxid() 31 | val stepInto: Button by fxid() 32 | val doContinue: Button by fxid() 33 | 34 | val inputText = SimpleStringProperty() 35 | val spText = SimpleStringProperty() 36 | val spfText = SimpleStringProperty() 37 | val cpuText = SimpleStringProperty() 38 | 39 | val debugger = Debugger2(this) 40 | 41 | val data = FXCollections.observableArrayList() 42 | 43 | override fun onDock() { 44 | currentWindow?.onHidingProperty()?.onChangeOnce { 45 | debugger.shouldRun = false 46 | exit() 47 | } 48 | } 49 | 50 | override fun onBeforeShow() { 51 | super.onBeforeShow() 52 | 53 | stepOver.setOnAction { 54 | processCommand("n") 55 | } 56 | stepInto.setOnAction { 57 | processCommand("z") 58 | } 59 | doContinue.setOnAction { 60 | processCommand("x") 61 | } 62 | 63 | spDump.bind(spText) 64 | spfDump.bind(spfText) 65 | cpuDump.bind(cpuText) 66 | commandLine.bind(inputText) 67 | commandLine.setOnAction { 68 | val command = commandLine.text 69 | commandLine.text = "" 70 | processCommand(command) 71 | } 72 | debugList.items = data 73 | 74 | 75 | // debugList.setCellFactory { 76 | // object: ListCell() { 77 | // override fun updateItem(item: String?, empty: Boolean) { 78 | // super.updateItem(item, empty) 79 | // 80 | // if(item != null) { 81 | // text = item 82 | // font = Font("Consolas", 12.0) 83 | // } 84 | // } 85 | // } 86 | // } 87 | 88 | debugger.start() 89 | 90 | } 91 | 92 | 93 | private fun processCommand(line: String) { 94 | val tokens = line.split(" ").map { it.trim() } 95 | 96 | when (tokens[0]) { 97 | "quit" -> { 98 | debugger.shouldRun = false 99 | exit() 100 | } 101 | "lbreak" -> { 102 | debugger.setLineBreakpoint(tokens) 103 | } 104 | else -> { 105 | debugger.sendCommandAsync(line) 106 | } 107 | } 108 | } 109 | 110 | 111 | fun exit() { 112 | Platform.exit() 113 | exitProcess(0) 114 | } 115 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/ParseTreeHelper.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin 2 | 3 | import org.antlr.v4.runtime.ParserRuleContext 4 | import org.antlr.v4.runtime.tree.ParseTree 5 | import org.antlr.v4.runtime.tree.TerminalNodeImpl 6 | 7 | //fun ParseTree.child(nr: Int): ParseTree? = try { 8 | // if (this is ParserRuleContext) { 9 | // this.children[nr] 10 | // } else 11 | // null 12 | //} catch (ex: Exception) { 13 | // null 14 | //} 15 | // 16 | //val ParseTree.iterable: Iterable 17 | // get() { 18 | // return object : Iterable { 19 | // override fun iterator(): Iterator { 20 | // return when { 21 | // this@iterable is ParserRuleContext -> return object : Iterator { 22 | // var dzieć = -1 23 | // override fun hasNext(): Boolean { 24 | // return dzieć < children.size - 1 25 | // } 26 | // 27 | // override fun next(): ParseTree { 28 | // return this@iterable.children[++dzieć] 29 | // } 30 | // 31 | // } 32 | // this@iterable is TerminalNodeImpl -> object : Iterator { 33 | // override fun hasNext(): Boolean { 34 | // return false 35 | // } 36 | // 37 | // override fun next(): ParseTree { 38 | // throw Exception("Terminal node!") 39 | // } 40 | // } 41 | // else -> throw Exception("Don't know how to iterate this!") 42 | // } 43 | // } 44 | // } 45 | // } 46 | 47 | fun dump(pt: ParseTree, level: Int): String { 48 | return " ".repeat(level) + when (pt) { 49 | is ParserRuleContext -> pt.javaClass.simpleName + "\n" + 50 | pt.children?.joinToString("") { 51 | dump(it, level + 1) 52 | } 53 | is TerminalNodeImpl -> "${pt.text}<<<--- TERMINAL\n" 54 | else -> "???\n" 55 | } 56 | } 57 | 58 | //fun ParseTree.traverseFilter(lista: MutableList, filter: (ParseTree) -> Boolean): MutableList { 59 | // if(filter(this)) 60 | // lista.add(this) 61 | // 62 | // when (this) { 63 | // is ParserRuleContext -> { 64 | // this.children.forEach { 65 | // it.traverseFilter(lista, filter) 66 | // } 67 | // } 68 | // } 69 | // 70 | // return lista 71 | //} 72 | // 73 | //fun ParseTree.any(filter: (ParseTree) -> Boolean): Boolean { 74 | // return if(filter(this)) 75 | // return true 76 | // else 77 | // when (this) { 78 | // is ParserRuleContext -> { 79 | // this.children.any { 80 | // it.any(filter) 81 | // } 82 | // } 83 | // else -> false 84 | // } 85 | //} 86 | // 87 | -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/PseudoAsmParserVisitor.java: -------------------------------------------------------------------------------- 1 | // Generated from PseudoAsmParser.g4 by ANTLR 4.5.1 2 | package pl.qus.wolin; 3 | import org.antlr.v4.runtime.tree.ParseTreeVisitor; 4 | 5 | /** 6 | * This interface defines a complete generic visitor for a parse tree produced 7 | * by {@link PseudoAsmParser}. 8 | * 9 | * @param The return type of the visit operation. Use {@link Void} for 10 | * operations with no return type. 11 | */ 12 | public interface PseudoAsmParserVisitor extends ParseTreeVisitor { 13 | /** 14 | * Visit a parse tree produced by {@link PseudoAsmParser#pseudoAsmFile}. 15 | * @param ctx the parse tree 16 | * @return the visitor result 17 | */ 18 | T visitPseudoAsmFile(PseudoAsmParser.PseudoAsmFileContext ctx); 19 | /** 20 | * Visit a parse tree produced by {@link PseudoAsmParser#jocker}. 21 | * @param ctx the parse tree 22 | * @return the visitor result 23 | */ 24 | T visitJocker(PseudoAsmParser.JockerContext ctx); 25 | /** 26 | * Visit a parse tree produced by {@link PseudoAsmParser#referencer}. 27 | * @param ctx the parse tree 28 | * @return the visitor result 29 | */ 30 | T visitReferencer(PseudoAsmParser.ReferencerContext ctx); 31 | /** 32 | * Visit a parse tree produced by {@link PseudoAsmParser#operand}. 33 | * @param ctx the parse tree 34 | * @return the visitor result 35 | */ 36 | T visitOperand(PseudoAsmParser.OperandContext ctx); 37 | /** 38 | * Visit a parse tree produced by {@link PseudoAsmParser#value}. 39 | * @param ctx the parse tree 40 | * @return the visitor result 41 | */ 42 | T visitValue(PseudoAsmParser.ValueContext ctx); 43 | /** 44 | * Visit a parse tree produced by {@link PseudoAsmParser#addressed}. 45 | * @param ctx the parse tree 46 | * @return the visitor result 47 | */ 48 | T visitAddressed(PseudoAsmParser.AddressedContext ctx); 49 | /** 50 | * Visit a parse tree produced by {@link PseudoAsmParser#index}. 51 | * @param ctx the parse tree 52 | * @return the visitor result 53 | */ 54 | T visitIndex(PseudoAsmParser.IndexContext ctx); 55 | /** 56 | * Visit a parse tree produced by {@link PseudoAsmParser#immediate}. 57 | * @param ctx the parse tree 58 | * @return the visitor result 59 | */ 60 | T visitImmediate(PseudoAsmParser.ImmediateContext ctx); 61 | /** 62 | * Visit a parse tree produced by {@link PseudoAsmParser#floatimmediate}. 63 | * @param ctx the parse tree 64 | * @return the visitor result 65 | */ 66 | T visitFloatimmediate(PseudoAsmParser.FloatimmediateContext ctx); 67 | /** 68 | * Visit a parse tree produced by {@link PseudoAsmParser#stringimmediate}. 69 | * @param ctx the parse tree 70 | * @return the visitor result 71 | */ 72 | T visitStringimmediate(PseudoAsmParser.StringimmediateContext ctx); 73 | /** 74 | * Visit a parse tree produced by {@link PseudoAsmParser#absAddress}. 75 | * @param ctx the parse tree 76 | * @return the visitor result 77 | */ 78 | T visitAbsAddress(PseudoAsmParser.AbsAddressContext ctx); 79 | /** 80 | * Visit a parse tree produced by {@link PseudoAsmParser#name}. 81 | * @param ctx the parse tree 82 | * @return the visitor result 83 | */ 84 | T visitName(PseudoAsmParser.NameContext ctx); 85 | /** 86 | * Visit a parse tree produced by {@link PseudoAsmParser#typeName}. 87 | * @param ctx the parse tree 88 | * @return the visitor result 89 | */ 90 | T visitTypeName(PseudoAsmParser.TypeNameContext ctx); 91 | /** 92 | * Visit a parse tree produced by {@link PseudoAsmParser#instrukcja}. 93 | * @param ctx the parse tree 94 | * @return the visitor result 95 | */ 96 | T visitInstrukcja(PseudoAsmParser.InstrukcjaContext ctx); 97 | /** 98 | * Visit a parse tree produced by {@link PseudoAsmParser#linia}. 99 | * @param ctx the parse tree 100 | * @return the visitor result 101 | */ 102 | T visitLinia(PseudoAsmParser.LiniaContext ctx); 103 | /** 104 | * Visit a parse tree produced by {@link PseudoAsmParser#target}. 105 | * @param ctx the parse tree 106 | * @return the visitor result 107 | */ 108 | T visitTarget(PseudoAsmParser.TargetContext ctx); 109 | /** 110 | * Visit a parse tree produced by {@link PseudoAsmParser#arg}. 111 | * @param ctx the parse tree 112 | * @return the visitor result 113 | */ 114 | T visitArg(PseudoAsmParser.ArgContext ctx); 115 | /** 116 | * Visit a parse tree produced by {@link PseudoAsmParser#identifier}. 117 | * @param ctx the parse tree 118 | * @return the visitor result 119 | */ 120 | T visitIdentifier(PseudoAsmParser.IdentifierContext ctx); 121 | /** 122 | * Visit a parse tree produced by {@link PseudoAsmParser#simpleIdentifier}. 123 | * @param ctx the parse tree 124 | * @return the visitor result 125 | */ 126 | T visitSimpleIdentifier(PseudoAsmParser.SimpleIdentifierContext ctx); 127 | /** 128 | * Visit a parse tree produced by {@link PseudoAsmParser#assemblerBody}. 129 | * @param ctx the parse tree 130 | * @return the visitor result 131 | */ 132 | T visitAssemblerBody(PseudoAsmParser.AssemblerBodyContext ctx); 133 | /** 134 | * Visit a parse tree produced by {@link PseudoAsmParser#multiLineStringLiteral}. 135 | * @param ctx the parse tree 136 | * @return the visitor result 137 | */ 138 | T visitMultiLineStringLiteral(PseudoAsmParser.MultiLineStringLiteralContext ctx); 139 | /** 140 | * Visit a parse tree produced by {@link PseudoAsmParser#multiLineStringContent}. 141 | * @param ctx the parse tree 142 | * @return the visitor result 143 | */ 144 | T visitMultiLineStringContent(PseudoAsmParser.MultiLineStringContentContext ctx); 145 | /** 146 | * Visit a parse tree produced by {@link PseudoAsmParser#lineStringLiteral}. 147 | * @param ctx the parse tree 148 | * @return the visitor result 149 | */ 150 | T visitLineStringLiteral(PseudoAsmParser.LineStringLiteralContext ctx); 151 | /** 152 | * Visit a parse tree produced by {@link PseudoAsmParser#lineStringContent}. 153 | * @param ctx the parse tree 154 | * @return the visitor result 155 | */ 156 | T visitLineStringContent(PseudoAsmParser.LineStringContentContext ctx); 157 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/PseudoAsmStateObject.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin 2 | 3 | class PseudoAsmStateObject { 4 | var reversePhase: Boolean = false 5 | var replaced: Boolean = false 6 | var insideOptimizedReg: Int = -1 7 | var assemblerLine: PseudoAsmParser.LiniaContext? = null 8 | var matched: PseudoAsmParser.LiniaContext? = null 9 | var tekstProgramu: String = "" 10 | 11 | val pary = mutableListOf>() 12 | 13 | fun code(kod: String) { 14 | tekstProgramu += "$kod\n" 15 | } 16 | 17 | fun dumpCode() = tekstProgramu 18 | 19 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/AllocType.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | enum class AllocType { LITERAL, FIXED, NORMAL } 4 | -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/AssignStack.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | import java.lang.Exception 4 | import java.util.* 5 | 6 | class AssignEntry { 7 | internal lateinit var left: Zmienna 8 | internal lateinit var right: Zmienna 9 | var isArray: Boolean = false 10 | } 11 | 12 | class AssignStack : Stack() { 13 | var assignLeftSideVar: Zmienna 14 | get() = peek().left 15 | set(value) { peek().left = value } 16 | 17 | var assignRightSideFinalVar: Zmienna 18 | get() = peek().right 19 | set(value) { peek().right = value } 20 | 21 | var arrayAssign: Boolean 22 | get() = peek().isArray 23 | set(value) { peek().isArray = value } 24 | 25 | val processingLeftSide: Boolean 26 | get() { 27 | val leftOk = try { 28 | assignLeftSideVar 29 | true 30 | } catch (ex: Exception) { false } 31 | val rithBlank = try { 32 | assignLeftSideVar 33 | false 34 | } catch (ex: Exception) { true } 35 | 36 | return leftOk && rithBlank 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/FieldType.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | enum class FieldType { 4 | STATIC, LOCAL, ARGUMENT, CLASS, OP_STACK, DUMMY 5 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/Funkcja.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | import pl.qus.wolin.KotlinParser 4 | import pl.qus.wolin.WolinStateObject 5 | import pl.qus.wolin.hex 6 | import java.lang.Exception 7 | 8 | class Funkcja( 9 | var fullName: String = "", 10 | var type: Typ = Typ.unit, 11 | 12 | var location: Int = 0, 13 | var lambdaBody: KotlinParser.StatementsContext? = null // dla lambd 14 | ) { 15 | 16 | var iscc65: Boolean = false 17 | var isExternal: Boolean = false 18 | //var startReg: Int = -1 19 | 20 | var fullReturnType: Zmienna? = null 21 | 22 | var returnAddress: Int = -1 23 | 24 | var isInterrupt: Boolean = false 25 | 26 | val returnName: String 27 | get() = "$fullName.__returnValue" 28 | 29 | val arguments: List 30 | get() = fields.filter { it.fieldType == FieldType.ARGUMENT } 31 | val locals: List 32 | get() = fields.filter { it.fieldType != FieldType.ARGUMENT } 33 | 34 | val labelName: String get() = 35 | when { 36 | isExternal -> fullName.split(".").last() 37 | iscc65 -> "_"+fullName.split(".").last() 38 | else -> "__wolin_${fullName.replace(".", "_")}" 39 | } 40 | var fields: MutableList = mutableListOf() 41 | 42 | //val calledFunctions = mutableListOf() 43 | 44 | fun addField(nowa: Zmienna) { 45 | if (fields.none { it.name == nowa.name }) 46 | fields.add(nowa) 47 | } 48 | 49 | override fun toString(): String = "fun $fullName(${arguments.joinToString()}):${type.name}" 50 | 51 | fun releaseCalledFunction(state: WolinStateObject) { 52 | try { 53 | state.fnCallReleaseRet(this) 54 | if (this.type != Typ.unit) 55 | state.code("free SPF <${this.returnName}>, #${this.type.sizeOnStack} // free return value of ${this.fullName} from call stack") 56 | } catch (ex: Exception) { 57 | val a = state.currentFunction?.fullName 58 | println("Release called function Błąd$$$$ $a") 59 | } 60 | 61 | } 62 | 63 | 64 | // fun releaseCalledFunctionsStack(state: WolinStateObject) { 65 | // calledFunctions.forEach { 66 | // try { 67 | // state.fnCallReleaseRet(it) 68 | // if(it.type != Typ.unit) 69 | // state.code("free SPF <${it.returnName}>, #${it.type.sizeOnStack} // free return value of ${it.fullName} from call stack") 70 | // } catch (ex: Exception) { 71 | // val a = state.currentFunction?.fullName 72 | // println("tu") 73 | // } 74 | // } 75 | // calledFunctions.clear() 76 | // } 77 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/Klasa.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | import pl.qus.wolin.SpecStack 4 | 5 | open class Klasa(val name: String) 6 | { 7 | val children = mutableListOf() 8 | 9 | val uniqId get() = heap.peek().immediateValue 10 | 11 | val heap = SpecStack("HEAP") 12 | 13 | open fun hasChild(childName: String): Boolean = children.any { it.name == childName || it.hasChild(childName) } 14 | 15 | fun toHeapAndVariablary(zmienna: Zmienna) { 16 | if (!heap.any { it.name == zmienna.name }) 17 | heap.push(zmienna) 18 | } 19 | } 20 | 21 | class AnyKlasa(): Klasa("any") { 22 | override fun hasChild(dummy: String): Boolean = true 23 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/Primitives.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | val primitives = setOf("bool", "byte", "ubyte", "word", "uword", "float", "unit") 4 | //enum class Primitives { 5 | // bool, byte, ubyte, word, uword, float 6 | //} -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/RegOper.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | enum class RegOper { 4 | VALUE, AMPRESAND, STAR 5 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/Typ.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | import pl.qus.wolin.WolinStateObject 4 | 5 | data class Typ( 6 | val name: String, 7 | val nulable: Boolean, 8 | var pointer: Boolean = false, 9 | var array: Boolean = false, 10 | var shortIndex: Boolean = false 11 | 12 | ) { 13 | 14 | val isPointer: Boolean 15 | get() { 16 | return when { 17 | array -> true 18 | isFunctional -> true 19 | primitives.contains(name) -> pointer 20 | else -> true 21 | } 22 | } 23 | 24 | fun copy(): Typ { 25 | return Typ( 26 | name, nulable, pointer, array, shortIndex 27 | ) 28 | } 29 | 30 | companion object { 31 | val unit get() = Typ("unit", false) 32 | val bool get() = Typ("bool", false) 33 | val ubyte get() = Typ("ubyte", false) 34 | val uword get() = Typ("uword", false) 35 | val float get() = Typ("float", false) 36 | 37 | fun byName(name: String, state: WolinStateObject): Typ { 38 | // TODO - musimy znaleźć dany typ w skołpie!!! 39 | 40 | val clearName =if (name.endsWith("?")) { 41 | name.dropLast(1) 42 | } else { 43 | name 44 | } 45 | 46 | val qualifiedName = state.findQualifiedType(clearName) 47 | return if(qualifiedName == "string") 48 | Typ("ubyte", name.endsWith("?"), pointer = false, array = true, shortIndex = true) 49 | else 50 | Typ(qualifiedName, name.endsWith("?")) 51 | } 52 | } 53 | 54 | val isUnit get() = name == "unit" 55 | 56 | val isClass get() = name.contains(".") 57 | 58 | val isFunctional get() = name.contains("->") 59 | 60 | val elementOccupiesOneByte: Boolean 61 | get() = if(array) { 62 | when(name) { 63 | "bool" -> true 64 | "ubyte" -> true 65 | "byte" -> true 66 | else -> false 67 | } 68 | } else throw Exception("elementOccupiesOneByte called on non-array!") 69 | 70 | val sizeOnStack: Int 71 | get() = when { 72 | array -> 2 73 | isPointer -> 2 74 | name == "unit" -> 0 75 | name == "bool" -> 1 76 | name == "byte" -> 1 77 | name == "ubyte" -> 1 78 | name == "float" -> 4 // http://6502.org/source/floats/wozfp1.txt 79 | name == "" -> throw Exception("Empty type!!!") 80 | else -> 2 81 | } 82 | 83 | val arrayElementSize: Int 84 | get() = when (name) { 85 | "unit" -> 0 86 | "bool" -> 1 87 | "byte" -> 1 88 | "ubyte" -> 1 89 | "float" -> 4 // http://6502.org/source/floats/wozfp1.txt 90 | "" -> throw Exception("Empty type!!!") 91 | else -> 2 92 | } 93 | 94 | override fun equals(other: Any?): Boolean = if (other is Typ) { 95 | other.name == this.name && other.nulable == this.nulable && other.isPointer == this.isPointer 96 | } else super.equals(other) 97 | 98 | fun canBeAssigned(other: Any?): Boolean = if (other is Typ) { 99 | other.name == this.name && other.nulable == this.nulable 100 | } else super.equals(other) 101 | 102 | override fun toString(): String = name + if (nulable) "?" else "" + if (isPointer) "*" else "" 103 | 104 | val arrayElementType: Typ 105 | get() = Typ(name, nulable, isPointer) 106 | 107 | val typeForAsm: String 108 | get() = 109 | when { 110 | array -> "$name" 111 | isFunctional -> "any" 112 | isUnit -> "unit" 113 | primitives.contains(name) -> name 114 | else -> "any" 115 | } + if(isPointer) "*" else "" 116 | 117 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/components/Zmienna.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.components 2 | 3 | import pl.qus.wolin.KotlinParser 4 | 5 | class Zmienna( 6 | var name: String = "", 7 | var mutable: Boolean = false, 8 | var locationTxt: String? = null, 9 | var allocation: AllocType, 10 | var comment: String = "", 11 | var fieldType: FieldType, 12 | private var typexxx: Typ = Typ.unit, 13 | var initExpression: KotlinParser.ExpressionContext? = null, 14 | var locationVal: Int? = null 15 | ) 16 | 17 | { 18 | var isDereferenced: Boolean = false 19 | var intValue: Long = 0L 20 | var stringValue: String = "" 21 | var floatValue: Float = 0f 22 | var inClass: Klasa? = null 23 | 24 | val immutable get() = !mutable 25 | 26 | var type: Typ 27 | get() { 28 | return typexxx 29 | } 30 | set(value) { 31 | typexxx = value 32 | } 33 | 34 | 35 | override fun toString(): String { 36 | return "$name: $type = $immediateValue /* $comment */" 37 | } 38 | 39 | val labelName: String get() = "__wolin_${name.replace(".","_")}" 40 | 41 | val location: String get() = "${locationVal ?: locationTxt}" 42 | 43 | val immediateValue: String get() = when { 44 | type.name == "bool" -> if(intValue == 0L) "0" else "1" 45 | type.name == "byte" -> "$intValue" 46 | type.name == "ubyte" -> "$intValue" 47 | type.name == "word" -> "$intValue" 48 | type.name == "uword" -> "$intValue" 49 | type.name == "float" -> "$floatValue" 50 | type.isPointer -> "$intValue" 51 | type.isFunctional -> "$intValue" 52 | else -> "65535" 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/exception/FunctionNotFound.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.exception 2 | 3 | import java.lang.Exception 4 | 5 | class FunctionNotFound(s: String) : Exception(s) -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/exception/InterruptFunctionWithLocals.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.exception 2 | 3 | import java.lang.Exception 4 | 5 | class InterruptFunctionWithLocals(s: String) : Exception(s) -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/exception/NoRuleException.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.exception 2 | 3 | import java.lang.Exception 4 | 5 | class NoRuleException(s: String) : Exception(s) -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/exception/RegTypeMismatchException.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.exception 2 | 3 | import java.lang.Exception 4 | 5 | class RegTypeMismatchException(s: String) : Exception(s) -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/exception/ReplaceInArgException.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.exception 2 | 3 | import java.lang.Exception 4 | 5 | class ReplaceInArgException(s: String) : Exception(s) -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/exception/TypeMismatchException.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.exception 2 | 3 | import java.lang.Exception 4 | 5 | class TypeMismatchException(s: String) : Exception(s) -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/exception/UnknownLiteral.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.exception 2 | 3 | import java.lang.Exception 4 | 5 | class UnknownLiteral(s: String) : Exception(s) -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/exception/VariableNotFound.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.exception 2 | 3 | import java.lang.Exception 4 | 5 | class VariableNotFound(s: String) : Exception(s) -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/steps/CompilerProcess.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.pl.qus.wolin.steps 2 | 3 | import pl.qus.wolin.Main.buildPath 4 | import pl.qus.wolin.WolinStateObject 5 | import java.io.* 6 | 7 | 8 | abstract class CompilerProcess { 9 | var inputName: String = "" 10 | var outputName: String = "" 11 | var state: WolinStateObject? = null 12 | 13 | fun chain(next: CompilerProcess, oName: String): CompilerProcess { 14 | next.inputName = outputName 15 | next.outputName = oName 16 | next.state = state 17 | next.execute() 18 | return next 19 | } 20 | 21 | fun execute() { 22 | val istream = FileInputStream(File("$buildPath$inputName")) 23 | val ostream = FileOutputStream(File("$buildPath$outputName")) 24 | 25 | process(istream, ostream) 26 | 27 | try { 28 | istream.close() 29 | } catch (ex: IOException) { 30 | } 31 | try { 32 | ostream.close() 33 | } catch (ex: IOException) { 34 | } 35 | } 36 | 37 | abstract fun process(istream: InputStream, ostream: OutputStream) 38 | } 39 | -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/steps/OptimizerStep.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.pl.qus.wolin.steps 2 | 3 | import org.antlr.v4.runtime.CommonTokenStream 4 | import pl.qus.wolin.PseudoAsmLexer 5 | import pl.qus.wolin.PseudoAsmParser 6 | import pl.qus.wolin.pl.qus.wolin.optimizer.NewOptimizerProcessor 7 | import java.io.InputStream 8 | import java.io.OutputStream 9 | import org.antlr.v4.runtime.ANTLRInputStream 10 | 11 | class OptimizerStep( 12 | var newOpt: NewOptimizerProcessor? = null 13 | ) : CompilerProcess() { 14 | override fun process(istream: InputStream, ostream: OutputStream) { 15 | 16 | val asmLexer = PseudoAsmLexer(ANTLRInputStream(istream)) 17 | val asmTokens = CommonTokenStream(asmLexer) 18 | val asmParser = PseudoAsmParser(asmTokens) 19 | val asmContext = asmParser.pseudoAsmFile() 20 | 21 | if (newOpt == null) newOpt = NewOptimizerProcessor(state!!) 22 | newOpt?.buildFlowTree(asmContext) 23 | newOpt?.optimizeGraph() 24 | newOpt?.removeRedundantAllocs(asmContext, state!!) 25 | newOpt?.replacePairs(asmContext, state!!) 26 | newOpt?.removeIdentities(asmContext) 27 | 28 | ostream.use { 29 | asmContext.linia().iterator().forEach { 30 | val linia = it.children.map { it.text }.joinToString(" ") 31 | ostream.write(linia.toByteArray()) 32 | } 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/steps/PseudoAsmStep.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.pl.qus.wolin.steps 2 | 3 | import org.antlr.v4.runtime.ANTLRInputStream 4 | import org.antlr.v4.runtime.CommonTokenStream 5 | import pl.qus.wolin.KotlinLexer 6 | import pl.qus.wolin.KotlinParser 7 | import pl.qus.wolin.Pass 8 | import pl.qus.wolin.WolinVisitor 9 | import java.io.* 10 | 11 | class PseudoAsmStep: CompilerProcess() { 12 | override fun process(istream: InputStream, ostream: OutputStream) { 13 | // Get our lexer 14 | val lexer = KotlinLexer(ANTLRInputStream(istream)) 15 | 16 | // Get a list of matched tokens 17 | val tokens = CommonTokenStream(lexer) 18 | 19 | // Pass the tokens to the parser 20 | val parser = KotlinParser(tokens) 21 | 22 | // Specify our entry point 23 | val fileContext = parser.kotlinFile() 24 | 25 | val symbolsVisitor = WolinVisitor(Pass.SYMBOLS, tokens) 26 | 27 | val declarationVisitor = WolinVisitor(Pass.DECLARATION, tokens) 28 | 29 | val translationVisitor = WolinVisitor(Pass.TRANSLATION, tokens) 30 | 31 | //try { 32 | 33 | // przygotowanie 34 | 35 | println("== PASS 1 - gathering symbols ==") 36 | 37 | symbolsVisitor.visit(fileContext) 38 | 39 | println("== PASS 2 - type inference ==") 40 | 41 | // zebranie typów dla rejestrów 42 | val mainName = symbolsVisitor.state.findFunction("main")// { it == "main" || it.endsWith(".main")} 43 | symbolsVisitor.state.copyInto(declarationVisitor.state) 44 | declarationVisitor.state.mainFunction = mainName 45 | 46 | declarationVisitor.visit(fileContext) 47 | declarationVisitor.appendLambdas() 48 | 49 | println("== PASS 3 - code generation ==") 50 | 51 | // właściwa translacja 52 | declarationVisitor.state.copyInto(translationVisitor.state) 53 | val wynik = translationVisitor.visit(fileContext) 54 | 55 | translationVisitor.appendLambdas() 56 | wynik.appendStatics() 57 | 58 | //val ostream = BufferedOutputStream(FileOutputStream(File("src/main/wolin/assembler.asm"))) 59 | 60 | ostream.use { 61 | it.write(wynik.dumpCode().toByteArray()) 62 | } 63 | 64 | this.state = translationVisitor.state 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /src/main/kotlin/pl/qus/wolin/steps/TargetStep.kt: -------------------------------------------------------------------------------- 1 | package pl.qus.wolin.pl.qus.wolin.steps 2 | 3 | import org.antlr.v4.runtime.ANTLRInputStream 4 | import org.antlr.v4.runtime.CommonTokenStream 5 | import pl.qus.wolin.PseudoAsmLexer 6 | import pl.qus.wolin.PseudoAsmParser 7 | import pl.qus.wolin.RuleMatcherVisitor 8 | import pl.qus.wolin.asmFileLine 9 | import pl.qus.wolin.exception.NoRuleException 10 | import java.io.File 11 | import java.io.FileInputStream 12 | import java.io.InputStream 13 | import java.io.OutputStream 14 | 15 | class TargetStep: CompilerProcess() { 16 | override fun process(istream: InputStream, ostream: OutputStream) { 17 | val templateStream = FileInputStream(File("src/main/wolin/template.asm")) 18 | 19 | val asmLexer = PseudoAsmLexer(ANTLRInputStream(istream)) 20 | val asmTokens = CommonTokenStream(asmLexer) 21 | val asmParser = PseudoAsmParser(asmTokens) 22 | val asmContext = asmParser.pseudoAsmFile() 23 | 24 | val templateLexer = PseudoAsmLexer(ANTLRInputStream(templateStream)) 25 | val templateTokens = CommonTokenStream(templateLexer) 26 | val templateParser = PseudoAsmParser(templateTokens) 27 | val templateContext = templateParser.pseudoAsmFile() 28 | val templateVisitor = RuleMatcherVisitor() 29 | 30 | asmContext.linia().forEach { 31 | templateVisitor.state.assemblerLine = it 32 | try { 33 | templateVisitor.visit(templateContext) 34 | } catch (ex: NoRuleException) { 35 | println("No rule for parsing:${ex.message}") 36 | } catch (ex: Exception) { 37 | println("Syntax error in rule file translateAsm") 38 | throw ex 39 | } finally { 40 | asmFileLine++ 41 | } 42 | } 43 | 44 | ostream.use { 45 | it.write(templateVisitor.state.dumpCode().toByteArray()) 46 | } 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/resources/pl/qus/wolin/MyView.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |