Selaa lähdekoodia

Improved comments in examples

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.1
Erez Shinan 7 vuotta sitten
vanhempi
commit
1456daddbe
4 muutettua tiedostoa jossa 9 lisäystä ja 2 poistoa
  1. +0
    -1
      examples/calc.py
  2. +1
    -1
      examples/conf.py
  3. +1
    -0
      examples/json_parser.py
  4. +7
    -0
      examples/reconstruct_json.py

+ 0
- 1
examples/calc.py Näytä tiedosto

@@ -59,7 +59,6 @@ def main():
print(calc(s))

def test():
# print calc("a=(1+2)")
print(calc("a = 1+2"))
print(calc("1+a*-3"))



+ 1
- 1
examples/conf.py Näytä tiedosto

@@ -3,7 +3,7 @@
#
# The tokens NAME and VALUE match the same input. A regular lexer would arbitrarily
# choose one over the other, which would lead to a (confusing) parse error.
# However, due to the unambiguous structure of the grammar, the LALR(1) algorithm knows
# However, due to the unambiguous structure of the grammar, the LALR(1) algorithm knows
# which one of them to expect at each point during the parse.
# The lexer then only matches the tokens that the parser expects.
# The result is a correct parse, something that is impossible with a regular lexer.


+ 1
- 0
examples/json_parser.py Näytä tiedosto

@@ -2,6 +2,7 @@
# This example shows how to write a basic JSON parser
#
# The code is short and clear, but has good performance.
# For an explanation, check out the JSON parser tutorial at /docs/json_tutorial.md
#

import sys


+ 7
- 0
examples/reconstruct_json.py Näytä tiedosto

@@ -1,3 +1,10 @@
#
# This example demonstrates an experimental feature: Text reconstruction
# The Reconstructor takes a parse tree (already filtered from punctuation, of course),
# and reconstructs it into correct text, that can be parsed correctly.
# It can be useful for creating "hooks" to alter data before handing it to other parsers. You can also use it to generate samples from scratch.
#

import json
from .json_parser import json_grammar



Ladataan…
Peruuta
Tallenna