Skip to main content

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

parserUtils.py

SYNOPSIS

See the file

Unit Tests

All unit tests appear at the end of the source file itself
They can be run using pytest

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.3.3.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PLLParser-0.3.3-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file PLLParser-0.3.3.tar.gz.

File metadata

  • Download URL: PLLParser-0.3.3.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for PLLParser-0.3.3.tar.gz
Algorithm Hash digest
SHA256 820af83ab4ff611381ca9a0dafe79d093b0af6cefe9a81b09705371bc74b4e2b
MD5 c6d32a25f08435552bb2c32e3455a5eb
BLAKE2b-256 771391dc6414dc1776bf2f7789006e7fb8a83dbdd5df3cafc7d8ab970615d476

See more details on using hashes here.

File details

Details for the file PLLParser-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: PLLParser-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for PLLParser-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 52b1947dcae7c9eee6c1ab4158003969b6cab82bde7543f4b50aacaf6c7acf33
MD5 ecbc2aeb24789f08c72c46d3762862d3
BLAKE2b-256 aa53fdb2ab31e6678b7a2c741e7caa32c600c860c51d8e1d784237e6fb0c86b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page