Skip to content

Parsing a dynamic list of functions with varying argument types #2042

Answered by msujew
lukasb asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @lukasb,

As far as I can tell, you're attempting to embed the type system of your language (i.e. the available functions and their arguments) into the parser.

This is generally not recommended. Instead I would recommend to create an expression language that allows to create any functions call and supply any kinds of arguments. In a second, post-processing phase, you would assert that the arguments match the functions. Essentially, splitting the type system from the parser/grammar.

See also langium-lox to see how one could implement this. A pure chevrotain implementation would use the same architecture.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lukasb
Comment options

@msujew
Comment options

Answer selected by lukasb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants