示例#1
0
    def factor(self, ast):
        return ast

    def unary(self, ast):
        return ast

    def id(self, ast):
        return ast

    def constant(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = cl1ckParser(parseinfo=False)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, cl1ckParser, name='cl1ck')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#2
0
        nameguard=None,
        comments_re=None,
        eol_comments_re=None,
        ignorecase=None,
        left_recursion=True,
        **kwargs):

    with open(filename) as f:
        text = f.read()
    parser = DatParser(parseinfo=False)
    ast = parser.parse(
        text,
        startrule,
        filename=filename,
        trace=trace,
        whitespace=whitespace,
        nameguard=nameguard,
        ignorecase=ignorecase,
        **kwargs)
    return ast

if __name__ == '__main__':
    import json
    ast = generic_main(main, DatParser, name='Dat')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#3
0
        comments_re=None,
        eol_comments_re=None,
        ignorecase=None,
        left_recursion=True,
        **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or None
    parser = CalcParser(parseinfo=False)
    ast = parser.parse(
        text,
        startrule,
        filename=filename,
        trace=trace,
        whitespace=whitespace,
        nameguard=nameguard,
        ignorecase=ignorecase,
        **kwargs)
    return ast

if __name__ == '__main__':
    import json
    ast = generic_main(main, CalcParser, name='Calc')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#4
0
         comments_re=None,
         eol_comments_re=None,
         ignorecase=None,
         left_recursion=True,
         **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or None
    parser = MusicTextParser(parseinfo=False)
    ast = parser.parse(text,
                       startrule,
                       filename=filename,
                       trace=trace,
                       whitespace=whitespace,
                       nameguard=nameguard,
                       ignorecase=ignorecase,
                       **kwargs)
    return ast


if __name__ == '__main__':
    import json
    ast = generic_main(main, MusicTextParser, name='MusicText')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#5
0
        return ast

    def label(self, ast):
        return ast

    def content(self, ast):
        return ast

    def etext(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = djvused_hiddentextParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, djvused_hiddentextParser, name='djvused_hiddentext')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#6
0
文件: parser.py 项目: STKFLT/prax
        return ast

    def term(self, ast):
        return ast

    def factor(self, ast):
        return ast

    def literal(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = PraxParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, PraxParser, name='Prax')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#7
0
    def div(self, ast):
        return ast

    def atom(self, ast):
        return ast

    def number(self, ast):
        return ast

    def identifier(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = SimpleLangParser(parseinfo=False)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, SimpleLangParser, name='SimpleLang')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#8
0
        return ast

    def string(self, ast):
        return ast

    def NEWLINE(self, ast):
        return ast

    def CLASS(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = thinkingprocessesParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, thinkingprocessesParser, name='thinkingprocesses')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#9
0
        comments_re=None,
        eol_comments_re=None,
        ignorecase=None,
        left_recursion=True,
        **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or None
    parser = RQLParser(parseinfo=False)
    ast = parser.parse(
        text,
        startrule,
        filename=filename,
        trace=trace,
        whitespace=whitespace,
        nameguard=nameguard,
        ignorecase=ignorecase,
        **kwargs)
    return ast

if __name__ == '__main__':
    import json
    ast = generic_main(main, RQLParser, name='RQL')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#10
0
        comments_re='\\(\\*((?:.|\\n)*?)\\*\\)',
        eol_comments_re='#([^\\n]*?)$',
        ignorecase=None,
        left_recursion=True,
        **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or None
    parser = GrakoBootstrapParser(parseinfo=False)
    ast = parser.parse(
        text,
        startrule,
        filename=filename,
        trace=trace,
        whitespace=whitespace,
        nameguard=nameguard,
        ignorecase=ignorecase,
        **kwargs)
    return ast

if __name__ == '__main__':
    import json
    ast = generic_main(main, GrakoBootstrapParser, name='GrakoBootstrap')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#11
0
    def message(self, ast):
        return ast

    def messageBody(self, ast):
        return ast

    def proto(self, ast):
        return ast

    def topLevelDef(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = ProtobufParser(parseinfo=False)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, ProtobufParser, name='Protobuf')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#12
0
         nameguard=None,
         comments_re=None,
         eol_comments_re=None,
         ignorecase=None,
         left_recursion=True,
         **kwargs):

    with open(filename) as f:
        text = f.read()
    parser = DatParser(parseinfo=False)
    ast = parser.parse(text,
                       startrule,
                       filename=filename,
                       trace=trace,
                       whitespace=whitespace,
                       nameguard=nameguard,
                       ignorecase=ignorecase,
                       **kwargs)
    return ast


if __name__ == '__main__':
    import json
    ast = generic_main(main, DatParser, name='Dat')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#13
