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

Bnf file #1

Open
florianpirchner opened this issue Jun 16, 2020 · 9 comments
Open

Bnf file #1

florianpirchner opened this issue Jun 16, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@florianpirchner
Copy link

Dear Team,

is there a bnf-file (grammar file) for this language?

Would appreciate to get one. Then I can start to write full Semantic IDE support.

Even for 3rd party products like Sublime text. Based on language server.

Best Flo

@Horaddrim
Copy link

Hey man, don't know if it helps, but I think this file can supply the info you need:
https://github.com/tgehr/ast/blob/2812b33092be8acb9f7d4e461b2198ccbc287b3f/lexer.d

@tgehr
Copy link
Collaborator

tgehr commented Jun 17, 2020

@florianpirchner Unfortunately, this does not exist yet.
@Horaddrim The remaining information is in this file: https://github.com/tgehr/ast/blob/master/parser.d
(I think Florian already found those.)

@florianpirchner
Copy link
Author

If i summarize:

  • The lexer and parser are implemented by hand. No grammar file like bnf was used to generate lexer and parser.
  • The way to get a proper grammar file is to reverse engineer lexer, parser and semantic.

Right?

@florianpirchner
Copy link
Author

Wow, a lot of work.

@florianpirchner
Copy link
Author

florianpirchner commented Jun 17, 2020

btw, here you can see the grammar documentation of d-lang.

https://dlang.org/spec/grammar.html

In my opinion it is neccessary to have a grammar file for every language. Otherwise people have a hard month to get into the syntax and semantics.

@tgehr
Copy link
Collaborator

tgehr commented Jun 18, 2020

For the lexer part we can probably pick some things from the D grammar, as the starting point for the lexer was a lexer for D. The Silq syntax is not particularly large. I am not sure why semantic would be relevant. I would rather go over the files that define the AST (expression.d, type.d, declaration.d), and make the grammar based on their toString functions, getting some more details by searching for the names of the respective classes in parser.d. If no one else picks it up, I will do it at some point.

@tgehr
Copy link
Collaborator

tgehr commented Jun 18, 2020

Figure 12 of another of our PLDI papers has a (simplified) grammar for a language that is based on the same parser code base: https://files.sri.inf.ethz.ch/website/papers/pldi20-lpsi.pdf

@florianpirchner
Copy link
Author

florianpirchner commented Jun 18, 2020

Thx, i will take a look.

I am not sure why semantic would be relevant
For semantic content assist using a scope based on the semantic model ist pretty helpful.

You could say a semantic model is the AST with the capability of crossreferences.

@florianpirchner
Copy link
Author

florianpirchner commented Jun 18, 2020

Did you evaluate this project. It is written in dlang and provides a parser builder/generator.
https://github.com/PhilippeSigaud/Pegged/tree/master/examples

Using grammar files ensures, that the language is normalized. Out there are several programming languages, that are not. Some years ago i talked to a senior (Phd) working at SAP. And he told me, that abap ist not normalized and there is no way right now, to create a proper grammar model-file.

Means, that in the language there are several exceptions made with the language, which inhibit to normalize it.

So it is a good idea, to ensure normalization at the beginning...

@tgehr tgehr added the enhancement New feature or request label Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants