Parse a Python-like language
Project description
PLLParser
Parse a Python-like language
This package includes the following modules:
TreeNode.py
SYNOPSIS
node = TreeNode('menubar')
# --- A node can be used like a dictionary
# It will, by default, have a key 'label' set
# to the string provided
print(node['label'])
# menubar
node['mykey'] = 'myvalue'
print(f"node has {len(node)} keys")
# node has 2 keys
firstChild = TreeNode('firstchild')
node.appendChildNode(firstChild)
secondChild = TreeNode('secondchild')
node.appendChildNode(secondChild)
thirdChild = TreeNode('thirdchild')
node.appendChildNode(secondChild)
print(f"node has {node.numChildren()} children")
# node has 3 children
print(f"node has {node.numSiblings()} siblings")
print(f"firstChild has {firstChild.numSiblings()} siblings")
# node has 0 siblings
# firstChild has 2 siblings
RETokenizer.py
SYNOPSIS
tokzr = RETokenizer()
tokzr.add('INTEGER', r'\d+')
tokzr.add('STRING', r'"([^"]*)"', 1)
tokzr.add('STRING', r"'([^']*)'", 1)
lTokens = list(tokzr.tokens('"mystring"'
' + '
"'other'"))
assert lTokens == [
('STRING', 'mystring'),
('OTHER', '+'),
('STRING', 'other'),
]
PLLParser.py
SYNOPSIS
s = '''
* menubar
file
new
open
edit
undo
* layout
row
EditField
SelectField
'''
(tree, hSubTrees) = parsePLL(s)
assert len(hSubTrees) == 2
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
PLLParser-0.2.0.tar.gz
(8.6 kB
view hashes)
Built Distribution
PLLParser-0.2.0-py3-none-any.whl
(10.5 kB
view hashes)
Close
Hashes for PLLParser-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c74d489a6868bfd0728a59fde6978f7e761e01f2c16339151dde8c034cab62ab |
|
MD5 | 669c22ecd64fa02a6fe9d1510140fc82 |
|
BLAKE2b-256 | 715f68b82a152981651d10f18a5408346a97ea135b775ac51821aad233ea7362 |