BlockIt
blockit::C::grammars Namespace Reference

Classes

class  TestCGrammar

Functions

def setUp
def tearDown
def testScanMultiplePrototype
def testParsePrototype
def testParseGenericPrototype
def testParseStructTypedef
def testParseEnumTypedef
def testParseBasicTypedef
def testParseBasicEnum
def testParseBasicStruct
def testParseStruct
def testParseStructPrototype
def testVarNameSpec
def testIntrinsicSpec
def testTypeSpec

Variables

string __doc__
tuple STRUCTDECL = pp.Forward()
tuple ENUMDECL = pp.Forward()
tuple CPLUSPLUSLINECOMMENT = pp.Literal("//")
tuple IDENT = pp.Word( pp.alphas+"_", pp.alphanums+"_$" )
tuple INTEGER = pp.Word( pp.nums )
tuple SEMI = pp.Literal(";")
tuple COMMA = pp.Literal(",")
tuple LBRACE = pp.Literal("{")
tuple RBRACE = pp.Literal("}")
tuple LBRACK = pp.Literal("[")
tuple RBRACK = pp.Literal("]")
tuple EQUALS = pp.Literal("=")
tuple LPAREN = pp.Literal("(")
tuple RPAREN = pp.Literal(")")
tuple CONST = pp.Keyword("const")
tuple ELLIPSIS = pp.Literal("...")
tuple ENUM = pp.Keyword("enum")
tuple EXTERN = pp.Keyword("extern")
tuple LONG = pp.Keyword("long")
tuple SHORT = pp.Keyword("short")
tuple STATIC = pp.Keyword("static")
tuple STRUCT = pp.Keyword("struct")
tuple VOID = pp.Keyword("void")
tuple ATTRIBUTE = pp.Keyword("__attribute__")
tuple PARENEDVALUE = LPAREN+pp.Word(pp.alphanums)
tuple ATTRIBUTES = pp.Group(ATTRIBUTE + pp.Literal("((") + pp.OneOrMore((pp.Word(pp.alphanums)|PARENEDVALUE)) + pp.Literal("))"))
tuple INLINE = pp.Keyword("__inline__")
tuple UNSIGNED = pp.Keyword("unsigned")
tuple POINTERNOTATION = pp.Optional(pp.Word("*"), default=None)
tuple TYPEDEF = pp.Keyword("typedef")
 TYPENAME = IDENT
 VARNAME = IDENT
 ARRAYSIZESPECIFIER = INTEGER|IDENT
tuple INTRINSICSPEC = pp.Optional(UNSIGNED|CONST)
tuple LONGLONGSPEC = pp.Optional(UNSIGNED|CONST)
tuple STRUCTTYPESPEC = pp.Optional(CONST)
 STRUCTPROTOTYPE = pp.lineStart+STRUCTTYPESPEC+SEMI
tuple ENUMTYPESPEC = pp.Optional(CONST)
tuple TYPESPEC = (INTRINSICSPEC|LONGLONGSPEC|STRUCTTYPESPEC|ENUMTYPESPEC|IDENT)
string BITFIELDSPEC = ":"
tuple VARNAMESPEC = ( VARNAME + pp.Optional( BITFIELDSPEC | ( LBRACK + ARRAYSIZESPECIFIER + RBRACK )))
tuple ASSIGNMENTFIELD
tuple VARNAMESPECARR = ( VARNAME + pp.Optional( BITFIELDSPEC | ( LBRACK + ARRAYSIZESPECIFIER + RBRACK ), default=None))
tuple ASSIGNMENTFIELDARR
 ENUMSPEC = ENUM+VARNAMESPEC
 STRUCTSPEC = STRUCT+VARNAMESPEC
tuple MEMBERDECL
tuple MEMBERENUMDECL
tuple MEMBERSTRUCTDECL
 CSTRUCTBNF = STRUCTDECL
 CENUMBNF = ENUMDECL
tuple TYPEDEFSPEC = pp.Keyword("typedef")
tuple TYPEDEFDECL = pp.Group( TYPEDEFSPEC + SEMI )
 TYPEDEFBNF = TYPEDEFDECL
tuple PROTOSPEC = pp.Group(pp.Optional(EXTERN|STATIC) + TYPESPEC + POINTERNOTATION )
tuple GENERICPROTOSPEC = pp.OneOrMore((EXTERN | TYPESPEC | VARNAME) + POINTERNOTATION)
tuple PROTODECL = pp.Group( PROTOSPEC + SEMI )
 PROTOBNF = PROTODECL
tuple GPROTODECL = pp.Group( GENERICPROTOSPEC + SEMI )
 GPROTOBNF = GPROTODECL
string testData1
string testData2
string testData3
 bnf = PROTOBNF
int ctr = 0
tuple output = bnf.parseString("extern cudaError_t cudaGetDeviceProperties(struct cudaDeviceProp *prop, int device);")
tuple suite = unittest.TestLoader()

