Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser: cleanup and simplify language parsing #20185

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Dec 15, 2023

馃[deprecated] Generated by Copilot at 38e6033

Refactor the parsing of function, struct, and interface languages in V. Use a common parse_language method in fn.v and struct.v to avoid duplication and simplify the code. Replace mut variables and multiple if statements with if expressions for readability and consistency.

馃[deprecated] Generated by Copilot at 38e6033

  • Refactor the parsing of the language of a function, type, struct, or interface declaration into a separate method parse_language that returns an ast.Language enum value (link, link, link)
  • Simplify the assignment of the function name based on the language using an if expression instead of a mut variable and multiple if statements in vlib/v/parser/fn.v (link)
  • Move the parsing of the language of a type declaration from vlib/v/parser/parser.v to vlib/v/parser/fn.v and use an if expression instead of a mut variable and multiple if statements (link)
  • Remove the redundant code that consumes the dot token after the language name in vlib/v/parser/fn.v (link)

@ttytm ttytm force-pushed the parser/update-lang-parsing branch 2 times, most recently from 225fa66 to 6456a3d Compare December 15, 2023 12:34
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit 226e075 into vlang:master Dec 15, 2023
54 checks passed
@ttytm ttytm deleted the parser/update-lang-parsing branch December 15, 2023 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants