Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Syntax Recovery #34

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Coverage Status](https://coveralls.io/repos/github/jdpage/jeff65/badge.svg?branch=master)](https://coveralls.io/github/jdpage/jeff65?branch=master)

*jeff65* is a compiler for the Commodore 64 (and perhaps in the future, other
6502-based computers). It is implemented in Python 3 and produces .prg files
6502-based computers). It is implemented in Python 3.6 (or newer) and produces .prg files
which can be loaded directly in VICE, or combined into .d64 disk images, written
to a floppy disk, and run on real hardware.

Expand All @@ -26,6 +26,16 @@ Invocation:
-h, --help show this help message and exit


## Status

* Basic syntax definition: finished, needs formal documentation.
* Lexer / Tokenizer: finished.
* Stage 1 Parsing (AST Generation): 75% finished.
* Stage 2 Parsing (AST validation and traversal): 15% finished.
* Stage 3 Parsing (AST optimization): not planned (for now).
* 6502 ASM Code Generation: not yet begun.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure this is no longer accurate

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there no react for "oops that's what I get for 2am commits"



## Licensing

The *jeff65* compiler itself is provided under the GPLv3 license; if you
Expand Down
13 changes: 13 additions & 0 deletions jeff65/gold/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ def parse(fileobj, name):
return builder.ast


def parse_expr(fileobj, name):
lexer = Lexer(fileobj, name=name)
tokens = antlr4.CommonTokenStream(lexer)
parser = Parser(tokens)
tree = parser.expr()
if parser._syntaxErrors > 0:
raise ast.ParseError("Unit {} had errors; terminating".format(name))
builder = ast.AstBuilder()
builder._push(ast.AstNode('<expr>', (0, 0)))
antlr4.ParseTreeWalker.DEFAULT.walk(builder, tree)
return builder.ast


def translate(unit, verbose=False):
with open_unit(unit) as input_file:
obj = parse(input_file, name=unit.name)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
nose==1.3.7
coverage==4.4.2
flake8==3.5.0
coverage==4.5.1
antlr4-python3-runtime==4.5.2
Expand Down
Loading