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

support '_' separator in dec/oct/float numbers #3665

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion examples/wallet/wallet.vy
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def approve(_seq: int128, to: address, _value: uint256, data: Bytes[4096], sigda
# Increase the number of approved transactions by 1
self.seq += 1
# Use raw_call to send the transaction
return raw_call(to, data, max_outsize=4096, gas=3000000, value=_value)
return raw_call(to, data, max_outsize=4096, gas=3_000_000, value=_value)


@external
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/grammar/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_basic_grammar():
code_func = """
@external
def one_two_three() -> uint256:
return 123123123
return 123_123_123
"""

assert parse_vyper_source(code, dedent=True)
Expand Down
6 changes: 3 additions & 3 deletions vyper/ast/grammar.lark
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ _NEWLINE: ( /\r?\n[\t ]*/ | COMMENT )+
STRING: /b?("(?!"").*?(?<!\\)(\\\\)*?"|'(?!'').*?(?<!\\)(\\\\)*?')/i
DOCSTRING: /(""".*?(?<!\\)(\\\\)*?"""|'''.*?(?<!\\)(\\\\)*?''')/is

DEC_NUMBER: /0|[1-9]\d*/i
DEC_NUMBER: /0|[1-9]([0-9]*_)?([0-9]+_)*[0-9]+/
HEX_NUMBER.2: /0x[\da-f]*/i
OCT_NUMBER.2: /0o[0-7]*/i
OCT_NUMBER.2: /0o([0-7]+_)*[0-7]+/
BIN_NUMBER.2 : /0b[0-1]*/i
FLOAT_NUMBER.2: /((\d+\.\d*|\.\d+)(e[-+]?\d+)?|\d+(e[-+]?\d+))/i
FLOAT_NUMBER.2: /((\d+(_\d+)*\.\d*|\.\d+)(e[-+]?\d+)?|\d+(_\d+)*(e[-+]?\d+)?)/i

_number: DEC_NUMBER
| HEX_NUMBER
Expand Down
Loading