feat(parser): add long and short as recognized types#113
Merged
Conversation
Add Type::Long and Type::Short variants to the AST. Include TokenKind::Long and TokenKind::Short in starts_type() and parse_type() so declarations like 'long x', 'short y', 'unsigned long z' and 'long *p' are accepted.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds long and short to the compiler’s type system and parser so C-style declarations using these keywords are accepted, addressing issue #109.
Changes:
- Extended the AST
Typeenum withLongandShort. - Updated
starts_type/parse_typeto recognize and parselongandshorttokens. - Added parser tests covering
long,short,unsigned long, and pointer-to-longdeclarations.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/common/ast/ast.rs |
Adds Type::Long and Type::Short variants to represent the new base types in the AST. |
src/parser/rules/declarations/types.rs |
Teaches the parser to treat long/short tokens as valid type starters and parse them into the corresponding AST types. |
src/tests/parser_test.rs |
Adds regression tests ensuring declarations using long/short (and unsigned long, pointer forms) parse successfully. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
Author
|
Nenhum comentario do Copilot. Pronto para o merge! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for the
longandshorttypes in the language's type system and parser, along with corresponding parser tests to ensure correct handling. The changes update both the AST and parsing logic to recognize and process these types.Type system and parsing updates:
LongandShortvariants to theTypeenum insrc/common/ast/ast.rsto represent these types in the AST.starts_typeandparse_typefunctions insrc/parser/rules/declarations/types.rsto recognize and correctly parselongandshorttokens as types.Testing:
src/tests/parser_test.rsto verify parsing oflong,short,unsigned long, and pointer-to-long variable declarations.Closes #109