0
文件: csp_parser.py 项目: dsksh/ICPy
        return ast

    def integer(self, ast):
        return ast

    def float(self, ast):
        return ast

    def infinity(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = CspParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, CspParser, name='Csp')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
        nameguard=None,
        comments_re=None,
        eol_comments_re=None,
        ignorecase=None,
        left_recursion=True,
        **kwargs):

    with open(filename) as f:
        text = f.read()
    parser = SSSLParser(parseinfo=False)
    ast = parser.parse(
        text,
        startrule,
        filename=filename,
        trace=trace,
        whitespace=whitespace,
        nameguard=nameguard,
        ignorecase=ignorecase,
        **kwargs)
    return ast

if __name__ == '__main__':
    import json
    ast = generic_main(main, SSSLParser, name='SSSL')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#15
0
         comments_re='/\\*[\\s\\S]*?\\*/',
         eol_comments_re='--.*?$',
         ignorecase=True,
         left_recursion=True,
         **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or re.compile('\\s+', RE_FLAGS | re.DOTALL)
    parser = SqlParser(parseinfo=False)
    ast = parser.parse(text,
                       startrule,
                       filename=filename,
                       trace=trace,
                       whitespace=whitespace,
                       nameguard=nameguard,
                       ignorecase=ignorecase,
                       **kwargs)
    return ast


if __name__ == '__main__':
    import json
    ast = generic_main(main, SqlParser, name='Sql')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#16
0
        return ast

    def regex(self, ast):
        return ast

    def boolean(self, ast):
        return ast

    def eof(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = EBNFBootstrapParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, EBNFBootstrapParser, name='EBNFBootstrap')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#17
0
         comments_re=None,
         eol_comments_re=None,
         ignorecase=None,
         left_recursion=True,
         **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or None
    parser = LilyParser(parseinfo=False)
    ast = parser.parse(text,
                       startrule,
                       filename=filename,
                       trace=trace,
                       whitespace=whitespace,
                       nameguard=nameguard,
                       ignorecase=ignorecase,
                       **kwargs)
    return ast


if __name__ == '__main__':
    import json
    ast = generic_main(main, LilyParser, name='Lily')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#18
0
        nameguard=None,
        comments_re=None,
        eol_comments_re=None,
        ignorecase=None,
        left_recursion=True,
        **kwargs):

    with open(filename) as f:
        text = f.read()
    parser = signatureParser(parseinfo=False)
    ast = parser.parse(
        text,
        startrule,
        filename=filename,
        trace=trace,
        whitespace=whitespace,
        nameguard=nameguard,
        ignorecase=ignorecase,
        **kwargs)
    return ast

if __name__ == '__main__':
    import json
    ast = generic_main(main, signatureParser, name='signature')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#19
0
    def STRING(self, ast):
        return ast

    def NEWLINE(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    print('got text', text)
    print('startrule', startrule)
    parser = PythonParser(parseinfo=False)
    print 'made this', parser.parse(text,
                                    startrule,
                                    filename=filename,
                                    **kwargs)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, PythonParser, name='Python')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#20
0
        return ast

    def identifier_start(self, ast):
        return ast

    def identifier_part(self, ast):
        return ast

    def attribute_name(self, ast):
        return ast

    def compound_attribute_name(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = CqlParser(parseinfo=False)
    return parser.parse(text, startrule, filename=filename, **kwargs)

if __name__ == '__main__':
    import json
    ast = generic_main(main, CqlParser, name='Cql')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#21
0
        return ast

    def pattern(self, ast):
        return ast

    def topts(self, ast):
        return ast

    def fopts(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = jasParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, jasParser, name='jas')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#22
0
         comments_re=None,
         eol_comments_re=None,
         ignorecase=None,
         left_recursion=True,
         **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or None
    parser = RQLParser(parseinfo=False)
    ast = parser.parse(text,
                       startrule,
                       filename=filename,
                       trace=trace,
                       whitespace=whitespace,
                       nameguard=nameguard,
                       ignorecase=ignorecase,
                       **kwargs)
    return ast


if __name__ == '__main__':
    import json
    ast = generic_main(main, RQLParser, name='RQL')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#23
0
        return ast

    def parameter(self, ast):
        return ast

    def text(self, ast):
        return ast

    def string(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = DisplayPatternParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, DisplayPatternParser, name='DisplayPattern')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#24
0
         comments_re='\\(\\*((?:.|\\n)*?)\\*\\)',
         eol_comments_re='#([^\\n]*?)$',
         ignorecase=None,
         left_recursion=True,
         **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or None
    parser = GrakoBootstrapParser(parseinfo=False)
    ast = parser.parse(text,
                       startrule,
                       filename=filename,
                       trace=trace,
                       whitespace=whitespace,
                       nameguard=nameguard,
                       ignorecase=ignorecase,
                       **kwargs)
    return ast


if __name__ == '__main__':
    import json
    ast = generic_main(main, GrakoBootstrapParser, name='GrakoBootstrap')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#25
0
         nameguard=None,
         comments_re=None,
         eol_comments_re=None,
         ignorecase=None,
         left_recursion=True,
         **kwargs):

    with open(filename) as f:
        text = f.read()
    parser = signatureParser(parseinfo=False)
    ast = parser.parse(text,
                       startrule,
                       filename=filename,
                       trace=trace,
                       whitespace=whitespace,
                       nameguard=nameguard,
                       ignorecase=ignorecase,
                       **kwargs)
    return ast


