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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[venom]: allow alphanumeric variables and source comments #4403

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions vyper/venom/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
%import common.WS
%import common.INT

# Allow multiple comment styles
COMMENT: ";" /[^\\n]*/ | "//" /[^\\n]*/ | "#" /[^\\n]*/

start: function* data_section?

# TODO: consider making entry block implicit, e.g.
Expand All @@ -40,7 +43,7 @@

CONST: INT
OPCODE: CNAME
VAR_IDENT: "%" INT (":" INT)?
VAR_IDENT: "%" NAME
LABEL: "@" NAME
NAME: (DIGIT|LETTER|"_")+

Expand All @@ -59,7 +62,9 @@ def _set_last_var(fn: IRFunction):
continue
value = inst.output.value
assert value.startswith("%")
fn.last_variable = max(fn.last_variable, int(value[1:]))
varname = value[1:]
if varname.isdigit():
fn.last_variable = max(fn.last_variable, int(varname))


def _set_last_label(ctx: IRContext):
Expand Down Expand Up @@ -172,7 +177,7 @@ def VAR_IDENT(self, var_ident) -> IRVariable:
varname = parts[0]
version = None
if len(parts) > 1:
version = parts[1]
version = int(parts[1])
return IRVariable(varname, version=version)

def CONST(self, val) -> IRLiteral:
Expand Down
Loading