Modelling token sets #4350
Replies: 2 comments 3 replies
-
You’d definitely want separate grammars, but FYI the latter is not valid i.e. 3 of the tokens have the same pattern so only 1 will ever be generated Envoyé de mon iPhoneLe 8 juil. 2023 à 12:26, Christian Sciberras ***@***.***> a écrit :
I've recently started using Antlr to build a prototype of a language I have in mind.
One of the interesting functionalities is the ability to switch between sets of tokens.
For example, a "traditional set" would look like:
PROP_ACCESS: '.';
STMT_TERM: ';';
MTD_L: '(';
MTD_R: '(';
Whereas a "natural set" could look like:
PROP_ACCESS: ' ';
STMT_TERM: '.';
MTD_L: ' ';
MTD_R: ' ';
My first thought was to somehow switch between these sets based on some top-level config/pragma/whatever (is this even possible?). Or perhaps it makes more sense to actually have separate grammars?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
uuf6429
-
I meant they won’t be generated at runtimeEnvoyé de mon iPhoneLe 8 juil. 2023 à 16:20, Ivan Kochurkin ***@***.***> a écrit :
You’d definitely want separate grammars, but FYI the latter is not valid i.e. 3 of the tokens have the same pattern so only 1 will ever be generated
Not correct. All three tokens will be generated but TOKEN_UNREACHABLE warnings will be reported.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've recently started using Antlr to build a prototype of a language I have in mind.
One of the interesting functionalities is the ability to switch between sets of tokens.
For example, a "traditional set" would look like:
Whereas a "natural set" could look like:
My first thought was to somehow switch between these sets based on some top-level config/pragma/whatever (is this even possible?). Or perhaps it makes more sense to actually have separate grammars?
Beta Was this translation helpful? Give feedback.
All reactions