if __name__ == '__main__':
    import json
    ast = generic_main(main, signatureParser, name='signature')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#26
0
    def VARIANT_IDENTIFIER(self, ast):
        return ast

    def IDENTIFIER(self, ast):
        return ast

    def LIST_SEPARATOR(self, ast):
        return ast

    def SEP(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = GnomicParser(parseinfo=False)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, GnomicParser, name='Gnomic')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#27
0
文件: parser.py 项目: jbrower95/crop
        return ast

    def complex_expr(self, ast):
        return ast

    def line(self, ast):
        return ast

    def start(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = CropParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, CropParser, name='Crop')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#28
0
    def number(self, ast):
        return ast

    def INT(self, ast):
        return ast

    def NAME(self, ast):
        return ast

    def NEWLINE(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = WhileLangParser(parseinfo=False)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, WhileLangParser, name='WhileLang')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#29
0
    def multimap(self, ast):
        return ast

    def type(self, ast):
        return ast

    def turnstile(self, ast):
        return ast

    def sequent(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = SequentsParser(parseinfo=False)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, SequentsParser, name='Sequents')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#30
0
        return ast

    def signextend(self, ast):
        return ast

    def not_(self, ast):
        return ast

    def issecure(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = pcodeParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, pcodeParser, name='pcode')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#31
0
文件: lilyparser.py 项目: Cecca/lydoc
        comments_re=None,
        eol_comments_re=None,
        ignorecase=None,
        left_recursion=True,
        **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or None
    parser = LilyParser(parseinfo=False)
    ast = parser.parse(
        text,
        startrule,
        filename=filename,
        trace=trace,
        whitespace=whitespace,
        nameguard=nameguard,
        ignorecase=ignorecase,
        **kwargs)
    return ast

if __name__ == '__main__':
    import json
    ast = generic_main(main, LilyParser, name='Lily')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#32
0
    def division(self, ast):
        return ast

    def factor(self, ast):
        return ast

    def subexpression(self, ast):
        return ast

    def number(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = CalcParser(parseinfo=False)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, CalcParser, name='Calc')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#33
0
        return ast

    def uint(self, ast):
        return ast

    def int(self, ast):
        return ast

    def float(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = NetlistParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, NetlistParser, name='Netlist')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#34
0
        return ast

    def literal_int(self, ast):
        return ast

    def nondigit(self, ast):
        return ast

    def pointer_or_ref_chars(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = SignatureParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, SignatureParser, name='Signature')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#35
0
        return ast

    def digits(self, ast):
        return ast

    def letters(self, ast):
        return ast

    def whitespace(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    parser = ForestParser()
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from grako.util import asjson

    ast = generic_main(main, ForestParser, name='Forest')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(asjson(ast), indent=2))
    print()
示例#36
0
    def string(self, ast):
        return ast

    def STRING(self, ast):
        return ast

    def NEWLINE(self, ast):
        return ast


def main(filename, startrule, **kwargs):
    with open(filename) as f:
        text = f.read()
    print( 'got text', text)
    print( 'startrule', startrule)
    parser = PythonParser(parseinfo=False)
    print 'made this', parser.parse(text, startrule, filename=filename, **kwargs)
    return parser.parse(text, startrule, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    ast = generic_main(main, PythonParser, name='Python')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()
示例#37
0
        comments_re='/\\*[\\s\\S]*?\\*/',
        eol_comments_re='--.*?$',
        ignorecase=True,
        left_recursion=True,
        **kwargs):

    with open(filename) as f:
        text = f.read()
    whitespace = whitespace or re.compile('\\s+', RE_FLAGS | re.DOTALL)
    parser = SqlParser(parseinfo=False)
    ast = parser.parse(
        text,
        startrule,
        filename=filename,
        trace=trace,
        whitespace=whitespace,
        nameguard=nameguard,
        ignorecase=ignorecase,
        **kwargs)
    return ast

if __name__ == '__main__':
    import json
    ast = generic_main(main, SqlParser, name='Sql')
    print('AST:')
    print(ast)
    print()
    print('JSON:')
    print(json.dumps(ast, indent=2))
    print()