Skip to content

Conversation

@glx22
Copy link
Contributor

@glx22 glx22 commented Oct 14, 2024

According to https://github.com/dabeaz/ply/blob/master/CHANGES, the latest version will never be available via pip, and the preferred way to use ply is to vendor it.
Latest ply version removes caching of lexer/parser tables, and as a side effect fixes #332.

import sys
import types
import copy
import os

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'os' is not used.
return

if not tokens:
self.log.error('tokens is empty')

Check warning

Code scanning / CodeQL

Unreachable code Warning

This statement is unreachable.
module = inspect.getmodule(f)
self.modules.add(module)

tokname = self.toknames[fname]

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'tokname' is unnecessary as it is
redefined
before this value is used.
global lexer

ldict = None
stateinfo = {'INITIAL': 'inclusive'}

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'stateinfo' is unnecessary as it is
redefined
before this value is used.
# Create global versions of the token() and input() functions
token = lexobj.token
input = lexobj.input
lexer = lexobj

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable 'lexer' is not used.
for f in self.pfuncs:
if f[3]:
parts.append(f[3])
except (TypeError, ValueError):

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
return

if not tokens:
self.log.error('tokens is empty')

Check warning

Code scanning / CodeQL

Unreachable code Warning

This statement is unreachable.
if doc[1] == ':':
self.log.warning('%s:%d: Possible grammar rule %r defined without p_ prefix',
v.__code__.co_filename, v.__code__.co_firstlineno, n)
except IndexError:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
lr.bind_callables(pinfo.pdict)
parser = LRParser(lr, pinfo.error_func)

parse = parser.parse

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable 'parse' is not used.
@glx22 glx22 force-pushed the vendor_ply branch 2 times, most recently from 5ede0e2 to fe8f527 Compare October 14, 2024 14:41
@LordAro
Copy link
Member

LordAro commented Oct 14, 2024

Given it removes commandline options, this feels like more than just a "Codechange"

@FLHerne
Copy link
Contributor

FLHerne commented Jan 2, 2025

FWIW I added the use of caching in #63 and in hindsight it was clearly a mistake.
The speedup was quite noticeable on the very slow laptop I had at the time, but is negligible on modern PCs.

@audigex
Copy link

audigex commented Feb 15, 2025

Is this planned for merging any time soon? I'm unable to auto-build my newGRF using Github workflows without it (or finding another solution) so it would be good to know whether I need to find an alternative

@glx22
Copy link
Contributor Author

glx22 commented Feb 15, 2025

Is this planned for merging any time soon? I'm unable to auto-build my newGRF using Github workflows without it (or finding another solution) so it would be good to know whether I need to find an alternative

#362 should already fix your build issue I think

@glx22 glx22 changed the title Codechange: Vendor in latest ply version Change: Vendor in latest ply version May 13, 2025
@glx22 glx22 merged commit 41d5cd4 into OpenTTD:master May 13, 2025
21 checks passed
@glx22 glx22 deleted the vendor_ply branch May 13, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: const keyword not working

5 participants