Open Louis-DR opened 1 year ago
Hey Louis were you able to fix this implementation?
For whoever is going through this issue, you can edit lexer.py, parser.py, ast.py using already existing structures.
For lexer,py
:
tokens = keywords + operators + ()
'UNSIZEDNUMBER',
unsized_number = '\'[0-1xXzZ?]'
@TOKEN(unsized_number)
def t_UNSIZEDNUMBER(self, t):
return t
For parser.py
:
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))
def p_unsizednumber(self, p):
'unsizednumber : UNSIZEDNUMBER'
p[0] = p[1]
p.set_lineno(0, p.lineno(1))
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
:
class UnsizedConst(Constant):
pass
Hello,
I noticed that unsized literal number constants with the base specified (
'd0
) are supported but if the base is not specified ('d
) it raises a ParseError exception :Note that some tools appear to treat
'0
and'd0
differently : ModelSimI have never worked with lex or yacc but I might dig into it to try implementing this.