dlang-community / Pegged

A Parsing Expression Grammar (PEG) module, using the D programming language.
534 stars 66 forks source link

How does one do Intellisense using a Pegged grammar? #315

Closed enjoysmath closed 1 year ago

enjoysmath commented 1 year ago

Everyone wants to know this. Please show us how that would go. For example, can we view the grammar as a tree?

I guess we could use the provided PEG example in the example grammars and get a tree, but just wondering if anyone's already solved this problem.

veelo commented 1 year ago

You mean you want a language server for a language that is defined by a PEG? You will still have to implement some kind of semantic analyser, a parser alone will be insufficient. A language server needs to build a symbol table, and for that you need to know what rules in the grammar define symbols, and how scope works.

Or do you want some kind of syntax highlighting for the PEG grammar itself?

enjoysmath commented 1 year ago

Yes, the first one.

On Fri, Oct 7, 2022 at 3:46 PM Bastiaan Veelo @.***> wrote:

You mean you want a language server for a language that is defined by a PEG? You will still have to implement some kind of semantic analyser, a parser alone will be insufficient. A language server needs to build a symbol table, and for that you need to know what rules in the grammar define symbols, and how scope works.

Or do you want some kind of syntax highlighting for the PEG grammar itself?

— Reply to this email directly, view it on GitHub https://github.com/PhilippeSigaud/Pegged/issues/315#issuecomment-1272141800, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMIF55RZMLS54MED5YFI53WCCR53ANCNFSM6AAAAAAQ7YR6A4 . You are receiving this because you authored the thread.Message ID: @.***>

enjoysmath commented 1 year ago

You mean you want a language server for a language that is defined by a PEG? You will still have to implement some kind of semantic analyser, a parser alone will be insufficient. A language server needs to build a symbol table, and for that you need to know what rules in the grammar define symbols, and how scope works.

Or do you want some kind of syntax highlighting for the PEG grammar itself?

@veelo do you know of a good article on how to do that using a symbol table as you've mentioned?