Function Documentation

def blockit::C::grammars::setUp (   self)

Definition at line 316 of file grammars.py.

def blockit::C::grammars::tearDown (   self)

Definition at line 318 of file grammars.py.

def blockit::C::grammars::testIntrinsicSpec (   self)

Definition at line 671 of file grammars.py.

def blockit::C::grammars::testParseBasicEnum (   self)

Definition at line 542 of file grammars.py.

def blockit::C::grammars::testParseBasicStruct (   self)

Definition at line 564 of file grammars.py.

def blockit::C::grammars::testParseBasicTypedef (   self)

Definition at line 489 of file grammars.py.

def blockit::C::grammars::testParseEnumTypedef (   self)

Definition at line 461 of file grammars.py.

def blockit::C::grammars::testParseGenericPrototype (   self)

Definition at line 384 of file grammars.py.

def blockit::C::grammars::testParsePrototype (   self)
    int cg_state_read(char **StateDescription);
    int cg_state_write(char const * StateDescription);
    

Definition at line 336 of file grammars.py.

def blockit::C::grammars::testParseStruct (   self)

Definition at line 594 of file grammars.py.

def blockit::C::grammars::testParseStructPrototype (   self)

Definition at line 635 of file grammars.py.

def blockit::C::grammars::testParseStructTypedef (   self)

Definition at line 442 of file grammars.py.

def blockit::C::grammars::testScanMultiplePrototype (   self)

Definition at line 321 of file grammars.py.

def blockit::C::grammars::testTypeSpec (   self)

Definition at line 698 of file grammars.py.

def blockit::C::grammars::testVarNameSpec (   self)

Definition at line 651 of file grammars.py.


Variable Documentation

Initial value:
00001 """
00002 (C) 2010 Michael List, michael.list@gmail.com
00003 (C) 2010 David Car, david.car7@gmail.com
00004 
00005 Some of these grammars were hacked from the PyParsing UnderDevelopment site and
00006 likely then follow the same license as pyparsing itself.
00007 
00008 """

Definition at line 29 of file grammars.py.

Initial value:
00001 pp.Group( VARNAMESPEC + EQUALS + \
00002     ( gram.HEX_NUM | gram.ENGINEERING_NUM | gram.DECIMAL_NUM | gram.INTEGER | gram.NUM ) )

Definition at line 86 of file grammars.py.

Initial value:
00001 pp.Group( VARNAMESPECARR + EQUALS + \
00002     ( gram.HEX_NUM | gram.ENGINEERING_NUM | gram.DECIMAL_NUM | gram.INTEGER | gram.NUM ) )

Definition at line 91 of file grammars.py.

tuple blockit::C::grammars::ATTRIBUTE = pp.Keyword("__attribute__")

Definition at line 64 of file grammars.py.

tuple blockit::C::grammars::ATTRIBUTES = pp.Group(ATTRIBUTE + pp.Literal("((") + pp.OneOrMore((pp.Word(pp.alphanums)|PARENEDVALUE)) + pp.Literal("))"))

Definition at line 66 of file grammars.py.

Definition at line 84 of file grammars.py.

Checks scanning of multiple preprocessed prototypes
Checks parsing of preprocessed prototypes
Checks parsing of non-preprocessed prototypes
Checks parsing of struct defined in typedef
Checks parsing of enum defined in typedef
Checks to ensure proper parsing of simple typedefs
Checks to ensure proper parsing of simple enums
Checks to ensure proper parsing of simple structs
Checks parsing of structs
Checks parsing of struct prototypes
Checks parsing of variable names
Tests capture of intrinsic variable declaration
Tests type specification capturing

Definition at line 325 of file grammars.py.

Definition at line 124 of file grammars.py.

tuple blockit::C::grammars::COMMA = pp.Literal(",")

Definition at line 47 of file grammars.py.

tuple blockit::C::grammars::CONST = pp.Keyword("const")

Definition at line 55 of file grammars.py.

Definition at line 43 of file grammars.py.

Definition at line 326 of file grammars.py.

tuple blockit::C::grammars::ELLIPSIS = pp.Literal("...")

Definition at line 56 of file grammars.py.

tuple blockit::C::grammars::ENUM = pp.Keyword("enum")

Definition at line 57 of file grammars.py.

tuple blockit::C::grammars::ENUMDECL = pp.Forward()

Definition at line 40 of file grammars.py.

Definition at line 81 of file grammars.py.

tuple blockit::C::grammars::EQUALS = pp.Literal("=")

Definition at line 52 of file grammars.py.

tuple blockit::C::grammars::EXTERN = pp.Keyword("extern")

Definition at line 58 of file grammars.py.

Definition at line 148 of file grammars.py.

Definition at line 158 of file grammars.py.

tuple blockit::C::grammars::IDENT = pp.Word( pp.alphas+"_", pp.alphanums+"_$" )

