-
Notifications
You must be signed in to change notification settings - Fork 50
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
Grammar railroad diagram #46
Comments
Neat! I just glanced through this, but when I get a chance to vet in detail, it could make a great addition to documentation. Thanks! |
A couple tweaks to tokens:
Thanks a bunch for doing this, it's a great start! Note also there are a lot of tests in |
Arriving here via your HN post — I made a tool that can generate |
I just updated the EBNF posted on my first message with the latest work I did that can recognize a lot more Observations about what I found doing this grammar:
Would be nice to have a playground like https://fascinatedbox.gitlab.io/lily-docs//intro-sandbox.html that is a scripting language with a set of features like |
Hi @mingodad , yep, you're right about the '<' operator and generics. It was my "easy fix" to avoid backtracking in the parser. Which 'u' prefix are you referring to here? I don't recall accepting a 'u' prefix, either in escapes or in integer literals. I agree that an in-browser demo would be cool. @diakopter had a web-based demo with Wasm, but I am not sure the status of it. |
Hello titzer ! I just updated again the EBNF and parser on the first message, now it recognizes almost all files in
|
I could not find how to rebuild/bootstrap |
I just found that you've added a |
Yep, I added that because traffic spiked a little. I could add a Makefile just as a convenience. For reference |
So I was not wrong on my initial interpretation of And what about the |
For the fixed-width integer types, the names will fall into the identifier category, since they start with a letter. I'm ok with that. The |
Thank you for reply ! Another topic that come while testing my parser was an error while trying to parse
Then I did a search in all
In
In
So I ended up copying an pasting to be able to run it:
How is code reuse/dependencies done/managed in |
Another question about variables by value/reference, looking at
The question is: Every token has a copy of fileName or only a reference to it ? |
The |
Dependencies aren't managed by the compiler in Virgil. You need to pass all the files of your program to the compiler. The runtime and garbage collector code also needs to be included, but the target-specific scripts, e.g. Apologies, the But manually:
E.g. to compile one of the applications in
|
How to call inherited methods ? I was trying to implement
Then I decided that a better approach would be to add the description directly to the
But then I'm getting this errors:
Then I searched for other code doing something similar I could not find other usage of I also tried this:
|
It seems that there is no function overload ?
Output:
|
Oh neat, it looks like you're adding some help to the options, which is something I was planning on doing eventually. You are correct on both of the above. There is no calling of overridden (super) methods, nor overloading of methods in Virgil. The latter becomes ambiguous in the case of delegate methods and the former was mostly a design choice on my part to avoid the fragile base class problem. It's occasionally useful, and There are lots of ways around this, e.g. you could just add a suffix
I kind of like this second pattern, because it keeps the shorthand local to the scope/file, instead of littering a utility class with many versions of a method that mostly do the same thing but just supply a default value of an argument. Plus, you can partially apply with any arguments you want, including the receiver, making it really really short. |
I've added a more complete EBNF to the |
Trying to use your EBNF at https://www.bottlecaps.de/rr/ui report some small mistakes that I fixed and you can see on the diff shown bellow:
|
Thanks, fixed. |
Not at all ! |
I'm using/cooperating with the development of I think that it can help to play with developing/debugging new/existing grammar syntax constructs due to it's interactive playgrounds: CHPEG -> https://chrishixon.github.io/chpeg/playground/ Copy and paste the grammar shown bellow on the Virgil peg grammar:
|
Notice the comments at the bottom of the grammar shown above to swap the comments depending if you want to use the |
I just found the problem to parse |
The same grammar is now listed here ChrisHixon/chpeg#20 (comment) like other ones I've done/converted/adapted so far. Any feedback is welcome ! |
I did several other small fixes to the grammar shown above (already updated again) and now it parses almost all
Attached is the same grammar that works with https://github.com/mingodad/peg and generate a standalone parser used to test on all |
And here is an EBNF generated from the above
|
This is great! When I have a chance to take a look in more detail I'll try to check in a version of the above. |
I just also did a port of CocoR to Typescript/Javascript and added a grammar for |
Going through the code on https://github.com/titzer/virgil/blob/master/aeneas/src/vst/Parser.v3 and using this tool https://github.com/mingodad/CocoR-CSharp to create a
LL(1)
parser to then generate anEBNF
understood by https://www.bottlecaps.de/rr/ui to generate a railroad diagram (https://en.wikipedia.org/wiki/Syntax_diagram) I've got an initial version that already shows a big chunk ofvirgil
grammar.Copy the
EBNF
shown bellow on https://www.bottlecaps.de/rr/ui in the tabEdit Grammar
then switch to the tabView Diagram
, I think that it's useful for documentation and understand/develop the syntax ofvirgil
:Here is the
LL(1)
parser that still need fixes to parse all the.v3
files of this project:The text was updated successfully, but these errors were encountered: