Common Patterns
Common parsing patterns and utilities.
This package contains pre-built parsers for commonly needed patterns.
Usage
Import the modules you need before defining your grammar:
from simpleparse.common import numbers, strings, comments
This makes the common productions available to all subsequent Parser instances.
Available Modules
Numbers Module
The simpleparse.common.numbers module provides:
int/integer- Integer numbersfloat/floatnumber- Floating point numbersnumber- Either int or floathex- Hexadecimal numbersbinary_number- Binary numbers
from simpleparse.common import numbers
grammar = '''
value := number
'''
Strings Module
The simpleparse.common.strings module provides:
string- Python-style strings with escapessimpleString- Simple quoted strings
from simpleparse.common import strings
grammar = '''
value := string
'''
ISO Date Module
The simpleparse.common.iso_date module provides ISO 8601 date parsing.
Character Types Module
The simpleparse.common.chartypes module provides character classification
patterns like uppercase, lowercase, digits, etc.
Comments Module
The
simpleparse.common.commentsmodule provides:c_comment- C-style/* ... */commentshash_comment- Python-style# ...commentssemicolon_comment- INI-style; ...comments