Definition at line 44 of file grammars.py.

tuple blockit::C::grammars::INLINE = pp.Keyword("__inline__")

Definition at line 67 of file grammars.py.

tuple blockit::C::grammars::INTEGER = pp.Word( pp.nums )

Definition at line 45 of file grammars.py.

Definition at line 76 of file grammars.py.

tuple blockit::C::grammars::LBRACE = pp.Literal("{")

Definition at line 48 of file grammars.py.

tuple blockit::C::grammars::LBRACK = pp.Literal("[")

Definition at line 50 of file grammars.py.

tuple blockit::C::grammars::LONG = pp.Keyword("long")

Definition at line 59 of file grammars.py.

Definition at line 78 of file grammars.py.

tuple blockit::C::grammars::LPAREN = pp.Literal("(")

Definition at line 53 of file grammars.py.

Initial value:
00001 pp.Group( ( TYPESPEC | TYPENAME | ENUMSPEC ) + POINTERNOTATION + \
00002     pp.Group( pp.delimitedList( pp.Group(ASSIGNMENTFIELDARR | VARNAMESPECARR) ) ) + SEMI )

Definition at line 103 of file grammars.py.

Initial value:
00001 pp.Group( ENUMSPEC + POINTERNOTATION + \
00002     pp.Group( pp.delimitedList( pp.Group(ASSIGNMENTFIELDARR | VARNAMESPECARR) ) ) + SEMI )

Definition at line 105 of file grammars.py.

Initial value:
00001 pp.Group( STRUCTSPEC + POINTERNOTATION + \
00002     pp.Group( pp.delimitedList( pp.Group(ASSIGNMENTFIELDARR | VARNAMESPECARR) ) ) + SEMI )

Definition at line 107 of file grammars.py.

tuple blockit::C::grammars::output = bnf.parseString("extern cudaError_t cudaGetDeviceProperties(struct cudaDeviceProp *prop, int device);")

Definition at line 342 of file grammars.py.

tuple blockit::C::grammars::PARENEDVALUE = LPAREN+pp.Word(pp.alphanums)

Definition at line 65 of file grammars.py.

tuple blockit::C::grammars::POINTERNOTATION = pp.Optional(pp.Word("*"), default=None)

Definition at line 69 of file grammars.py.

Definition at line 153 of file grammars.py.

Definition at line 143 of file grammars.py.

tuple blockit::C::grammars::RBRACE = pp.Literal("}")

Definition at line 49 of file grammars.py.

tuple blockit::C::grammars::RBRACK = pp.Literal("]")

Definition at line 51 of file grammars.py.

tuple blockit::C::grammars::RPAREN = pp.Literal(")")

Definition at line 54 of file grammars.py.

tuple blockit::C::grammars::SEMI = pp.Literal(";")

Definition at line 46 of file grammars.py.

tuple blockit::C::grammars::SHORT = pp.Keyword("short")

Definition at line 60 of file grammars.py.

tuple blockit::C::grammars::STATIC = pp.Keyword("static")

Definition at line 61 of file grammars.py.

tuple blockit::C::grammars::STRUCT = pp.Keyword("struct")

Definition at line 62 of file grammars.py.

tuple blockit::C::grammars::STRUCTDECL = pp.Forward()

Definition at line 39 of file grammars.py.

Definition at line 80 of file grammars.py.

Definition at line 79 of file grammars.py.

tuple blockit::C::grammars::suite = unittest.TestLoader()

Definition at line 722 of file grammars.py.

Initial value:
00001 """
00002         struct {
00003             long a;
00004             short b;
00005             char c[32]; /* comment */
00006             } a;
00007 
00008         struct {
00009           int i;
00010           } dimple;
00011     """

Definition at line 170 of file grammars.py.

Definition at line 182 of file grammars.py.

Definition at line 217 of file grammars.py.

tuple blockit::C::grammars::TYPEDEF = pp.Keyword("typedef")

Definition at line 70 of file grammars.py.

Definition at line 134 of file grammars.py.

tuple blockit::C::grammars::TYPEDEFSPEC = pp.Keyword("typedef")

Definition at line 131 of file grammars.py.

Definition at line 72 of file grammars.py.

tuple blockit::C::grammars::UNSIGNED = pp.Keyword("unsigned")

Definition at line 68 of file grammars.py.

Definition at line 73 of file grammars.py.

Definition at line 85 of file grammars.py.

tuple blockit::C::grammars::VARNAMESPECARR = ( VARNAME + pp.Optional( BITFIELDSPEC | ( LBRACK + ARRAYSIZESPECIFIER + RBRACK ), default=None))

Definition at line 90 of file grammars.py.

tuple blockit::C::grammars::VOID = pp.Keyword("void")

Definition at line 63 of file grammars.py.

 All Classes Namespaces Files Functions Variables Properties