Comments (13)
The current Github version of PLY writes no such files. In older versions, there are optional arguments to lex() and yacc() that control this. I can't recall what they are off the top of my head, but honestly, you should probably be using the Github version of code instead.
from ply.
I tried to use a latest version but it throws me errors:
ERROR: Rule 't_STRING_LITERAL' defined for an unspecified token STRING_LITERAL
ERROR: Rule 't_LBRACKET' defined for an unspecified token LBRACKET
ERROR: Rule 't_PERIOD' defined for an unspecified token PERIOD
ERROR: Rule 't_RBRACKET' defined for an unspecified token RBRACKET
ERROR: Rule 't_LNOT' defined for an unspecified token LNOT
ERROR: Rule 't_NOT' defined for an unspecified token NOT
and won't allow to proceed.
It is working fine with the pervious version. And I have a lot other tokens.
from ply.
These errors have nothing to do with files and are probably due to a bad tokens
specification. Can't say without any example code.
from ply.
I don't know what could be wrong here (and it worked fine with previous version):
tokens = reserved + (
# Literals (identifier, integer constant, float constant, string constant,
# char const)
'ID', 'SCONST',
# constants
'INT_CONST_DEC', 'INT_CONST_OCT', 'INT_CONST_HEX', 'INT_CONST_BIN',
# Operators (+,-,*,/,%,|,&,~,^,<<,>>, ||, &&, !, <, <=, >, >=, ==, !=)
'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'MOD',
'OR', 'AND', 'NOT', 'XOR', 'LSHIFT', 'RSHIFT',
'LOR', 'LAND', 'LNOT',
'LT', 'LE', 'GT', 'GE', 'EQ', 'NE',
# Assignment (=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |=)
'EQUALS', 'TIMESEQUAL', 'DIVEQUAL', 'MODEQUAL', 'PLUSEQUAL', 'MINUSEQUAL',
'LSHIFTEQUAL', 'RSHIFTEQUAL', 'ANDEQUAL', 'XOREQUAL', 'OREQUAL',
# Increment/decrement (++,--)
'PLUSPLUS', 'MINUSMINUS',
# Structure dereference (->)
'ARROW',
# Conditional operator (?)
'CONDOP',
# Delimeters ( ) [ ] { } , . ; :
'LPAREN', 'RPAREN',
'LBRACKET', 'RBRACKET',
'LBRACE', 'RBRACE',
'COMMA', 'PERIOD', 'SEMI', 'COLON',
# Ellipsis (...)
'ELLIPSIS',
)
# Completely ignored characters
t_ignore = ' \t\x0c'
# Newlines
def t_NEWLINE(t):
r'\n+'
t.lexer.lineno += t.value.count("\n")
# Operators
t_PLUS = r'\+'
t_MINUS = r'-'
t_TIMES = r'\*'
t_DIVIDE = r'/'
t_MOD = r'%'
t_OR = r'\|'
t_AND = r'&'
t_NOT = r'~'
t_XOR = r'\^'
t_LSHIFT = r'<<'
t_RSHIFT = r'>>'
t_LOR = r'\|\|'
t_LAND = r'&&'
t_LNOT = r'!'
t_LT = r'<'
t_GT = r'>'
t_LE = r'<='
t_GE = r'>='
t_EQ = r'=='
t_NE = r'!='
from ply.
You don't show how you're creating the lexer and the error messages reference variables that aren't even defined in the above code sample. So, hard to say.
from ply.
I build it as:
self.clex = lexer(
error_func=self._lex_error_func,
on_lbrace_func=self._lex_on_lbrace_func,
on_rbrace_func=self._lex_on_rbrace_func,
type_lookup_func=self._lex_type_lookup_func)
self.clex.build()
from ply.
I don't know what this lexer()
function/object is, but it's not part of PLY (old or new). So, I have no idea. Sorry.
from ply.
this is a class with all the definitions. Like this
from ply.
Will have to investigate further. Do you know the last known version of PLY that worked with this?
from ply.
This version worked:
# PLY package
# Author: David Beazley ([email protected])
__version__ = '3.9'
__all__ = ['lex','yacc']
from ply.
And what are you doing exactly? Is the goal to simply use pycparser or is something else going on? Are you extending it?
from ply.
I just used it as a template for my own parser (for another custom language).
from ply.
I made changes and it is working now.
from ply.
Related Issues (20)
- Python 3.11: inability to use global inline flags HOT 3
- yacc argument "write_tables" is missing in 3.11 HOT 5
- Warn user about tuple flattening in precedence table HOT 3
- PyPI package HOT 2
- Trying to get in touch regarding a security issue
- "global flags not at the start of the expression" error when using in-line global regex flag with Python 11+ HOT 1
- t_AUTOINCREMENT error ?
- Please make a new release HOT 1
- PLY not compatible with python 3.12 HOT 1
- extreme slowness HOT 5
- Read grammar from files HOT 2
- Re examples/ansic HOT 1
- Exporting gramma for documentation
- ssl cert issue for the website
- License HOT 2
- "state" is ambiguous in the documentation. HOT 1
- lex.lex() can get some rules in the wrong order. HOT 1
- Documentation in doc/ply.md lacks important details about creating a custom lexer. HOT 6
- Import several module with lex()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ply.