Coverage for ion/integration/ais/validate_data_resource/data_resource_parser : 97.10%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
#!/usr/bin/env python
@file ion/integration/ais/validate_data_resource/data_resource_parser.py @author Ian Katz @brief Classes to parse a url for its metadata """
pass
# lexer and parser from Python Ply #regex's for the tokens we expect to read #t_NAME = r'[a-zA-Z_][a-zA-Z0-9_]*'
r'[a-zA-Z_][a-zA-Z0-9_]*' #print t
#numbers that can be negative and/or decimal r"NaN|(-?\d+(\.\d+)?(E-?\d+)?)" #print t.value, "becomes", float(t.value) else:
# Define a rule so we can track line numbers r'\n+'
raise ParseException(t)
"""parsing rules are contained in the comment to each function"""
"dasfile : NAME OPEN sections CLOSE" # p[0] : p[1] p[2] p[3] p[4] is how you read this
#list of single-entry dictionaries for sections
# recursive case for building a list... base case follows below "sections : section sections"
"sections : section"
"section : NAME OPEN lineitems CLOSE"
# lineitems is a list of single-entry dictionaries for lines... collapse it
# recursive case for building a list... base case follows below "lineitems : lineitem lineitems"
"lineitems : lineitem"
"""lineitem : NAME NAME meat SEMI | NAME NAME NAME SEMI | section """
#subsections are ok i think else:
#collapse number non-lists to just the number
"""meat : LITERAL | numberlist"""
else:
"""numberlist : numberlist COMMA NUMBER"""
"""numberlist : NUMBER"""
raise Exception(p)
|