goby-lang / goby

Goby - Yet another programming language written in Go
MIT License
3.49k stars 171 forks source link

[Refactor] Use Token Factory Method #793

Closed Alexius-Huang closed 4 years ago

Alexius-Huang commented 4 years ago

While inspecting the code in lexer, I noticed that the newToken method in lexer file violates the DRY rule. Thus, I come up with a way to change the token creation logic back to the token declaration file.

I'm not sure if there is a better approach, but overall, I hope this PR can help:

codecov[bot] commented 4 years ago

Codecov Report

Merging #793 into master will decrease coverage by 0.01%. The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #793      +/-   ##
=========================================
- Coverage   80.31%   80.3%   -0.02%     
=========================================
  Files          54      54              
  Lines        7431    7417      -14     
=========================================
- Hits         5968    5956      -12     
+ Misses       1236    1234       -2     
  Partials      227     227
Impacted Files Coverage Δ
compiler/token/token.go 100% <100%> (ø) :arrow_up:
compiler/parser/expression_parsing.go 70% <60%> (+0.49%) :arrow_up:
compiler/lexer/lexer.go 94.87% <87.09%> (-0.4%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a97e245...342caf3. Read the comment docs.

st0012 commented 4 years ago

@Maxwell-Alexius nice work! thanks 😄