| Index: tools/lexer_generator/rule_lexer.py
|
| diff --git a/WATCHLISTS b/tools/lexer_generator/rule_lexer.py
|
| similarity index 71%
|
| copy from WATCHLISTS
|
| copy to tools/lexer_generator/rule_lexer.py
|
| index 9c2bce9c5589c22649b4a2c94837f00c8d669be1..be7b42f01d9cbb85ff38ffa83bf2c23085726a36 100644
|
| --- a/WATCHLISTS
|
| +++ b/tools/lexer_generator/rule_lexer.py
|
| @@ -25,22 +25,32 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -# Watchlist Rules
|
| -# Refer: http://dev.chromium.org/developers/contributing-code/watchlists
|
| -
|
| -# IMPORTANT: The regular expression filepath is tested against each path using
|
| -# re.search, so it is not usually necessary to add .*.
|
| -
|
| -{
|
| - 'WATCHLIST_DEFINITIONS': {
|
| - 'public_api': {
|
| - 'filepath': 'include/',
|
| - },
|
| - },
|
| -
|
| - 'WATCHLISTS': {
|
| - 'public_api': [
|
| - 'phajdan.jr@chromium.org',
|
| - ],
|
| - },
|
| -}
|
| +import ply.lex as lex
|
| +
|
| +class RuleLexer:
|
| +
|
| + tokens = (
|
| + 'ALIAS',
|
| + 'CONDITION_TRANSITION',
|
| + 'CONDITION'
|
| + )
|
| +
|
| + t_ignore = " \t\n"
|
| +
|
| + def t_ALIAS(self, t):
|
| + r'\s*(?P<name>[a-zA-Z0-9_]+)\s*=\s*(?P<regex>.+)\s*;\s*'
|
| + return t
|
| +
|
| + def t_CONDITION_TRANSITION(self, t):
|
| + r'\s*<(?P<old>[a-zA-Z]+)>\s*(?P<regex>.+)\s*:=>\s*(?P<new>.+)\s*'
|
| + return t
|
| +
|
| + def t_CONDITION(self, t):
|
| + r'\s*<(?P<old>[a-zA-Z]+)>\s*(?P<regex>.+)\s*{(?P<body>.+)}\s*'
|
| + return t
|
| +
|
| + def t_error(self, t):
|
| + raise Exception("Illegal character '%s'" % t.value[0])
|
| +
|
| + def build(self, **kwargs):
|
| + self.lexer = lex.lex(module=self, **kwargs)
|
|
|