Skip to content

Commit

Permalink
Merge branch 'master' of github.com:eliben/pycparser
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben committed Jul 25, 2018
2 parents 92f65b6 + a301cbb commit ccd673e
Show file tree
Hide file tree
Showing 32 changed files with 101 additions and 98 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
@@ -1,8 +1,6 @@
language: python
python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Expand Up @@ -2,7 +2,7 @@
pycparser v2.18
===============

:Author: `Eli Bendersky <http://eli.thegreenplace.net>`_
:Author: `Eli Bendersky <https://eli.thegreenplace.net/>`_


.. contents::
Expand Down Expand Up @@ -79,7 +79,7 @@ Installing
Prerequisites
-------------

* **pycparser** was tested on Python 2.7, 3.3-3.6, on both Linux and
* **pycparser** was tested on Python 2.7, 3.4-3.6, on both Linux and
Windows. It should work on any later version (in both the 2.x and 3.x lines)
as well.

Expand Down Expand Up @@ -158,7 +158,7 @@ the source is a previously defined type. This is essential in order to be able
to parse C correctly.

See `this blog post
<http://eli.thegreenplace.net/2015/on-parsing-c-type-declarations-and-fake-headers>`_
<https://eli.thegreenplace.net/2015/on-parsing-c-type-declarations-and-fake-headers>`_
for more details.

Basic usage
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Expand Up @@ -2,7 +2,6 @@ environment:

matrix:
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python33"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python36"
Expand Down
2 changes: 1 addition & 1 deletion examples/c-to-c.py
Expand Up @@ -4,7 +4,7 @@
# Example of using pycparser.c_generator, serving as a simplistic translator
# from C to AST and back to C.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------
from __future__ import print_function
Expand Down
2 changes: 1 addition & 1 deletion examples/cdecl.py
Expand Up @@ -29,7 +29,7 @@
# explain_c_declaration(c_decl, expand_struct=True)
# => p is a struct P containing {x is a int, y is a int}
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
import copy
Expand Down
2 changes: 1 addition & 1 deletion examples/dump_ast.py
Expand Up @@ -3,7 +3,7 @@
#
# Basic example of parsing a file and dumping its parsed AST.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
Expand Down
2 changes: 1 addition & 1 deletion examples/explore_ast.py
Expand Up @@ -9,7 +9,7 @@
# information from the AST.
# It helps to have the pycparser/_c_ast.cfg file in front of you.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
Expand Down
2 changes: 1 addition & 1 deletion examples/func_calls.py
Expand Up @@ -4,7 +4,7 @@
# Using pycparser for printing out all the calls of some function
# in a C file.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
Expand Down
2 changes: 1 addition & 1 deletion examples/func_defs.py
Expand Up @@ -7,7 +7,7 @@
# This is a simple example of traversing the AST generated by
# pycparser. Call it from the root directory of pycparser.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
Expand Down
2 changes: 1 addition & 1 deletion examples/rewrite_ast.py
Expand Up @@ -3,7 +3,7 @@
#
# Tiny example of rewriting a AST node
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
Expand Down
2 changes: 1 addition & 1 deletion examples/serialize_ast.py
Expand Up @@ -4,7 +4,7 @@
# Simple example of serializing AST
#
# Hart Chu [https://github.com/CtheSky]
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
from __future__ import print_function
Expand Down
2 changes: 1 addition & 1 deletion examples/using_cpp_libc.py
Expand Up @@ -5,7 +5,7 @@
# the 'real' cpp if you're on Linux/Unix) and "fake" libc includes
# to parse a file that includes standard C headers.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
import sys
Expand Down
2 changes: 1 addition & 1 deletion examples/using_gcc_E_libc.py
Expand Up @@ -5,7 +5,7 @@
# of 'cpp'. The same can be achieved with Clang instead of gcc. If you have
# Clang installed, simply replace 'gcc' with 'clang' here.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-------------------------------------------------------------------------------
import sys
Expand Down
5 changes: 3 additions & 2 deletions pycparser/__init__.py
Expand Up @@ -4,12 +4,13 @@
# This package file exports some convenience functions for
# interacting with pycparser
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
__all__ = ['c_lexer', 'c_parser', 'c_ast']
__version__ = '2.18'

