Sets info values of an open section references should be a dictionary with the
Sets info values of an open section references should be a dictionary with the
...
@@ -575,6 +592,16 @@ class Section(object):
...
@@ -575,6 +592,16 @@ class Section(object):
else:
else:
vals.append(section)
vals.append(section)
defget_value(self,metaInfo):
ifmetaInfo.nameinself.simple_values:
returnself.simple_values[metaInfo.name]
elifmetaInfo.nameinself.array_values:
returnself.array_values[metaInfo.name]
raiseKeyError(metaInfo.name)
defget_subsections(self,metaInfo):
returnself.subsections[metaInfo.name]
classSectionManager(object):
classSectionManager(object):
"""Manages the sections for the given metainfo.
"""Manages the sections for the given metainfo.
...
@@ -655,6 +682,27 @@ class SectionManager(object):
...
@@ -655,6 +682,27 @@ class SectionManager(object):
except (KeyError,IndexError):
except (KeyError,IndexError):
raiseException("Cannot add array values for metadata %s to section %d (%d) of %s, as it is not open"%(valueMetaInfo.name,gI,gIndex,self.metaInfo.name))
raiseException("Cannot add array values for metadata %s to section %d (%d) of %s, as it is not open"%(valueMetaInfo.name,gI,gIndex,self.metaInfo.name))
"""A Something that matches either a single line, or multiple lines grouped together.
"""
This is the base of a declarative parser."""
A Something that matches either a single line, or multiple lines grouped together.
This is the base of a declarative parser.
"""
classSubFlags(object):
classSubFlags(object):
Sequenced=0# the subMatchers should be executed in sequence
Sequenced=0# the subMatchers should be executed in sequence
Unordered=1# the subMatchers can be in any order
Unordered=1# the subMatchers can be in any order
...
@@ -87,9 +101,11 @@ class SimpleMatcher(object):
...
@@ -87,9 +101,11 @@ class SimpleMatcher(object):
weak=False,# this matcher should not "steal" the position
weak=False,# this matcher should not "steal" the position
repeats=False,# this matcher is expected to repeat
repeats=False,# this matcher is expected to repeat
required=False,# this value is required to have been matched on section close
required=False,# this value is required to have been matched on section close
floating=False,# this section goes not steal the context, useful for example for low level debugging/error messages.
# this section goes not steal the context, useful for example for low level debugging/error messages.
floating=False,
# valid from the point they are read until the exit from the enclosing section
# valid from the point they are read until the exit from the enclosing section
forwardMatch=False,# if start match should not eat input, but be forwarded to adHoc and subMatchers
# if start match should not eat input, but be forwarded to adHoc and subMatchers
forwardMatch=False,
name="",
name="",
adHoc=None,
adHoc=None,
otherMetaInfo=tuple(),# The metainfos that are later manually added ot the backend
otherMetaInfo=tuple(),# The metainfos that are later manually added ot the backend
...
@@ -101,7 +117,8 @@ class SimpleMatcher(object):
...
@@ -101,7 +117,8 @@ class SimpleMatcher(object):
coverageIgnore=False,# mark line as ignored in coverage analysis
coverageIgnore=False,# mark line as ignored in coverage analysis
onClose=None,# A dictionary of onClose callbacks that are specific to this SimpleMatcher
onClose=None,# A dictionary of onClose callbacks that are specific to this SimpleMatcher
onOpen=None,# A dictionary of onOpen callbacks that are specific to this SimpleMatcher
onOpen=None,# A dictionary of onOpen callbacks that are specific to this SimpleMatcher
startReAction=None,# A callback function that is called when the starting regex is matcher. If the regex has any capturing groups, they will be provided as well to this function as parameter called "groups".
# A callback function that is called when the starting regex is matcher. If the regex has any capturing groups, they will be provided as well to this function as parameter called "groups".
startReAction=None,
):
):
self.index=-1
self.index=-1
self.startReStr=startReStr
self.startReStr=startReStr
...
@@ -126,7 +143,8 @@ class SimpleMatcher(object):
...
@@ -126,7 +143,8 @@ class SimpleMatcher(object):
self.onClose=onClose
self.onClose=onClose
self.onOpen=onOpen
self.onOpen=onOpen
self.startReAction=startReAction
self.startReAction=startReAction
self.keep=False# Boolean flag used by the ParserOptimizer to determine which SimpleMatchers to keep
# Boolean flag used by the ParserOptimizer to determine which SimpleMatchers to keep
self.keep=False
# boolean flag to signal that this SimpleMatcher does not have any
# boolean flag to signal that this SimpleMatcher does not have any
# effect (besides progressing input file):
# effect (besides progressing input file):
# - no data extracted
# - no data extracted
...
@@ -134,12 +152,14 @@ class SimpleMatcher(object):
...
@@ -134,12 +152,14 @@ class SimpleMatcher(object):