Skip to content
Discussion options

You must be logged in to vote

How would I go about generating some useful error message stating that the require command only accepts a string or a string-list?

For such cases, the usual approach is usually to have the parser accept a more permissive syntax than the language actually allows and then have a subsequent pass over the AST that does semantic checks (in most languages, that would be type-checking, making sure identifiers exist in the scope, etc. but for your language it would be checking arguments are valid, say).

Alternatively, you can perform a limited but sufficient form of this with the validate combinator.

I think I just realized that the spans are in terms of tokens and not characters, aren't they?

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mainrs
Comment options

@zesterer
Comment options

@mainrs
Comment options

Answer selected by mainrs
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