petitparser / dart-petitparser-examples Goto Github PK
View Code? Open in Web Editor NEWExamples of PetitParser for Dart.
License: MIT License
Examples of PetitParser for Dart.
License: MIT License
(This is more of a discussion item than an issue, but discussions are not enabled on this repo.)
I've been working on my fork (see #5) of the Lisp example, and when implementing splicing I noticed an interesting consequence of the current implementation of quote syntax.
Currently when a '
is encountered the next atom is wrapped with an instance of the Quote
class. This makes the quote-handling code quite succinct and clean, but:
As I understand it, many (most? all?) Lisps implement quote syntax by transforming 'foo
into the list (quote foo)
where quote
is a symbol. The evaluator then recognizes this form and handles it specially.
It's important to note that '
parses into a cons list, because in some edge cases this results in behavior that not only diverges, but cannot even be expressed with the class-based parsing of Petit Lisp. A specific example I happened across:
`',@'(1 2)
Emacs, Guile, and SBCL all agree that this expands to (quote 1 2)
, which cannot be expressed with the Quote class in Petit Lisp.
((quote 1 2)
is not the same as '(1 2)
โ (quote (1 2))
, which is expressable in Petit Lisp as Quote(Cons(1, Cons(2))
. The closest you can get to the former would be Cons(Name('quote'), Cons(1, Cons(2)))
.)
My question is: What was the motivation behind the class-based quote implementation? Was this divergence intentional? Is this divergence a big enough problem to move to a cons-based implementation?
My feeling is that this is unimportant for basically all real-world purposes, but if for instance one were to aim for passing some sort of compatibility test then it could be a problem.
return [arguments, other.arguments] .zip() .map((arg) => arg[0].match(arg[1])) .fold(newBindings(), mergeBindings);
flags on zip.
I have a need for a Lisp parser and evaluator. I was going to write one myself, but I realized that the example here is already probably better than what I would have come up with on my own.
I could make a package that consumes this one, but I don't want all the extra dependencies.
Am I best off taking the code from here and starting a separate project? Could I call it "petit_lisp"?
Since the code in this repo is MIT-licensed, I believe I am allowed to do so, so I suppose I am mostly asking about how people feel about it, or if there are better alternative approaches.
(Aside: What I actually need is a near-Elisp, so I will need to add lots of library functions e.g. to an ElispEnvironment
and also make a few parsing changes. I also want to add a mechanism for interrupting evaluation after some time i.e. to prevent infinite loops. It looks like I can do all or most of this additively, but I'm not positive about that.)
This is a great project, but I noticed that it is still in the alpha stage. Will this project continue to be updated?
Hello!
I'm looking for some examples with petitparser that will allow me to create own programming language. I am Java developer itself.
So the closest sample I found is the Lisp interpreter in this repo. And all the main magic about evaluation stuff happening here :
This looks like a recursive function that took an object with just two props head
and tail
and first calls itself with head
to create a function and then uses the resulting function and calls it with tail
.
But can't get where the function creation actually happened, and how its evaluation was performed. Can be a bit of explanation on this?
Thanks!
Email addresses can be tricky to handle with regex. I think an idiomatic example written with petitparser
would be great for reference.
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.