-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate isType
function for primitive datatype rules
#1003
Conversation
Could you run |
isType
function for primitive datatype rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, thanks!
Can we also include generated checks for number
, bigint
and Date
types? I think that would complete the feature on this part.
packages/langium/src/grammar/type-system/type-collector/inferred-types.ts
Outdated
Show resolved
Hide resolved
packages/langium/src/grammar/type-system/type-collector/types.ts
Outdated
Show resolved
Hide resolved
packages/langium/src/grammar/type-system/type-collector/types.ts
Outdated
Show resolved
Hide resolved
packages/langium/src/grammar/type-system/type-collector/types.ts
Outdated
Show resolved
Hide resolved
packages/langium/src/grammar/type-system/type-collector/types.ts
Outdated
Show resolved
Hide resolved
packages/langium/src/grammar/type-system/type-collector/types.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking fairly good. I have a few minor improvements.
packages/langium/src/grammar/type-system/type-collector/types.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've simplified the generator tests a bit further. Looks good to me now 👍
closes #990
The idea is to generate checker functions for datatype rules through langium-cli.
This only applies on datatype rules that are only composed of strings or terminals. I also had to slightly touch the type inference to provide the regex for terminals.
Example:
will generate the following functions in the generated
ast.ts
file: