davidkellis / arborist Goto Github PK
View Code? Open in Web Editor NEWArborist is a PEG parser that supports left-associative left recursion
License: MIT License
Arborist is a PEG parser that supports left-associative left recursion
License: MIT License
Are there any plans to support regex? It seems as though Ohm itself doesn't support it, but it would be a nice thing to have.
Hey ๐
thanks for your lib! I'm using it to parse Lisp (Clojure-like) syntax. Here is some feedback (want to share some thoughts with you).
It would be nice to have error object which would contain 1 message (as a string) with line and column. For now I use print_match_failure_error
.
For example:
Malformed input fragment on line 1 char 5 ; at position 5 (character index 4):
(1 2
----^
Expected one of the following expressions to match on line 1 char 5 ; at position 5 (character index 4):
number
1. term(".")
0 - expression_or_comment
0 - expression
0 - list
3 - expression_or_comment
3 - expression
3 - number
comment
1. term(";")
0 - expression_or_comment
0 - expression
0 - list
3 - expression_or_comment
4 - comment
list
1. term(")")
0 - expression_or_comment
0 - expression
0 - list
In the given example I would expect:
Expected ")" on line 1 at position 5 instead got end of file
Adding ;
or .
would not fix the sitaution.
I didn't find a good way to skip Lisp-comments, instead I return nil
and later check for it:
eval.on("expression_or_comment") do |ctx|
if ctx.captures["expression"]?
ctx.capture("expression").visit(eval)
else
# return nil to skip
nil
end
end
eval.on("list") do |ctx|
list = Mal::List.new
if ctx.captures.first_value?
ctx.captures.first_value.each do |e|
val = e.visit(eval)
if val # check if not a comment
list << val
end
end
end
Mal::Type.new list
end
I also want to implement Python-like syntax (which would be transformed to s-expressions). I wonder what it would take to implement :python
mode?
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.