Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from lark import Lark
- test_str = """
- //asdasd
- extern "C"
- {
- //odfsafd
- def ak():
- //blablabla
- def xkcd():
- }
- """
- pydef_parser = Lark(r"""
- file: (COMMENT)* "extern 'C' {" [(COMMENT)*(def)*]* "}"
- def: "def" FUNCNAME "():"
- FUNCNAME: LETTER[(INT)*(LETTER)*]*
- COMMENT: /\/\/[^\n]*/
- | /#include[^\n]*/
- %import common.LETTER
- %import common.INT
- %import common.WS
- %ignore WS
- %ignore COMMENT
- """, start="file")
- print(pydef_parser.parse(test_str))
Advertisement
Add Comment
Please, Sign In to add comment