renamed project to Prog8

This commit is contained in:
Irmen de Jong 2018-09-15 16:21:05 +02:00
parent f3532e9014
commit 8ff72167a4
63 changed files with 243 additions and 618 deletions

1
.gitignore vendored
View File

@ -16,7 +16,6 @@
__pycache__/
parser.out
parsetab.py
!/il65/lib/*
.pytest_cache/
docs/build
out/

View File

@ -1,13 +1,13 @@
IL65 / 'Sick' - Experimental Programming Language for 8-bit 6502/6510 microprocessors
=====================================================================================
Prog8 - Structured Programming Language for 8-bit 6502/6510 microprocessors
===========================================================================
*Written by Irmen de Jong (irmen@razorvine.net)*
*Software license: GNU GPL 3.0, see file LICENSE*
This is an experimental programming language for the 8-bit 6502/6510 microprocessor from the late 1970's and 1980's
as used in many home computers from that era. IL65 is a medium to low level programming language,
This is a structured programming language for the 8-bit 6502/6510 microprocessor from the late 1970's and 1980's
as used in many home computers from that era. It is a medium to low level programming language,
which aims to provide many conveniences over raw assembly code (even when using a macro assembler):
- reduction of source code length
@ -32,11 +32,10 @@ It still allows for low level programming however and inline assembly blocks
to write performance critical pieces of code, but otherwise compiles fairly straightforwardly
into 6502 assembly code. This resulting code is assembled into a binary program by using
an external macro assembler, [64tass](https://sourceforge.net/projects/tass64/).
It can be compiled pretty easily for various platforms (Linux, Mac OS, Windows) or just ask me
to provide a small precompiled executable if you need that.
You need [Python 3.5](https://www.python.org/downloads/) or newer to run IL65 itself.
This tool can be compiled pretty easily for various platforms (Linux, Mac OS, Windows) or just ask me
to provide a small precompiled executable.
IL65 is mainly targeted at the Commodore-64 machine, but should be mostly system independent.
Prog8 is mainly targeted at the Commodore-64 machine, but should be mostly system independent.
See [the reference document](reference.md) for detailed information.

3
compiler/antlr/Makefile Normal file
View File

@ -0,0 +1,3 @@
parser:
./antlr.sh -o ../src/prog8/parser -no-listener -no-visitor -package prog8.parser -Dlanguage=Java prog8.g4

View File

@ -1,6 +1,6 @@
#!/bin/sh
PROJECT=~/Projects/IL65/il65/antlr
PROJECT=~/Projects/prog8/compiler/antlr
export CLASSPATH=".:${PROJECT}/lib/antlr-4.7.1-complete.jar:${CLASSPATH}"
java -jar ${PROJECT}/lib/antlr-4.7.1-complete.jar $*

View File

@ -1,6 +1,6 @@
#!/bin/sh
PROJECT=~/Projects/IL65/il65/antlr
PROJECT=~/Projects/prog8/compiler/antlr
export CLASSPATH=".:${PROJECT}/lib/antlr-4.7.1-complete.jar:${CLASSPATH}"
java org.antlr.v4.gui.TestRig $*

View File

@ -1,5 +1,5 @@
/*
IL65 combined lexer and parser grammar
Prog8 combined lexer and parser grammar
NOTES:
@ -8,7 +8,7 @@ NOTES:
*/
grammar il65;
grammar prog8;
LINECOMMENT : [\r\n][ \t]* COMMENT -> channel(HIDDEN);

View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh
IL65_LIBDIR=../lib65
IL65CLASSPATH=out/production/il65
PROG8_LIBDIR=../prog8lib
PROG8CLASSPATH=out/production/compiler
LIBJARS=/opt/irmen/idea-2018/plugins/Kotlin/lib/kotlin-stdlib.jar:/opt/irmen/idea-2018/plugins/Kotlin/lib/kotlin-reflect.jar:antlr/lib/antlr-runtime-4.7.1.jar
java -Dil65.libdir=${IL65_LIBDIR} -cp ${IL65CLASSPATH}:${LIBJARS} il65.MainKt $*
java -Dprog8.libdir=${PROG8_LIBDIR} -cp ${PROG8CLASSPATH}:${LIBJARS} prog8.MainKt $*

5
compiler/src/compile.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
mkdir -p compiled_java
javac -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.1.jar $(find . -name \*.java)
jar cf parser.jar -C compiled_java prog8
kotlinc -d prog8_kotlin.jar -include-runtime -cp ../antlr/lib/antlr-runtime-4.7.1.jar:parser.jar prog8

View File

