Skip to content

Unsized numbers without base solution #127

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
YSJL opened this issue Oct 30, 2023 · 0 comments
Open

Unsized numbers without base solution #127

YSJL opened this issue Oct 30, 2023 · 0 comments

Comments

@YSJL
Copy link

YSJL commented Oct 30, 2023

I had the same problem as issue #116
However, I was able to fix the problem by adding a new type of number with the provided structure.
Already made a comment on said issue, but making a new one for visibility.

You can edit lexer.py, parser.py, ast.py using already existing structures.
For lexer,py:

  • Add at line 89 within tokens = keywords + operators + ()
    'UNSIZEDNUMBER',
  • line 184
    unsized_number = '\'[0-1xXzZ?]'
  • line 218
    @TOKEN(unsized_number)
    def t_UNSIZEDNUMBER(self, t):
    return t

For parser.py:

  • line 1266
    def p_const_expression_unsizednum(self, p):
    'const_expression : unsizednumber'
    p[0] = UnsizedConst(p[1], lineno=p.lineno(1))
    p.set_lineno(0, p.lineno(1))
  • line 1281
    def p_unsizednumber(self, p):
    'unsizednumber : UNSIZEDNUMBER'
    p[0] = p[1]
    p.set_lineno(0, p.lineno(1))
  • line 1498
    def p_delays_unsizednumber(self, p):
    'delays : DELAY unsizednumber'
    p[0] = DelayStatement(UnsizedConst(
    p[2], lineno=p.lineno(1)), lineno=p.lineno(1))
    p.set_lineno(0, p.lineno(1))

For ast.py:

  • line 267
    class UnsizedConst(Constant):
    pass
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant