Repository: benber86/mamushi (language: python)

Issue:
[Feature] Support numeric separator
Example:

```python
# @version 0.3.9

@external
def bar() -> uint256:
    return 1_000_000_000_000
```

It won't work at all for now. If I change `1_000_000_000_000` to `1000000000000`, it works.


Discussion / hints:

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 63de4ae..440a115 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,7 +13,7 @@ repos:
         language_version: python3.10
         args: [ --line-length=79 ]
 
-  - repo: https://gitlab.com/pycqa/flake8
+  - repo: https://github.com/pycqa/flake8
     rev: 3.9.2
     hooks:
       - id: flake8
diff --git a/src/mamushi/parsing/grammar.lark b/src/mamushi/parsing/grammar.lark
index 85816fa..55daeaf 100644
--- a/src/mamushi/parsing/grammar.lark
+++ b/src/mamushi/parsing/grammar.lark
@@ -296,11 +296,11 @@ STRING: /b?("(?!"").*?(?<!\\)(\\\\)*?"|'(?!'').*?(?<!\\)(\\\\)*?')/i
 DOCSTRING: /(""".*?(?<!\\)(\\\\)*?"""|'''.*?(?<!\\)(\\\\)*?''')/is
 ?strings: STRING+
 
-DEC_NUMBER: /0|[1-9]\d*/i
-HEX_NUMBER.2: /0x[\da-f]*/i
-OCT_NUMBER.2: /0o[0-7]*/i
-BIN_NUMBER.2 : /0b[0-1]*/i
-FLOAT_NUMBER.2: /((\d+\.\d*|\.\d+)(e[-+]?\d+)?|\d+(e[-+]?\d+))/i
+DEC_NUMBER: /0|[1-9](_?\d)*/
+HEX_NUMBER.2: /0x([_]?[0-9a-f])+/i
+OCT_NUMBER.2: /0o([_]?[0-7])+/i
+BIN_NUMBER.2 : /0b([_]?[01])+/i
+FLOAT_NUMBER.2: /(([1-9]\d*(_?\d*)*\.?\d*(_?\d*)?|\.\d+(_?\d*)?)(e[-+]?\d+(_?\d*)?)?|[1-9]\d*(_?\d*)?(e[-+]?\d+(_?\d*)?)?)/i
 
 _number: DEC_NUMBER
        | HEX_NUMBER


Test patch:
diff --git a/tests/data/declarations/number_formats.vy b/tests/data/declarations/number_formats.vy
new file mode 100644
index 0000000..2355647
--- /dev/null
+++ b/tests/data/declarations/number_formats.vy
@@ -0,0 +1,19 @@
+@external
+def foo():
+    a: decimal = 1_0000.1
+    b: uint256 = 1111_2222_33_4_5555
+    c: uint256 = 12_234_56
+    d: uint256 = 0o_12_122_0
+    e: uint256 = 0O_12_122_0
+    f: Bytes[1] = 0b0_1_1_0_1_0_0_1
+    g: address = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7
+# output
+@external
+def foo():
+    a: decimal = 1_0000.1
+    b: uint256 = 1111_2222_33_4_5555
+    c: uint256 = 12_234_56
+    d: uint256 = 0o_12_122_0
+    e: uint256 = 0O_12_122_0
+    f: Bytes[1] = 0b0_1_1_0_1_0_0_1
+    g: address = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7