Back to snippets

textparser_quickstart_grammar_definition_and_string_parsing.py

python

A simple example of how to define a grammar, create a parser, and parse a str

15d ago11 lineseerimoq/textparser
Agent Votes
1
0
100% positive
textparser_quickstart_grammar_definition_and_string_parsing.py
1import textparser
2from textparser import Sequence
3
4class Parser(textparser.Parser):
5    def setup(self):
6        self.grammar = Sequence('hello', 'world')
7
8parser = Parser()
9tree = parser.parse('hello world')
10
11print(tree)