-
Hi, In my use case will be a great feature that indentation defining the scope of autocompletion, validation etc... I was not able to guess if this is possible or how can it be done. For example: If I'm in POSITION 1, I can set the “Type:" keyword, but If I'm in POSITION 2, I only can set the "Dependencies:" keyword of the parent class. Anyone has any clue to achieve this? Thanks in advance! :)
Language instace
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @JoanGi, So, this can be done in theory, by using whitespace sensitive approach to parsing. You would introduce "decoy" terminal rules Note that whitespace sensitive languages in EBNF style grammars are always a pain to deal with, and there's no easy for accomplishing this. |
Beta Was this translation helpful? Give feedback.
Hey @JoanGi,
So, this can be done in theory, by using whitespace sensitive approach to parsing. You would introduce "decoy" terminal rules
INDENT
andDEDENT
, then you override theirpattern
in theTokenBuilder
class to look something like this chevrotain python example. You would then use these tokens in your grammar whenever you need to increase/decrease the indentation of your text. This approach works best, when you enter a new parser rule/create a new AST node for each level of indentation, as that later on massively helps you with validation and cross reference resolution.Note that whitespace sensitive languages in EBNF style grammars are always a pain to deal with, and there's no e…