import io
from subprocess import check_output
from .c_parser import CParser

Expand Down Expand Up @@ -81,7 +82,7 @@ def parse_file(filename, use_cpp=False, cpp_path='cpp', cpp_args='',
if use_cpp:
text = preprocess_file(filename, cpp_path, cpp_args)
else:
with open(filename, 'rU') as f:
with io.open(filename) as f:
text = f.read()

if parser is None:
Expand Down
4 changes: 2 additions & 2 deletions pycparser/_ast_gen.py
Expand Up @@ -7,7 +7,7 @@
# The design of this module was inspired by astgen.py from the
# Python 2.5 code-base.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
import pprint
Expand Down Expand Up @@ -180,7 +180,7 @@ def _gen_attr_names(self):
#
# AST Node classes.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pycparser/_build_tables.py
Expand Up @@ -6,7 +6,7 @@
# Also generates AST code from the configuration file.
# Should be called from the pycparser directory.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pycparser/_c_ast.cfg
Expand Up @@ -9,7 +9,7 @@
# <name>** - a sequence of child nodes
# <name> - an attribute
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pycparser/ast_transforms.py
Expand Up @@ -3,7 +3,7 @@
#
# Some utilities used by the parser to create a friendlier AST.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pycparser/c_ast.py
Expand Up @@ -11,7 +11,7 @@
#
# AST Node classes.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pycparser/c_generator.py
Expand Up @@ -3,7 +3,7 @@
#
# C code generator from pycparser AST nodes.
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------
from . import c_ast
Expand Down
2 changes: 1 addition & 1 deletion pycparser/c_lexer.py
Expand Up @@ -3,7 +3,7 @@
#
# CLexer class: lexer for the C language
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------
import re
Expand Down
2 changes: 1 addition & 1 deletion pycparser/c_parser.py
Expand Up @@ -3,7 +3,7 @@
#
# CParser class: Parser and AST builder for the C language
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------
import re
Expand Down
2 changes: 0 additions & 2 deletions pycparser/ply/cpp.py
Expand Up @@ -7,8 +7,6 @@
#
# This module implements an ANSI-C style lexical preprocessor for PLY.
# -----------------------------------------------------------------------------
from __future__ import generators

import sys

# Some Python 3 compatibility shims
Expand Down
2 changes: 1 addition & 1 deletion pycparser/ply/yacc.py
Expand Up @@ -309,7 +309,7 @@ def restart(self):
# certain kinds of advanced parsing situations where the lexer and parser interact with
# each other or change states (i.e., manipulation of scope, lexer states, etc.).
#
# See: http://www.gnu.org/software/bison/manual/html_node/Default-Reductions.html#Default-Reductions
# See: https://www.gnu.org/software/bison/manual/html_node/Default-Reductions.html#Default-Reductions
def set_defaulted_states(self):
self.defaulted_states = {}
for state, actions in self.action.items():
Expand Down
2 changes: 1 addition & 1 deletion pycparser/plyparser.py
Expand Up @@ -4,7 +4,7 @@
# PLYParser class and other utilites for simplifying programming
# parsers with PLY
#
# Eli Bendersky [http://eli.thegreenplace.net]
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -55,12 +55,11 @@ def make_release_tree(self, basedir, files):
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
packages=['pycparser', 'pycparser.ply'],
package_data={'pycparser': ['*.cfg']},
cmdclass={'install': install, 'sdist': sdist},
Expand Down
4 changes: 2 additions & 2 deletions tests/test_c_ast.py
Expand Up @@ -16,11 +16,11 @@ def test_BinaryOp(self):
left=c_ast.Constant(type='int', value='6'),
right=c_ast.ID(name='joe'))

self.failUnless(isinstance(b1.left, c_ast.Constant))
self.assertIsInstance(b1.left, c_ast.Constant)
self.assertEqual(b1.left.type, 'int')
self.assertEqual(b1.left.value, '6')

self.failUnless(isinstance(b1.right, c_ast.ID))
self.assertIsInstance(b1.right, c_ast.ID)
self.assertEqual(b1.right.name, 'joe')

def test_weakref_works_on_nodes(self):
Expand Down

0 comments on commit ccd673e

Please sign in to comment.