Skip to content

Commit

Permalink
Update PLY from Chromium 114.0.5735.358
Browse files Browse the repository at this point in the history
Issue: 326748668
Reviewed-on: #3128
  • Loading branch information
dahlstrom-g authored May 2, 2024
2 parents f99b767 + 9b62955 commit ec5ebab
Show file tree
Hide file tree
Showing 10 changed files with 1,840 additions and 1,553 deletions.
3 changes: 3 additions & 0 deletions third_party/ply/DIR_METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
monorail {
component: "Tools"
}
4 changes: 2 additions & 2 deletions third_party/ply/METADATA
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ description:
third_party {
identifier {
type: "ChromiumVersion"
value: "74.0.3729.169" # from https://chromereleases.googleblog.com/2019/05/stable-channel-update-for-desktop_21.html
value: "114.0.5735.358" # from https://chromereleases.googleblog.com/2024/03/long-term-support-channel-update-for_26.html
}
identifier {
type: "Git"
value: "https://chromium.googlesource.com/chromium/src.git"
version: "84108231f6e6e0772fb9a4643679ce76aa771e67"
version: "1759c6ae9316996b9f150c0ce9d0ca78a3d15c02"
}
identifier {
type: "UpstreamSubdir"
Expand Down
3 changes: 3 additions & 0 deletions third_party/ply/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[email protected]

file://tools/idl_parser/OWNERS
22 changes: 13 additions & 9 deletions third_party/ply/README.chromium
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
Name: PLY (Python Lex-Yacc)
Current version: 3.4
URL: http://www.dabeaz.com/ply/ply-3.4.tar.gz
Current version: 3.11
URL: http://www.dabeaz.com/ply/ply-3.11.tar.gz
License: BSD
License File: LICENSE
Security Critical: no
Version: 3.4
Version: 3.11

This directory contains a copy of these ply-3.4 components:
PLY is used by (at least) the Mojo python bindings, the PPAPI
IDL generator, and the Blink IDL generator.

README ply-3.4/README
Sources ply-3.4/ply/__init__.py
ply-3.4/ply/lex.py
ply-3.4/ply/yacc.py
This directory contains a copy of these ply-3.11 components:

README ply-3.11/README.md
Sources ply-3.11/ply/__init__.py
ply-3.11/ply/lex.py
ply-3.11/ply/yacc.py


The license is in LICENSE.

Modifications made with initial commit:
Modifications made:
- Added the file README.chromium (this file)
- Applies license.patch
- Added ply.gni to list sources
232 changes: 118 additions & 114 deletions third_party/ply/README → third_party/ply/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
PLY (Python Lex-Yacc) Version 3.4
# PLY (Python Lex-Yacc) Version 3.11

Copyright (C) 2001-2011,
[![Build Status](https://travis-ci.org/dabeaz/ply.svg?branch=master)](https://travis-ci.org/dabeaz/ply)

Copyright (C) 2001-2018
David M. Beazley (Dabeaz LLC)
All rights reserved.

Expand Down Expand Up @@ -96,7 +98,7 @@ A simple example is found at the end of this document

Requirements
============
PLY requires the use of Python 2.2 or greater. However, you should
PLY requires the use of Python 2.6 or greater. However, you should
use the latest Python release if possible. It should work on just
about any platform. PLY has been tested with both CPython and Jython.
It also seems to work with IronPython.
Expand All @@ -112,7 +114,11 @@ book "Compilers : Principles, Techniques, and Tools" by Aho, Sethi, and
Ullman. The topics found in "Lex & Yacc" by Levine, Mason, and Brown
may also be useful.

A Google group for PLY can be found at
The GitHub page for PLY can be found at:

https://github.com/dabeaz/ply

An old and relatively inactive discussion group for PLY is found at:

http://groups.google.com/group/ply-hack

Expand All @@ -130,7 +136,7 @@ and testing a revised LALR(1) implementation for PLY-2.0.
Special Note for PLY-3.0
========================
PLY-3.0 the first PLY release to support Python 3. However, backwards
compatibility with Python 2.2 is still preserved. PLY provides dual
compatibility with Python 2.6 is still preserved. PLY provides dual
Python 2/3 compatibility by restricting its implementation to a common
subset of basic language features. You should not convert PLY using
2to3--it is not necessary and may in fact break the implementation.
Expand All @@ -141,109 +147,109 @@ Example
Here is a simple example showing a PLY implementation of a calculator
with variables.

# -----------------------------------------------------------------------------
# calc.py
#
# A simple calculator with variables.
# -----------------------------------------------------------------------------

tokens = (
'NAME','NUMBER',
'PLUS','MINUS','TIMES','DIVIDE','EQUALS',
'LPAREN','RPAREN',
)

# Tokens

t_PLUS = r'\+'
t_MINUS = r'-'
t_TIMES = r'\*'
t_DIVIDE = r'/'
t_EQUALS = r'='
t_LPAREN = r'\('
t_RPAREN = r'\)'
t_NAME = r'[a-zA-Z_][a-zA-Z0-9_]*'

def t_NUMBER(t):
r'\d+'
t.value = int(t.value)
return t

# Ignored characters
t_ignore = " \t"

def t_newline(t):
r'\n+'
t.lexer.lineno += t.value.count("\n")
def t_error(t):
print("Illegal character '%s'" % t.value[0])
t.lexer.skip(1)
# Build the lexer
import ply.lex as lex
lex.lex()

# Precedence rules for the arithmetic operators
precedence = (
('left','PLUS','MINUS'),
('left','TIMES','DIVIDE'),
('right','UMINUS'),
)

# dictionary of names (for storing variables)
names = { }

def p_statement_assign(p):
'statement : NAME EQUALS expression'
names[p[1]] = p[3]

def p_statement_expr(p):
'statement : expression'
print(p[1])

def p_expression_binop(p):
'''expression : expression PLUS expression
| expression MINUS expression
| expression TIMES expression
| expression DIVIDE expression'''
if p[2] == '+' : p[0] = p[1] + p[3]
elif p[2] == '-': p[0] = p[1] - p[3]
elif p[2] == '*': p[0] = p[1] * p[3]
elif p[2] == '/': p[0] = p[1] / p[3]

def p_expression_uminus(p):
'expression : MINUS expression %prec UMINUS'
p[0] = -p[2]

def p_expression_group(p):
'expression : LPAREN expression RPAREN'
p[0] = p[2]

def p_expression_number(p):
'expression : NUMBER'
p[0] = p[1]

def p_expression_name(p):
'expression : NAME'
try:
p[0] = names[p[1]]
except LookupError:
print("Undefined name '%s'" % p[1])
p[0] = 0

def p_error(p):
print("Syntax error at '%s'" % p.value)

import ply.yacc as yacc
yacc.yacc()

while 1:
try:
s = raw_input('calc > ') # use input() on Python 3
except EOFError:
break
yacc.parse(s)
# -----------------------------------------------------------------------------
# calc.py
#
# A simple calculator with variables.
# -----------------------------------------------------------------------------

tokens = (
'NAME','NUMBER',
'PLUS','MINUS','TIMES','DIVIDE','EQUALS',
'LPAREN','RPAREN',
)

# Tokens

t_PLUS = r'\+'
t_MINUS = r'-'
t_TIMES = r'\*'
t_DIVIDE = r'/'
t_EQUALS = r'='
t_LPAREN = r'\('
t_RPAREN = r'\)'
t_NAME = r'[a-zA-Z_][a-zA-Z0-9_]*'

def t_NUMBER(t):
r'\d+'
t.value = int(t.value)
return t

# Ignored characters
t_ignore = " \t"

def t_newline(t):
r'\n+'
t.lexer.lineno += t.value.count("\n")

def t_error(t):
print("Illegal character '%s'" % t.value[0])
t.lexer.skip(1)

# Build the lexer
import ply.lex as lex
lex.lex()

# Precedence rules for the arithmetic operators
precedence = (
('left','PLUS','MINUS'),
('left','TIMES','DIVIDE'),
('right','UMINUS'),
)

# dictionary of names (for storing variables)
names = { }

def p_statement_assign(p):
'statement : NAME EQUALS expression'
names[p[1]] = p[3]

def p_statement_expr(p):
'statement : expression'
print(p[1])

def p_expression_binop(p):
'''expression : expression PLUS expression
| expression MINUS expression
| expression TIMES expression
| expression DIVIDE expression'''
if p[2] == '+' : p[0] = p[1] + p[3]
elif p[2] == '-': p[0] = p[1] - p[3]
elif p[2] == '*': p[0] = p[1] * p[3]
elif p[2] == '/': p[0] = p[1] / p[3]

def p_expression_uminus(p):
'expression : MINUS expression %prec UMINUS'
p[0] = -p[2]

def p_expression_group(p):
'expression : LPAREN expression RPAREN'
p[0] = p[2]

def p_expression_number(p):
'expression : NUMBER'
p[0] = p[1]

def p_expression_name(p):
'expression : NAME'
try:
p[0] = names[p[1]]
except LookupError:
print("Undefined name '%s'" % p[1])
p[0] = 0

def p_error(p):
print("Syntax error at '%s'" % p.value)

import ply.yacc as yacc
yacc.yacc()

while True:
try:
s = raw_input('calc > ') # use input() on Python 3
except EOFError:
break
yacc.parse(s)


Bug Reports and Patches
Expand All @@ -252,12 +258,10 @@ My goal with PLY is to simply have a decent lex/yacc implementation
for Python. As a general rule, I don't spend huge amounts of time
working on it unless I receive very specific bug reports and/or
patches to fix problems. I also try to incorporate submitted feature
requests and enhancements into each new version. To contact me about
bugs and/or new features, please send email to [email protected].

In addition there is a Google group for discussing PLY related issues at

http://groups.google.com/group/ply-hack
requests and enhancements into each new version. Please visit the PLY
github page at https://github.com/dabeaz/ply to submit issues and pull
requests. To contact me about bugs and/or new features, please send
email to [email protected].

-- Dave

Expand Down
5 changes: 3 additions & 2 deletions third_party/ply/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# PLY package
# Author: David Beazley ([email protected])
# -----------------------------------------------------------------------------
# ply: yacc.py
# ply: __init__.py
#
# Copyright (C) 2001-2011,
# Copyright (C) 2001-2018
# David M. Beazley (Dabeaz LLC)
# All rights reserved.
#
Expand Down Expand Up @@ -33,4 +33,5 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------

__version__ = '3.11'
__all__ = ['lex','yacc']
Loading

0 comments on commit ec5ebab

Please sign in to comment.