PLY is an implementation of lex and yacc parsing tools for Python. Please do not use this tag for the PLY graphic file format (use ply-file-format) nor for the plyr / dplyr R packages, which have their own tags.
#About PLY
PLY is a parser generator tool that uses reflection to read token definitions and production rules written in pure Python. You can, for example, define tokens with a simple string attribution or with methods containing a regular expression in its docstring.
Ply is no longer distributed in any package-installable form. Since it has no dependencies, it can be used in a project which uses Python v3.6 or later by simply copying two files into the project directory. To acquire the files, either clone github repository or just download the two files lex.py and yacc.py.
Note: Do not use pip
to install PLY, it will install a broken distribution on your machine.
Examples of token definitions with code to interpret value:
def t_BOOLEAN(token):
r'(?:true|false)'
token.value = token.value == "true"
return token
def t_NUMBER(token):
r'[0-9]+'
token.value = int(token.value)
return token
Project page: http://www.dabeaz.com/ply/
Main docs: http://www.dabeaz.com/ply/ply.html
#Related tags:
- python
The Python Language - parsing
- SLY A proposed successor implementation, now retired by its author.