Browse Source

Examples: Added new syntax to python grammar

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.11.0
Erez Sh 4 years ago
parent
commit
cd78243b82
2 changed files with 3 additions and 3 deletions
  1. +1
    -1
      examples/advanced/python3.lark
  2. +2
    -2
      lark/grammars/python.lark

+ 1
- 1
examples/advanced/python3.lark View File

@@ -23,7 +23,7 @@ decorated: decorators (classdef | funcdef | async_funcdef)
async_funcdef: "async" funcdef
funcdef: "def" NAME "(" parameters? ")" ["->" test] ":" suite

parameters: paramvalue ("," paramvalue)* ["," [ starparams | kwparams]]
parameters: paramvalue ("," paramvalue)* ["," "/"] ["," [starparams | kwparams]]
| starparams
| kwparams
starparams: "*" typedparam? ("," paramvalue)* ["," kwparams]


+ 2
- 2
lark/grammars/python.lark View File

@@ -6,11 +6,11 @@ COMMENT: /#[^\n]*/
STRING : /[ubf]?r?("(?!"").*?(?<!\\)(\\\\)*?"|'(?!'').*?(?<!\\)(\\\\)*?')/i
LONG_STRING: /[ubf]?r?(""".*?(?<!\\)(\\\\)*?"""|'''.*?(?<!\\)(\\\\)*?''')/is

DEC_NUMBER: /0|[1-9]\d*/i
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
FLOAT_NUMBER.2: /((\d+\.[\d_]*|\.[\d_]+)(e[-+]?\d+)?|\d+(e[-+]?\d+))/i
IMAG_NUMBER.2: /\d+j/i | FLOAT_NUMBER "j"i




Loading…
Cancel
Save