@ -1,18 +1,18 @@
package il65
package prog8
import java.nio.file.Paths
import il65.ast.*
import il65.parser.*
import il65.compiler.*
import il65.optimizing.constantFold
import il65.optimizing.optimizeStatements
import il65.optimizing.simplifyExpressions
import prog8.ast.*
import prog8.parser.*
import prog8.compiler.*
import prog8.optimizing.constantFold
import prog8.optimizing.optimizeStatements
import prog8.optimizing.simplifyExpressions
import java.io.File
import kotlin.system.exitProcess
fun main(args: Array<String>) {
println("\nIL65 compiler by Irmen de Jong (irmen@razorvine.net)")
println("\nProg8 compiler by Irmen de Jong (irmen@razorvine.net)")
println("This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html\n")
if(args.size != 1) {
System.err.println("requires one argument: name of module file")

View File

@ -1,7 +1,7 @@
package il65.ast
package prog8.ast
import il65.functions.*
import il65.parser.il65Parser
import prog8.functions.*
import prog8.parser.prog8Parser
import org.antlr.v4.runtime.ParserRuleContext
import org.antlr.v4.runtime.tree.TerminalNode
import java.nio.file.Paths
@ -1128,7 +1128,7 @@ class BranchStatement(var condition: BranchCondition,
/***************** Antlr Extension methods to create AST ****************/
fun il65Parser.ModuleContext.toAst(name: String) : Module =
fun prog8Parser.ModuleContext.toAst(name: String) : Module =
Module(name, modulestatement().asSequence().map { it.toAst() }.toMutableList(), toPosition())
@ -1141,7 +1141,7 @@ private fun ParserRuleContext.toPosition() : Position {
}
private fun il65Parser.ModulestatementContext.toAst() : IStatement {
private fun prog8Parser.ModulestatementContext.toAst() : IStatement {
val directive = directive()?.toAst()
if(directive!=null) return directive
@ -1152,15 +1152,15 @@ private fun il65Parser.ModulestatementContext.toAst() : IStatement {
}
private fun il65Parser.BlockContext.toAst() : IStatement =
private fun prog8Parser.BlockContext.toAst() : IStatement =
Block(identifier().text, integerliteral()?.toAst()?.intvalue, statement_block().toAst(), toPosition())
private fun il65Parser.Statement_blockContext.toAst(): MutableList<IStatement> =
private fun prog8Parser.Statement_blockContext.toAst(): MutableList<IStatement> =
statement().asSequence().map { it.toAst() }.toMutableList()
private fun il65Parser.StatementContext.toAst() : IStatement {
private fun prog8Parser.StatementContext.toAst() : IStatement {
vardecl()?.let {
return VarDecl(VarDeclType.VAR,
it.datatype().toAst(),
@ -1244,7 +1244,7 @@ private fun il65Parser.StatementContext.toAst() : IStatement {
throw FatalAstException("unprocessed source text: $text")
}
private fun il65Parser.Functioncall_stmtContext.toAst(): IStatement {
private fun prog8Parser.Functioncall_stmtContext.toAst(): IStatement {
val location =
if(identifier()!=null) identifier()?.toAst()
else scoped_identifier()?.toAst()
@ -1255,7 +1255,7 @@ private fun il65Parser.Functioncall_stmtContext.toAst(): IStatement {
}
private fun il65Parser.FunctioncallContext.toAst(): FunctionCall {
private fun prog8Parser.FunctioncallContext.toAst(): FunctionCall {
val location =
if(identifier()!=null) identifier()?.toAst()
else scoped_identifier()?.toAst()
@ -1266,16 +1266,16 @@ private fun il65Parser.FunctioncallContext.toAst(): FunctionCall {
}
private fun il65Parser.InlineasmContext.toAst(): IStatement =
private fun prog8Parser.InlineasmContext.toAst(): IStatement =
InlineAssembly(INLINEASMBLOCK().text, toPosition())
private fun il65Parser.ReturnstmtContext.toAst() : IStatement {
private fun prog8Parser.ReturnstmtContext.toAst() : IStatement {
val values = expression_list()
return Return(values?.toAst() ?: emptyList(), toPosition())
}
private fun il65Parser.UnconditionaljumpContext.toAst(): IStatement {
private fun prog8Parser.UnconditionaljumpContext.toAst(): IStatement {
val address = integerliteral()?.toAst()?.intvalue
val identifier =
@ -1286,11 +1286,11 @@ private fun il65Parser.UnconditionaljumpContext.toAst(): IStatement {
}
private fun il65Parser.LabeldefContext.toAst(): IStatement =
private fun prog8Parser.LabeldefContext.toAst(): IStatement =
Label(children[0].text, toPosition())
private fun il65Parser.SubroutineContext.toAst() : Subroutine {
private fun prog8Parser.SubroutineContext.toAst() : Subroutine {
return Subroutine(identifier().text,
if(sub_params() ==null) emptyList() else sub_params().toAst(),
if(sub_returns() ==null) emptyList() else sub_returns().toAst(),
@ -1300,20 +1300,20 @@ private fun il65Parser.SubroutineContext.toAst() : Subroutine {
}
private fun il65Parser.Sub_paramsContext.toAst(): List<SubroutineParameter> =
private fun prog8Parser.Sub_paramsContext.toAst(): List<SubroutineParameter> =
sub_param().map {
SubroutineParameter(it.identifier().text, it.register()?.toAst(), it.statusflag()?.toAst(), it.toPosition())
}
private fun il65Parser.Sub_returnsContext.toAst(): List<SubroutineReturnvalue> =
private fun prog8Parser.Sub_returnsContext.toAst(): List<SubroutineReturnvalue> =
sub_return().map {
val isClobber = it.childCount==2 && it.children[1].text == "?"
SubroutineReturnvalue(it.register()?.toAst(), it.statusflag()?.toAst(), isClobber, it.toPosition())
}
private fun il65Parser.Assign_targetContext.toAst() : AssignTarget {
private fun prog8Parser.Assign_targetContext.toAst() : AssignTarget {
val register = register()?.toAst()
val identifier = identifier()
return if(identifier!=null)
@ -1323,26 +1323,26 @@ private fun il65Parser.Assign_targetContext.toAst() : AssignTarget {
}
private fun il65Parser.RegisterContext.toAst() = Register.valueOf(text.toUpperCase())
private fun prog8Parser.RegisterContext.toAst() = Register.valueOf(text.toUpperCase())
private fun il65Parser.StatusflagContext.toAst() = Statusflag.valueOf(text)
private fun prog8Parser.StatusflagContext.toAst() = Statusflag.valueOf(text)
private fun il65Parser.DatatypeContext.toAst() = DataType.valueOf(text.toUpperCase())
private fun prog8Parser.DatatypeContext.toAst() = DataType.valueOf(text.toUpperCase())
private fun il65Parser.ArrayspecContext.toAst() : ArraySpec =
private fun prog8Parser.ArrayspecContext.toAst() : ArraySpec =
ArraySpec(expression(0).toAst(), if (expression().size > 1) expression(1).toAst() else null, toPosition())
private fun il65Parser.DirectiveContext.toAst() : Directive =
private fun prog8Parser.DirectiveContext.toAst() : Directive =
Directive(directivename.text, directivearg().map { it.toAst() }, toPosition())
private fun il65Parser.DirectiveargContext.toAst() : DirectiveArg =
private fun prog8Parser.DirectiveargContext.toAst() : DirectiveArg =
DirectiveArg(stringliteral()?.text, identifier()?.text, integerliteral()?.toAst()?.intvalue, toPosition())
private fun il65Parser.IntegerliteralContext.toAst(): ByteOrWordLiteral {
private fun prog8Parser.IntegerliteralContext.toAst(): ByteOrWordLiteral {
fun makeLiteral(text: String, radix: Int, forceWord: Boolean): ByteOrWordLiteral {
val integer: Int
var datatype = DataType.BYTE
@ -1366,15 +1366,15 @@ private fun il65Parser.IntegerliteralContext.toAst(): ByteOrWordLiteral {
val terminal: TerminalNode = children[0] as TerminalNode
val integerPart = this.intpart.text
return when (terminal.symbol.type) {
il65Parser.DEC_INTEGER -> makeLiteral(integerPart, 10, wordsuffix()!=null)
il65Parser.HEX_INTEGER -> makeLiteral(integerPart.substring(1), 16, wordsuffix()!=null)
il65Parser.BIN_INTEGER -> makeLiteral(integerPart.substring(1), 2, wordsuffix()!=null)
prog8Parser.DEC_INTEGER -> makeLiteral(integerPart, 10, wordsuffix()!=null)
prog8Parser.HEX_INTEGER -> makeLiteral(integerPart.substring(1), 16, wordsuffix()!=null)
prog8Parser.BIN_INTEGER -> makeLiteral(integerPart.substring(1), 2, wordsuffix()!=null)
else -> throw FatalAstException(terminal.text)
}
}
private fun il65Parser.ExpressionContext.toAst() : IExpression {
private fun prog8Parser.ExpressionContext.toAst() : IExpression {
val litval = literalvalue()
if(litval!=null) {
@ -1427,48 +1427,48 @@ private fun il65Parser.ExpressionContext.toAst() : IExpression {
}
private fun il65Parser.Expression_listContext.toAst() = expression().map{ it.toAst() }
private fun prog8Parser.Expression_listContext.toAst() = expression().map{ it.toAst() }
private fun il65Parser.IdentifierContext.toAst() : IdentifierReference =
private fun prog8Parser.IdentifierContext.toAst() : IdentifierReference =
IdentifierReference(listOf(text), toPosition())
private fun il65Parser.Scoped_identifierContext.toAst() : IdentifierReference =
private fun prog8Parser.Scoped_identifierContext.toAst() : IdentifierReference =
IdentifierReference(NAME().map { it.text }, toPosition())
private fun il65Parser.FloatliteralContext.toAst() = text.toDouble()
private fun prog8Parser.FloatliteralContext.toAst() = text.toDouble()
private fun il65Parser.BooleanliteralContext.toAst() = when(text) {
private fun prog8Parser.BooleanliteralContext.toAst() = when(text) {
"true" -> true
"false" -> false
else -> throw FatalAstException(text)
}
private fun il65Parser.ArrayliteralContext.toAst() =
private fun prog8Parser.ArrayliteralContext.toAst() =
expression().asSequence().map { it.toAst() }.toMutableList()
private fun il65Parser.If_stmtContext.toAst(): IfStatement {
private fun prog8Parser.If_stmtContext.toAst(): IfStatement {
val condition = expression().toAst()
val statements = statement_block()?.toAst() ?: listOf(statement().toAst())
val elsepart = else_part()?.toAst() ?: emptyList()
return IfStatement(condition, statements, elsepart, toPosition())
}
private fun il65Parser.Else_partContext.toAst(): List<IStatement> {
private fun prog8Parser.Else_partContext.toAst(): List<IStatement> {
return statement_block()?.toAst() ?: listOf(statement().toAst())
}
private fun il65Parser.Branch_stmtContext.toAst(): IStatement {
private fun prog8Parser.Branch_stmtContext.toAst(): IStatement {
val branchcondition = branchcondition().toAst()
val statements = statement_block()?.toAst() ?: listOf(statement().toAst())
val elsepart = else_part()?.toAst() ?: emptyList()
return BranchStatement(branchcondition, statements, elsepart, toPosition())
}
private fun il65Parser.BranchconditionContext.toAst() = BranchCondition.valueOf(text.substringAfter('_').toUpperCase())
private fun prog8Parser.BranchconditionContext.toAst() = BranchCondition.valueOf(text.substringAfter('_').toUpperCase())

View File

@ -1,8 +1,8 @@
package il65.ast
package prog8.ast
import il65.compiler.CompilationOptions
import il65.functions.BuiltinFunctionNames
import il65.parser.ParsingFailedError
import prog8.compiler.CompilationOptions
import prog8.functions.BuiltinFunctionNames
import prog8.parser.ParsingFailedError
/**
* General checks on the Ast

View File

@ -1,7 +1,7 @@
package il65.ast
package prog8.ast
import il65.functions.BuiltinFunctionNames
import il65.parser.ParsingFailedError
import prog8.functions.BuiltinFunctionNames
import prog8.parser.ParsingFailedError
/**
* Checks the validity of all identifiers (no conflicts)

View File

@ -1,6 +1,6 @@
package il65.ast
package prog8.ast
import il65.parser.ParsingFailedError
import prog8.parser.ParsingFailedError
/**
* Checks for the occurrence of recursive subroutine calls

View File

@ -1,6 +1,6 @@
package il65.ast
package prog8.ast
import il65.parser.ParsingFailedError
import prog8.parser.ParsingFailedError
/**

View File

@ -1,4 +1,4 @@
package il65.ast
package prog8.ast
class StatementReorderer: IAstProcessor {
// Reorders the statements in a way the compiler needs.

View File

@ -1,6 +1,6 @@
package il65.compiler
package prog8.compiler
import il65.ast.*
import prog8.ast.*
import kotlin.experimental.and
import kotlin.math.absoluteValue
import kotlin.math.pow
@ -205,7 +205,7 @@ class Compiler(private val options: CompilationOptions) {
}
}
private fun makeLabel(postfix: String): String = "_il65stmt_${stmtUniqueSequenceNr}_$postfix"
private fun makeLabel(postfix: String): String = "_prog8stmt_${stmtUniqueSequenceNr}_$postfix"
private fun translate(stmt: IfStatement) {
/*
@ -532,7 +532,7 @@ class AssemblyResult(val name: String) {
vice_mon_file = program_filename + ".vice-mon-list"
with open(vice_mon_file, "rU") as f:
for line in f:
match = re.fullmatch(r"al (?P<address>\w+) \S+_il65_breakpoint_\d+.?", line, re.DOTALL)
match = re.fullmatch(r"al (?P<address>\w+) \S+_prog8_breakpoint_\d+.?", line, re.DOTALL)
if match:
breakpoints.append("$" + match.group("address"))
with open(vice_mon_file, "at") as f:

View File

@ -1,4 +1,4 @@
package il65.compiler
package prog8.compiler
class Petscii {
companion object {

View File

@ -1,9 +1,9 @@
package il65.compiler
package prog8.compiler
import il65.ast.DataType
import il65.ast.LiteralValue
import il65.ast.VarDecl
import il65.ast.VarDeclType
import prog8.ast.DataType
import prog8.ast.LiteralValue
import prog8.ast.VarDecl
import prog8.ast.VarDeclType
class Zeropage(private val options: CompilationOptions) {

View File

@ -1,7 +1,6 @@
package il65.functions
package prog8.functions
import il65.ast.*
import javax.xml.crypto.Data
import prog8.ast.*
import kotlin.math.abs
import kotlin.math.floor

View File

@ -1,6 +1,6 @@
package il65.optimizing
package prog8.optimizing
import il65.ast.*
import prog8.ast.*
import kotlin.math.pow
class ConstExprEvaluator {

View File

@ -1,7 +1,7 @@
package il65.optimizing
package prog8.optimizing
import il65.ast.*
import il65.compiler.Petscii
import prog8.ast.*
import prog8.compiler.Petscii
class ConstantFolding(private val globalNamespace: INameScope) : IAstProcessor {

View File

@ -1,10 +1,10 @@
package il65.optimizing
package prog8.optimizing
import il65.ast.AstException
import il65.ast.INameScope
import il65.ast.IStatement
import il65.ast.Module
import il65.parser.ParsingFailedError
import prog8.ast.AstException
import prog8.ast.INameScope
import prog8.ast.IStatement
import prog8.ast.Module
import prog8.parser.ParsingFailedError
fun Module.constantFold(globalNamespace: INameScope) {
val optimizer = ConstantFolding(globalNamespace)

View File

@ -1,7 +1,7 @@
package il65.optimizing
package prog8.optimizing
import il65.ast.IAstProcessor
import il65.ast.INameScope
import prog8.ast.IAstProcessor
import prog8.ast.INameScope
/*
todo eliminate useless terms:

View File

@ -1,8 +1,8 @@
package il65.optimizing
package prog8.optimizing
import il65.ast.*
import il65.functions.BuiltinFunctionNames
import il65.functions.BuiltinFunctionsWithoutSideEffects
import prog8.ast.*
import prog8.functions.BuiltinFunctionNames
import prog8.functions.BuiltinFunctionsWithoutSideEffects
/*

View File

@ -1,4 +1,4 @@
package il65.parser
package prog8.parser
import org.antlr.v4.runtime.CommonTokenStream
import org.antlr.v4.runtime.Lexer
@ -10,7 +10,7 @@ class CommentHandlingTokenStream(lexer: Lexer) : CommonTokenStream(lexer) {
fun commentTokens() : List<Comment> {
// extract the comments
val commentTokenChannel = il65Lexer.channelNames.indexOf("HIDDEN")
val commentTokenChannel = prog8Lexer.channelNames.indexOf("HIDDEN")
val theLexer = tokenSource as Lexer
return get(0, size())
.asSequence()

View File

@ -1,10 +1,10 @@
package il65.parser
package prog8.parser
import org.antlr.v4.runtime.CharStreams
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import il65.ast.*
import prog8.ast.*
class ParsingFailedError(override var message: String) : Exception(message)
@ -21,9 +21,9 @@ fun importModule(filePath: Path) : Module {
val moduleName = filePath.fileName.toString().substringBeforeLast('.')
val input = CharStreams.fromPath(filePath)
val lexer = il65Lexer(input)
val lexer = prog8Lexer(input)
val tokens = CommentHandlingTokenStream(lexer)
val parser = il65Parser(tokens)
val parser = prog8Parser(tokens)
val parseTree = parser.module()
if(parser.numberOfSyntaxErrors > 0)
throw ParsingFailedError("There are ${parser.numberOfSyntaxErrors} syntax errors in '${filePath.fileName}'.")
@ -63,13 +63,13 @@ fun discoverImportedModule(name: String, importedFrom: Path, position: Position?
val fileName = "$name.ill"
val locations = mutableListOf(Paths.get(importedFrom.parent.toString()))
val propPath = System.getProperty("il65.libdir")
val propPath = System.getProperty("prog8.libdir")
if(propPath!=null)
locations.add(Paths.get(propPath))
val envPath = System.getenv("IL65_LIBDIR")
val envPath = System.getenv("PROG8_LIBDIR")
if(envPath!=null)
locations.add(Paths.get(envPath))
locations.add(Paths.get(Paths.get("").toAbsolutePath().toString(), "lib65"))
locations.add(Paths.get(Paths.get("").toAbsolutePath().toString(), "prog8lib"))
locations.forEach {
val file = Paths.get(it.toString(), fileName)

View File

@ -1,5 +1,5 @@
// Generated from /home/irmen/Projects/il65/il65/antlr/il65.g4 by ANTLR 4.7
package il65.parser;
// Generated from prog8.g4 by ANTLR 4.7.1
package prog8.parser;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
@ -10,8 +10,8 @@ import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class il65Lexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
public class prog8Lexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
@ -114,13 +114,13 @@ public class il65Lexer extends Lexer {
}
public il65Lexer(CharStream input) {
public prog8Lexer(CharStream input) {
super(input);
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
@Override
public String getGrammarFileName() { return "il65.g4"; }
public String getGrammarFileName() { return "prog8.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }

View File

@ -1,5 +1,5 @@
// Generated from /home/irmen/Projects/il65/il65/antlr/il65.g4 by ANTLR 4.7
package il65.parser;
// Generated from prog8.g4 by ANTLR 4.7.1
package prog8.parser;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
@ -10,8 +10,8 @@ import java.util.Iterator;
import java.util.ArrayList;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class il65Parser extends Parser {
static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
public class prog8Parser extends Parser {
static { RuntimeMetaData.checkVersion("4.7.1", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
@ -116,7 +116,7 @@ public class il65Parser extends Parser {
}
@Override
public String getGrammarFileName() { return "il65.g4"; }
public String getGrammarFileName() { return "prog8.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@ -127,21 +127,21 @@ public class il65Parser extends Parser {
@Override
public ATN getATN() { return _ATN; }
public il65Parser(TokenStream input) {
public prog8Parser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
public static class ModuleContext extends ParserRuleContext {
public TerminalNode EOF() { return getToken(il65Parser.EOF, 0); }
public TerminalNode EOF() { return getToken(prog8Parser.EOF, 0); }
public List<ModulestatementContext> modulestatement() {
return getRuleContexts(ModulestatementContext.class);
}
public ModulestatementContext modulestatement(int i) {
return getRuleContext(ModulestatementContext.class,i);
}
public List<TerminalNode> EOL() { return getTokens(il65Parser.EOL); }
public List<TerminalNode> EOL() { return getTokens(prog8Parser.EOL); }
public TerminalNode EOL(int i) {
return getToken(il65Parser.EOL, i);
return getToken(prog8Parser.EOL, i);
}
public ModuleContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
@ -272,7 +272,7 @@ public class il65Parser extends Parser {
public Statement_blockContext statement_block() {
return getRuleContext(Statement_blockContext.class,0);
}
public TerminalNode EOL() { return getToken(il65Parser.EOL, 0); }
public TerminalNode EOL() { return getToken(prog8Parser.EOL, 0); }
public IntegerliteralContext integerliteral() {
return getRuleContext(IntegerliteralContext.class,0);
}
@ -1787,7 +1787,7 @@ public class il65Parser extends Parser {
}
public static class IdentifierContext extends ParserRuleContext {
public TerminalNode NAME() { return getToken(il65Parser.NAME, 0); }
public TerminalNode NAME() { return getToken(prog8Parser.NAME, 0); }
public IdentifierContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@ -1816,9 +1816,9 @@ public class il65Parser extends Parser {
}
public static class Scoped_identifierContext extends ParserRuleContext {
public List<TerminalNode> NAME() { return getTokens(il65Parser.NAME); }
public List<TerminalNode> NAME() { return getTokens(prog8Parser.NAME); }
public TerminalNode NAME(int i) {
return getToken(il65Parser.NAME, i);
return getToken(prog8Parser.NAME, i);
}
public Scoped_identifierContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
@ -1946,9 +1946,9 @@ public class il65Parser extends Parser {
public static class IntegerliteralContext extends ParserRuleContext {
public Token intpart;
public TerminalNode DEC_INTEGER() { return getToken(il65Parser.DEC_INTEGER, 0); }
public TerminalNode HEX_INTEGER() { return getToken(il65Parser.HEX_INTEGER, 0); }
public TerminalNode BIN_INTEGER() { return getToken(il65Parser.BIN_INTEGER, 0); }
public TerminalNode DEC_INTEGER() { return getToken(prog8Parser.DEC_INTEGER, 0); }
public TerminalNode HEX_INTEGER() { return getToken(prog8Parser.HEX_INTEGER, 0); }
public TerminalNode BIN_INTEGER() { return getToken(prog8Parser.BIN_INTEGER, 0); }
public WordsuffixContext wordsuffix() {
return getRuleContext(WordsuffixContext.class,0);
}
@ -2120,7 +2120,7 @@ public class il65Parser extends Parser {
}
public static class StringliteralContext extends ParserRuleContext {
public TerminalNode STRING() { return getToken(il65Parser.STRING, 0); }
public TerminalNode STRING() { return getToken(prog8Parser.STRING, 0); }
public StringliteralContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@ -2149,7 +2149,7 @@ public class il65Parser extends Parser {
}
public static class FloatliteralContext extends ParserRuleContext {
public TerminalNode FLOAT_NUMBER() { return getToken(il65Parser.FLOAT_NUMBER, 0); }
public TerminalNode FLOAT_NUMBER() { return getToken(prog8Parser.FLOAT_NUMBER, 0); }
public FloatliteralContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@ -2260,7 +2260,7 @@ public class il65Parser extends Parser {
}
public static class InlineasmContext extends ParserRuleContext {
public TerminalNode INLINEASMBLOCK() { return getToken(il65Parser.INLINEASMBLOCK, 0); }
public TerminalNode INLINEASMBLOCK() { return getToken(prog8Parser.INLINEASMBLOCK, 0); }
public InlineasmContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@ -2306,7 +2306,7 @@ public class il65Parser extends Parser {
public Statement_blockContext statement_block() {
return getRuleContext(Statement_blockContext.class,0);
}
public TerminalNode EOL() { return getToken(il65Parser.EOL, 0); }
public TerminalNode EOL() { return getToken(prog8Parser.EOL, 0); }
public SubroutineContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@ -2390,9 +2390,9 @@ public class il65Parser extends Parser {
}
public static class Statement_blockContext extends ParserRuleContext {
public List<TerminalNode> EOL() { return getTokens(il65Parser.EOL); }
public List<TerminalNode> EOL() { return getTokens(prog8Parser.EOL); }
public TerminalNode EOL(int i) {
return getToken(il65Parser.EOL, i);
return getToken(prog8Parser.EOL, i);
}
public List<StatementContext> statement() {
return getRuleContexts(StatementContext.class);
@ -2796,9 +2796,9 @@ public class il65Parser extends Parser {
public ExpressionContext expression() {
return getRuleContext(ExpressionContext.class,0);
}
public List<TerminalNode> EOL() { return getTokens(il65Parser.EOL); }
public List<TerminalNode> EOL() { return getTokens(prog8Parser.EOL); }
public TerminalNode EOL(int i) {
return getToken(il65Parser.EOL, i);
return getToken(prog8Parser.EOL, i);
}
public StatementContext statement() {
return getRuleContext(StatementContext.class,0);
@ -2937,7 +2937,7 @@ public class il65Parser extends Parser {
public Statement_blockContext statement_block() {
return getRuleContext(Statement_blockContext.class,0);
}
public TerminalNode EOL() { return getToken(il65Parser.EOL, 0); }
public TerminalNode EOL() { return getToken(prog8Parser.EOL, 0); }
public Else_partContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@ -3035,9 +3035,9 @@ public class il65Parser extends Parser {
public BranchconditionContext branchcondition() {
return getRuleContext(BranchconditionContext.class,0);
}
public List<TerminalNode> EOL() { return getTokens(il65Parser.EOL); }
public List<TerminalNode> EOL() { return getTokens(prog8Parser.EOL); }
public TerminalNode EOL(int i) {
return getToken(il65Parser.EOL, i);
return getToken(prog8Parser.EOL, i);
}
public StatementContext statement() {
return getRuleContext(StatementContext.class,0);

View File

@ -1,4 +1,4 @@
package il65.stackvm
package prog8.stackvm
import javax.swing.*
import java.awt.*

View File

@ -1,8 +1,8 @@
package il65.stackvm
package prog8.stackvm
import il65.ast.DataType
import il65.compiler.Mflpt5
import il65.compiler.Petscii
import prog8.ast.DataType
import prog8.compiler.Mflpt5
import prog8.compiler.Petscii
import java.awt.EventQueue
import java.io.File
import java.io.PrintWriter
@ -1276,7 +1276,7 @@ class StackVm(val traceOutputFile: String?) {
fun main(args: Array<String>) {
println("\nStackVM by Irmen de Jong (irmen@razorvine.net)")
println("\nProg8 StackVM by Irmen de Jong (irmen@razorvine.net)")
println("This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html\n")
if(args.size != 1) {
System.err.println("requires one argument: name of stackvm sourcecode file")

View File

@ -1,7 +1,6 @@
#!/usr/bin/env sh
IL65_LIBDIR=../lib65
IL65CLASSPATH=out/production/il65
PROG8CLASSPATH=out/production/compiler
LIBJARS=/opt/irmen/idea-2018/plugins/Kotlin/lib/kotlin-stdlib.jar:/opt/irmen/idea-2018/plugins/Kotlin/lib/kotlin-reflect.jar:antlr/lib/antlr-runtime-4.7.1.jar
java -cp ${IL65CLASSPATH}:${LIBJARS} il65.stackvm.StackVmKt $*
java -cp ${PROG8CLASSPATH}:${LIBJARS} prog8.stackvm.StackVmKt $*

View File

@ -1,10 +1,10 @@
package il65tests
package prog8tests
import il65.ast.DataType
import il65.ast.Position
import il65.ast.VarDecl
import il65.ast.VarDeclType
import il65.compiler.*
import prog8.ast.DataType
import prog8.ast.Position
import prog8.ast.VarDecl
import prog8.ast.VarDeclType
import prog8.compiler.*
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.closeTo
import org.hamcrest.Matchers.equalTo

View File

@ -4,7 +4,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = IL65
SPHINXPROJ = Prog8
SOURCEDIR = source
BUILDDIR = build

View File

@ -9,7 +9,7 @@ if "%SPHINXBUILD%" == "" (
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=IL65
set SPHINXPROJ=Prog8
if "%1" == "" goto help

View File

@ -7,19 +7,19 @@ What is a "Program" anyway?
A "complete runnable program" is a compiled, assembled, and linked together single unit.
It contains all of the program's code and data and has a certain file format that
allows it to be loaded directly on the target system. IL65 currently has no built-in
allows it to be loaded directly on the target system. Prog8 currently has no built-in
support for programs that exceed 64 Kb of memory, nor for multi-part loaders.
For the Commodore-64, most programs will have a tiny BASIC launcher that does a SYS into the generated machine code.
This way the user can load it as any other program and simply RUN it to start. (This is a regular ".prg" program).
Il65 can create those, but it is also possible to output plain binary programs
Prog8 can create those, but it is also possible to output plain binary programs
that can be loaded into memory anywhere.
Compiling program code
----------------------
Compilation of program code is done by telling the IL65 compiler to compile a main source code module file.
Compilation of program code is done by telling the Prog8 compiler to compile a main source code module file.
Other modules that this code needs will be loaded and processed via imports from within that file.
The compiler will link everything together into one output program at the end.
@ -39,8 +39,8 @@ A module source file is a text file with the ``.ill`` suffix, containing the pro
It consists of compilation options and other directives, imports of other modules,
and source code for one or more code blocks.
IL65 has a couple of *LIBRARY* modules that are defined in special internal files provided by the compiler:
``c64lib``, ``il65lib``, ``mathlib``.
Prog8 has a couple of *LIBRARY* modules that are defined in special internal files provided by the compiler:
``c64lib``, ``prog8lib``, ``mathlib``.
You should not overwrite these or reuse their names.
@ -55,7 +55,7 @@ There's support for using the monitor and debugging capabilities of the rather e
The ``%breakpoint`` directive (see :ref:`directives`) in the source code instructs the compiler to put
a *breakpoint* at that position. Some systems use a BRK instruction for this, but
this will usually halt the machine altogether instead of just suspending execution.
IL65 issues a NOP instruction instead and creates a 'virtual' breakpoint at this position.
Prog8 issues a NOP instruction instead and creates a 'virtual' breakpoint at this position.
All breakpoints are then written to a file called "programname.vice-mon-list",
which is meant to be used by the Vice emulator.
It contains a series of commands for Vice's monitor, including source labels and the breakpoint settings.

View File

@ -19,7 +19,7 @@
# -- Project information -----------------------------------------------------
project = 'IL65'
project = 'Prog8'
copyright = '2018, Irmen de Jong'
author = 'Irmen de Jong'
@ -113,7 +113,7 @@ html_static_path = ['_static']
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'IL65doc'
htmlhelp_basename = 'Prog8doc'
# -- Options for LaTeX output ------------------------------------------------
@ -140,7 +140,7 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'IL65.tex', 'IL65 Documentation',
(master_doc, 'Prog8.tex', 'Prog8 Documentation',
'Irmen de Jong', 'manual'),
]
@ -150,7 +150,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'il65', 'IL65 Documentation',
(master_doc, 'prog8', 'Prog8 Documentation',
[author], 1)
]
@ -161,8 +161,8 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'IL65', 'IL65 Documentation',
author, 'IL65', 'One line description of project.',
(master_doc, 'Prog8', 'Prog8 Documentation',
author, 'Prog8', 'One line description of project.',
'Miscellaneous'),
]

View File

@ -1,16 +1,16 @@
IL65 documentation - |version|
==============================
Prog8 documentation - |version|
===============================
.. image:: _static/logo.jpg
:align: center
:alt: IL65 logo
:alt: Prog8 logo
.. index:: what is IL65
.. index:: what is Prog8
What is IL65?
-------------
What is Prog8?
--------------
IL65 is an experimental compiled programming language targeting the 8-bit
This is an experimental compiled programming language targeting the 8-bit
`6502 <https://en.wikipedia.org/wiki/MOS_Technology_6502>`_ /
`6510 <https://en.wikipedia.org/wiki/MOS_Technology_6510>`_ microprocessor.
This CPU is from the late 1970's and early 1980's and was used in many home computers from that era,
@ -19,7 +19,7 @@ The language aims to provide many conveniences over raw assembly code (even when
while still being low level enough to create high performance programs.
IL65 is copyright © Irmen de Jong (irmen@razorvine.net | http://www.razorvine.net).
Prog8 is copyright © Irmen de Jong (irmen@razorvine.net | http://www.razorvine.net).
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html

View File

@ -1,8 +1,8 @@
.. _programstructure:
===================
Programming in IL65
===================
====================
Programming in Prog8
====================
This chapter describes a high level overview of the elements that make up a program.
Details about the syntax can be found in the :ref:`syntaxreference` chapter.
@ -35,7 +35,7 @@ Directive
Code block
A block of actual program code. It defines a *scope* (also known as 'namespace') and
can contain IL65 *code*, *variable declarations* and *subroutines*.
can contain Prog8 *code*, *variable declarations* and *subroutines*.
More details about this below: :ref:`blocks`.
Variable declarations
@ -45,7 +45,7 @@ Variable declarations
is fixed and is determined at compile time.
Variable declarations tend to appear at the top of the code block that uses them.
They define the name and type of the variable, and its initial value.
IL65 supports a small list of data types, including special 'memory mapped' types
Prog8 supports a small list of data types, including special 'memory mapped' types
that don't allocate storage but instead point to a fixed location in the address space.
Code
@ -75,7 +75,7 @@ Scope
This prevents name collisions (or 'namespace pollution'), because the name of the scope
is needed as prefix to be able to access the symbols in it.
Anything *inside* the scope can refer to symbols in the same scope without using a prefix.
There are three scopes in IL65:
There are three scopes in Prog8:
- global (no prefix)
- code block
@ -351,7 +351,7 @@ Arithmetic expressions are expressions that calculate a numeric result (integer
Many common arithmetic operators can be used and follow the regular precedence rules.
Logical expressions are expressions that calculate a boolean result, true or false
(which in IL65 will effectively be a 1 or 0 integer value).
(which in Prog8 will effectively be a 1 or 0 integer value).
You can use parentheses to group parts of an expresion to change the precedence.
Usually the normal precedence rules apply (``*`` goes before ``+`` etc.) but subexpressions

View File

@ -108,7 +108,7 @@ Directives
Level: block.
This directive can only be used inside a block.
The assembler will include the file as binary bytes at this point, il65 will not process this at all.
The assembler will include the file as binary bytes at this point, prog8 will not process this at all.
The optional offset and length can be used to select a particular piece of the file.
.. data:: %asminclude "<filename>", scopelabel
@ -116,7 +116,7 @@ Directives
Level: block.
This directive can only be used inside a block.
The assembler will include the file as raw assembly source text at this point,
il65 will not process this at all, with one exception: the labels.
prog8 will not process this at all, with one exception: the labels.
The scopelabel argument will be used as a prefix to access the labels from the included source code,
otherwise you would risk symbol redefinitions or duplications.
@ -130,7 +130,7 @@ Directives
Level: block, subroutine.
Declares that there is *inline assembly code* in the lines enclosed by the curly braces.
This code will be written as-is into the generated output file.
The assembler syntax used should be for the 3rd party cross assembler tool that IL65 uses.
The assembler syntax used should be for the 3rd party cross assembler tool that Prog8 uses.
Note that the start and end markers are both *double curly braces* to minimize the chance
that the inline assembly itself contains either of those. If it does contain a ``}}``,
the parsing of the inline assembler block will end prematurely and cause compilation errors.
@ -139,7 +139,7 @@ Directives
Identifiers
-----------
Naming things in IL65 is done via valid *identifiers*. They start with a letter or underscore,
Naming things in Prog8 is done via valid *identifiers*. They start with a letter or underscore,
and after that, a combination of letters, numbers, or underscores. Examples of valid identifiers::
a
@ -154,7 +154,7 @@ Code blocks
-----------
A named block of actual program code. Itefines a *scope* (also known as 'namespace') and
can contain IL65 *code*, *directives*, *variable declarations* and *subroutines*::
can contain Prog8 *code*, *directives*, *variable declarations* and *subroutines*::
~ <blockname> [<address>] {
<directives>
@ -221,7 +221,7 @@ Various examples::
Data types
^^^^^^^^^^
IL65 supports the following data types:
Prog8 supports the following data types:
=============== ======================= ================= =========================================
type identifier type storage size example var declaration and literal value

View File

@ -2,7 +2,7 @@
Target system specification
***************************
IL65 targets the following hardware:
Prog8 targets the following hardware:
- 8 bit MOS 6502/6510 CPU
- 64 Kb addressable memory (RAM or ROM)
@ -19,7 +19,7 @@ Physical address space layout
-----------------------------
The 6502 CPU can address 64 kilobyte of memory.
Most of the 64 kilobyte address space can be used by IL65 programs.
Most of the 64 kilobyte address space can be used by Prog8 programs.
This is a hard limit: there is no built-in support for RAM expansions or bank switching.
@ -41,10 +41,10 @@ reserved address in use for
================== =======================
``$00`` data direction (CPU hw)
``$01`` bank select (CPU hw)
``$02`` IL65 scratch variable
``$03`` IL65 scratch variable
``$fb - $fc`` IL65 scratch variable
``$fd - $fe`` IL65 scratch variable
``$02`` internal scratch variable
``$03`` internal scratch variable
``$fb - $fc`` internal scratch variable
``$fd - $fe`` internal scratch variable
``$fffa - $fffb`` NMI vector (CPU hw)
``$fffc - $fffd`` RESET vector (CPU hw)
``$fffe - $ffff`` IRQ vector (CPU hw)
@ -57,7 +57,7 @@ For example, the Commodore-64 has:
- memory-mapped I/O registers, for the video and sound chips, and the CIA's. Occupying ``$d000``--``$dfff``.
- RAM areas that are used for screen graphics and sprite data: usually at ``$0400``--``$07ff``.
IL65 programs can access all of those special memory locations but it will have a special meaning.
Prog8 programs can access all of those special memory locations but it will have a special meaning.
.. _zeropage:
@ -74,7 +74,7 @@ Theoretically they can all be used in a program, with the follwoing limitations:
and overwriting them will probably crash the machine. It is possible to use all of these
yourself, but only if the program takes over the entire system (and seizes control from the regular kernal).
This means it can no longer use (most) BASIC and kernal routines from ROM.
- it's more convenient and safe to let IL65 allocate these addresses for you and just
- it's more convenient and safe to let the compiler allocate these addresses for you and just
use symbolic names in the program code.
.. todo::
@ -82,7 +82,7 @@ Theoretically they can all be used in a program, with the follwoing limitations:
``zeropage`` modifier keyword on vardecl perhaps?
IL65 knows what addresses are safe to use in the various ZP handling configurations.
Prog8 knows what addresses are safe to use in the various ZP handling configurations.
It will use the free ZP addresses to place its ZP variables in,
until they're all used up. If instructed to output a program that takes over the entire
machine, (almost) all of the ZP addresses are suddenly available and will be used.
@ -132,7 +132,7 @@ Additional arguments can be passed via memory locations as well ofcourse.
But you'll have to be careful when dealing with chained or even recursive calls then,
because there's a big risk of overwriting those memory locations.
In IL65 the "caller saves" principle applies to calling subroutines.
In Prog8 the "caller saves" principle applies to calling subroutines.
This means the code that calls a subroutine that clobbers certain
registers (``A``, ``X`` or ``Y``), is responsible for storing and restoring the original values if
those values are needed by the rest of the code.

View File

@ -17,18 +17,18 @@ IF_XX::
(no else:)::
if[_!XX] [<expression>] goto il65_if_999_end ; !XX being the conditional inverse of XX
if[_!XX] [<expression>] goto prog8_if_999_end ; !XX being the conditional inverse of XX
.... (true part)
il65_if_999_end ; code continues after this
prog8_if_999_end ; code continues after this
(with else)::
if[_XX] [<expression>] goto il65_if_999
if[_XX] [<expression>] goto prog8_if_999
... (else part)
goto il65_if_999_end
il65_if_999 ... (true part)
il65_if_999_end ; code continues after this
goto prog8_if_999_end
prog8_if_999 ... (true part)
prog8_if_999_end ; code continues after this
IF X <COMPARISON> Y
@ -50,14 +50,14 @@ While::
==> DESUGARING ==>::
goto il65_while_999_check ; jump to the check
il65_while_999
goto prog8_while_999_check ; jump to the check
prog8_while_999
... (code)
goto il65_while_999 ;continue
goto il65_while_999_end ;break
il65_while_999_check
if[_XX] <expression> goto il65_while_999 ; loop condition
il65_while_999_end ; code continues after this
goto prog8_while_999 ;continue
goto prog8_while_999_end ;break
prog8_while_999_check
if[_XX] <expression> goto prog8_while_999 ; loop condition
prog8_while_999_end ; code continues after this
Repeat::
@ -70,12 +70,12 @@ Repeat::
==> DESUGARING ==>::
il65_repeat_999
prog8_repeat_999
... (code)
goto il65_repeat_999 ;continue
goto il65_repeat_999_end ;break
if[_!XX] <expression> goto il65_repeat_999 ; loop condition via conditional inverse of XX
il65_repeat_999_end ; code continues after this
goto prog8_repeat_999 ;continue
goto prog8_repeat_999_end ;break
if[_!XX] <expression> goto prog8_repeat_999 ; loop condition via conditional inverse of XX
prog8_repeat_999_end ; code continues after this
For::
@ -94,18 +94,18 @@ For::
loopvar = <from_expression>
compare loopvar, <to_expression>
if_ge goto il65_for_999_end ; loop condition
if_ge goto prog8_for_999_end ; loop condition
step = <step_expression> ; (store only if step < -1 or step > 1)
il65_for_999
goto il65_for_999_end ;break
goto il65_for_999_loop ;continue
prog8_for_999
goto prog8_for_999_end ;break
goto prog8_for_999_loop ;continue
.... (code)
il65_for_999_loop
prog8_for_999_loop
loopvar += step ; (if step > 1 or step < -1)
loopvar++ ; (if step == 1)
loopvar-- ; (if step == -1)
goto il65_for_999 ; continue the loop
il65_for_999_end ; code continues after this
goto prog8_for_999 ; continue the loop
prog8_for_999_end ; code continues after this

View File

@ -1,4 +0,0 @@
parser:
./antlr.sh -o ../src/il65/parser -no-listener -no-visitor -package il65.parser -Dlanguage=Java il65.g4
# ./antlr.sh -o ../src/il65/parser -no-listener -no-visitor -package il65.parser -Dlanguage=Python3 il65.g4

View File

@ -1,5 +0,0 @@
#!/bin/sh
mkdir -p compiled_java
javac -d compiled_java -cp ../antlr/lib/antlr-runtime-4.7.1.jar $(find . -name \*.java)
jar cf parser.jar -C compiled_java il65
kotlinc -d il65_kotlin.jar -include-runtime -cp ../antlr/lib/antlr-runtime-4.7.1.jar:parser.jar il65

View File

@ -1,185 +0,0 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
T__12=13
T__13=14
T__14=15
T__15=16
T__16=17
T__17=18
T__18=19
T__19=20
T__20=21
T__21=22
T__22=23
T__23=24
T__24=25
T__25=26
T__26=27
T__27=28
T__28=29
T__29=30
T__30=31
T__31=32
T__32=33
T__33=34
T__34=35
T__35=36
T__36=37
T__37=38
T__38=39
T__39=40
T__40=41
T__41=42
T__42=43
T__43=44
T__44=45
T__45=46
T__46=47
T__47=48
T__48=49
T__49=50
T__50=51
T__51=52
T__52=53
T__53=54
T__54=55
T__55=56
T__56=57
T__57=58
T__58=59
T__59=60
T__60=61
T__61=62
T__62=63
T__63=64
T__64=65
T__65=66
T__66=67
T__67=68
T__68=69
T__69=70
T__70=71
T__71=72
T__72=73
T__73=74
T__74=75
T__75=76
T__76=77
T__77=78
T__78=79
T__79=80
T__80=81
T__81=82
T__82=83
T__83=84
T__84=85
T__85=86
T__86=87
LINECOMMENT=88
COMMENT=89
WS=90
EOL=91
NAME=92
DEC_INTEGER=93
HEX_INTEGER=94
BIN_INTEGER=95
FLOAT_NUMBER=96
STRING=97
INLINEASMBLOCK=98
'~'=1
':'=2
'goto'=3
'%output'=4
'%launcher'=5
'%zeropage'=6
'%address'=7
'%import'=8
'%breakpoint'=9
'%asminclude'=10
'%asmbinary'=11
'%option'=12
','=13
'='=14
'const'=15
'memory'=16
'byte'=17
'word'=18
'float'=19
'str'=20
'str_p'=21
'str_s'=22
'str_ps'=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
'to'=52
'and'=53
'or'=54
'xor'=55
'not'=56
'return'=57
'.'=58
'A'=59
'X'=60
'Y'=61
'AX'=62
'AY'=63
'XY'=64
'Pc'=65
'Pz'=66
'Pn'=67
'Pv'=68
'.w'=69
'true'=70
'false'=71
'%asm'=72
'sub'=73
'->'=74
'{'=75
'}'=76
'?'=77
'if'=78
'else'=79
'if_cs'=80
'if_cc'=81
'if_eq'=82
'if_ne'=83
'if_pl'=84
'if_mi'=85
'if_vs'=86
'if_vc'=87

View File

@ -1,185 +0,0 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
T__12=13
T__13=14
T__14=15
T__15=16
T__16=17
T__17=18
T__18=19
T__19=20
T__20=21
T__21=22
T__22=23
T__23=24
T__24=25
T__25=26
T__26=27
T__27=28
T__28=29
T__29=30
T__30=31
T__31=32
T__32=33
T__33=34
T__34=35
T__35=36
T__36=37
T__37=38
T__38=39
T__39=40
T__40=41
T__41=42
T__42=43
T__43=44
T__44=45
T__45=46
T__46=47
T__47=48
T__48=49
T__49=50
T__50=51
T__51=52
T__52=53
T__53=54
T__54=55
T__55=56
T__56=57
T__57=58
T__58=59
T__59=60
T__60=61
T__61=62
T__62=63
T__63=64
T__64=65
T__65=66
T__66=67
T__67=68
T__68=69
T__69=70
T__70=71
T__71=72
T__72=73
T__73=74
T__74=75
T__75=76
T__76=77
T__77=78
T__78=79
T__79=80
T__80=81
T__81=82
T__82=83
T__83=84
T__84=85
T__85=86
T__86=87
LINECOMMENT=88
COMMENT=89
WS=90
EOL=91
NAME=92
DEC_INTEGER=93
HEX_INTEGER=94
BIN_INTEGER=95
FLOAT_NUMBER=96
STRING=97
INLINEASMBLOCK=98
'~'=1
':'=2
'goto'=3
'%output'=4
'%launcher'=5
'%zeropage'=6
'%address'=7
'%import'=8
'%breakpoint'=9
'%asminclude'=10
'%asmbinary'=11
'%option'=12
','=13
'='=14
'const'=15
'memory'=16
'byte'=17
'word'=18
'float'=19
'str'=20
'str_p'=21
'str_s'=22
'str_ps'=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
'to'=52
'and'=53
'or'=54
'xor'=55
'not'=56
'return'=57
'.'=58
'A'=59
'X'=60
'Y'=61
'AX'=62
'AY'=63
'XY'=64
'Pc'=65
'Pz'=66
'Pn'=67
'Pv'=68
'.w'=69
'true'=70
'false'=71
'%asm'=72
'sub'=73
'->'=74
'{'=75
'}'=76
'?'=77
'if'=78
'else'=79
'if_cs'=80
'if_cc'=81
'if_eq'=82
'if_ne'=83
'if_pl'=84
'if_mi'=85
'if_vs'=86
'if_vc'=87

View File

@ -1,4 +1,4 @@
; IL65 definitions for the Commodore-64
; Prog8 definitions for the Commodore-64
; Including memory registers, I/O registers, Basic and Kernal subroutines, utility subroutines.
;
; Written by Irmen de Jong (irmen@razorvine.net) - license: GNU GPL 3.0
@ -833,7 +833,7 @@ sub word2decimal (dataword: XY) -> (?) {
sub print_string (address: XY) -> (A?, Y?) {
; ---- print null terminated string from X/Y
; note: the IL65 compiler contains an optimization that will replace
; note: the compiler contains an optimization that will replace
; a call to this subroutine with a string argument of just one char,
; by just one call to c64.CHROUT of that single char.
%asm {{

View File

@ -1,4 +1,4 @@
; IL65 integer math library for 6502
; Prog8 integer math library for 6502
; (floating point math is done via the C-64's BASIC ROM routines)
;
; some more interesting routines can be found here:
@ -6,7 +6,7 @@
; http://codebase64.org/doku.php?id=base:6502_6510_maths
;
; Written by Irmen de Jong (irmen@razorvine.net) - license: GNU GPL 3.0
; ;
;
; indent format: TABS, size=8

View File

@ -1,11 +1,11 @@
; IL65 internal library routines - always included by the compiler
; Prog8 internal library routines - always included by the compiler
;
; Written by Irmen de Jong (irmen@razorvine.net) - license: GNU GPL 3.0
;
; indent format: TABS, size=8
~ il65_lib {
~ prog8_lib {
; note: the following ZP scratch registers must be the same as in c64lib
memory byte SCRATCH_ZP1 = $02 ; scratch register #1 in ZP
memory byte SCRATCH_ZP2 = $03 ; scratch register #2 in ZP