Skip to content

Commit

Permalink
Merge pull request #131 from nilason/update_cgrammar
Browse files Browse the repository at this point in the history
Add full support for floating and integer constants and update of PLY
  • Loading branch information
davidjamesca committed Jan 13, 2022
2 parents 5ddc80e + c572d94 commit cef9a7a
Show file tree
Hide file tree
Showing 21 changed files with 4,730 additions and 3,545 deletions.
19 changes: 2 additions & 17 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,19 @@ per-file-ignores =
# Files and directories which need fixes or specific exceptions.
#
# Description of codes:
# E302 expected 2 blank lines, found 0
# E305 expected 2 blank lines after end of function or class
# E401 multiple imports on one line
# E402 module level import not at top of file
# E501 line too long
# E711 comparison to None should be ‘if cond is None:’
# E722 do not use bare except, specify exception instead
# E731 do not assign a lambda expression, use a def
# E741 do not use variables named ‘l’, ‘O’, or ‘I’
#
# F401 module imported but unused
# F403 ‘from module import *’ used; unable to detect undefined names
# F405 name may be undefined, or defined from star imports: module
# F811 redefinition of unused name from line N
# F841 local variable name is assigned to but never used
#
# W391 blank line at end of file
# W605 invalid escape sequence ‘x’
#
ctypesgen/__init__.py: F401
ctypesgen/parser/yacc.py: E302, E501, E731, E741, F841
ctypesgen/parser/cgrammar.py: E501

max-line-length = 100

exclude =
ctypesgen/parser/parsetab.py,
ctypesgen/parser/lextab.py,
ctypesgen/parser/yacc.py,
ctypesgen/parser/lex.py,
demo/pydemolib.py,
.git,
__pycache__,
Expand Down
4 changes: 0 additions & 4 deletions ctypesgen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#!/usr/bin/env python
# -*- coding: us-ascii -*-
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab

"""
Ctypesgencore is the module that contains the main body of ctypesgen - in fact,
it contains everything but the command-line interface.
Expand Down
2 changes: 0 additions & 2 deletions ctypesgen/descriptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
ctypesgen.descriptions contains classes to represent a description of a
struct, union, enum, function, constant, variable, or macro. All the
Expand Down
5 changes: 4 additions & 1 deletion ctypesgen/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ def visit(self, visitor):


class ConstantExpressionNode(ExpressionNode):
def __init__(self, value):
def __init__(self, value, is_literal=False):
ExpressionNode.__init__(self)
self.value = value
self.is_literal = is_literal

def evaluate(self, context):
return self.value

def py_string(self, can_be_ctype):
if self.is_literal:
return self.value
if self.value == float("inf"):
return "float('inf')"
elif self.value == float("-inf"):
Expand Down
2 changes: 0 additions & 2 deletions ctypesgen/parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python

"""
This package parses C header files and generates lists of functions, typedefs,
variables, structs, unions, enums, macros, and constants. This package knows
Expand Down
2 changes: 1 addition & 1 deletion ctypesgen/parser/cdeclarations.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self):
def __repr__(self):
s = self.identifier or ""
if self.bitfield:
s += ":%d" % self.bitfield
s += f":{self.bitfield.value}"
if self.array:
s += repr(self.array)
if self.initializer:
Expand Down
Loading

0 comments on commit cef9a7a

Please sign in to comment.