rspivak / lsbasi Goto Github PK
View Code? Open in Web Editor NEWLet's Build A Simple Interpreter
License: MIT License
Let's Build A Simple Interpreter
License: MIT License
Thank you so much for making your Let's build a simple interpreter series, it's really helping me learn how interpreters work while I'm making my own programming language in JavaScript ๐
I am trying to make an interpreter of Swarm programing language. If you have some ideas or advices, please contact me.
Here is the repo link.
I want to make a compiler for a c++ like language and I want to know how I can change PROCEDURE to functions?
Hello,
I'm currently going through your tutorial on "Lets build a simple interpreter".
I enjoy reading the tutorial, but I don't really understand why the change in Symbol and SymbolTable from chapter 11 to chapter 13, where much of what we already have defined, you want us to redefine?
Also I encountered, something I don't really understand with the VarSymbol scope property...
I fail to see where VarSymbol.scope.scope_level is defined,
This is from the https://github.com/rspivak/lsbasi/blob/master/part14/src2srccompiler.py#L171
var_name = node.value
var_symbol = self.current_scope.lookup(var_name)
if var_symbol is None:
raise Exception(
"Error: Symbol(identifier) not found '%s'" % var_name
)
scope_level = str(var_symbol.scope.scope_level)
return '<%s:%s>' % (var_name + scope_level, var_symbol.type.name)
and roaming around in your spi.py, I cannot find the link to .scope is it possible for you to help me out?
Thanks in advance
As you metioned in the articles!
Hi,
This is mine :
I've tried to generate AST in part18 using genastdot.py
, but it raised AttributeError: 'ProcedureDecl' object has no attribute 'params'
.
This can be fixed by altering self.formal_params
on self.params
in ProcedureDecl
class.
Hello sir~
I love this series post, It's a great tutorial, so, When is the next post coming out๏ผ
Given the fantastic work you've done so far, its a real shame to leave it hanging, the work with nested scopes is fantastic and brilliantly explained.
A great topic for the next instalment might be IF blocks with their own scopes
From there you only need some rudimentary input / output and you have a much more complete set of articles...
In spi.py (https://github.com/rspivak/lsbasi/blob/master/part15/spi.py), the skip_comment() function (starts on line 172) does not properly handle input source that contains an un-terminated comment.
For example, when run on the input below, spi.py hangs:
PROGRAM Test;
VAR
a : INTEGER;
BEGIN
a := 10 * 25; { Un-terminated comment. FREEZE!
END.
Line 581 in 83746bd
It currently reads """proccall_statement : ID LPAREN expr? (COMMA expr)* RPAREN"""
I believe the correct version is """proccall_statement : ID LPAREN (expr (COMMA expr)*)? RPAREN"""
, because otherwise foobar(, b, c)
would be valid.
If I'm right, then the only additional change is that the while loop
Line 592 in 83746bd
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.