aboutsummaryrefslogtreecommitdiff
path: root/grammars/python.bp
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-17 20:05:19 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-17 20:05:19 -0800
commit008db802298d688067ed9615079be28978e60e28 (patch)
treeeb1a4e080aad6356852b4712b5bdc1901e817697 /grammars/python.bp
parentfdc91544b7c7a57243e5504c29dab68e45cc79cc (diff)
Adding and improving grammars.
Diffstat (limited to 'grammars/python.bp')
-rw-r--r--grammars/python.bp20
1 files changed, 5 insertions, 15 deletions
diff --git a/grammars/python.bp b/grammars/python.bp
index 0683c0a..6928580 100644
--- a/grammars/python.bp
+++ b/grammars/python.bp
@@ -7,24 +7,14 @@
# See the accompanying README.md for more info.
comment: `# ..$
-string: quoted-string / `b quoted-string / `f quoted-string
-quoted-string: "'''".."'''" % \n / '"""'..'"""' % \n / `"..`" % (`\.) / `'..`' % (`\.)
-dict: `{__`} / `{ __ +(expr__`:__expr) % (__`,__) __ `}
-set: `{ __ +expr % (__`,__) __ `}
-list: `[ __ +expr % (__`,__) __ `]
+string: "'''".."'''" % \n / '"""'..'"""' % \n / `"..`" % (`\.) / `'..`' % (`\.)
keyword: |("and" / "as" / "assert" / "break" / "class" / "continue" / "def" /
"del" / "elif" / "else" / "except" / "finally" / "for" / "from" /
"global" / "if" / "import" / "in" / "is" / "lambda" / "None" / "nonlocal" /
"not" / "or" / "pass" / "raise" / "return" / "try" / "while" /
"with" / "yield")|
-expr: (function-call / lambda / string / dict / set / list / id / number / `(__expr__`)) *(method/attr/index)
-method: `. function-call
-attr: `. id
-index: `[__expr[__`:__expr [__`:__expr]]__`]
-tuple: `(__`) / +(__expr__`,) [__expr]
-empty-tuple: `(__`)
-class: |"class"|_id`: +(\N ..$)
+class: class-def +(\N ..$)
+class-def: ^_|"class"|_id[_parens]_`:
function: function-def +(\N ..$)
-function-def: |"def"|_id parens `:
-function-call: !<"def " id parens
-lambda: |"lambda"| .. `:__expr
+function-def: ^_|"def"|_id parens `:
+import: |"import"| _ (parens / *id%(_`,__)) [_ |"as"| (parens / *id%(_`,__))]