Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/lexer_generator/lexer_test.py

Issue 66493003: Experimental lexer generator: fix dfa generation when there are epsilon transitions with actions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/lexer_generator/nfa.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 the V8 project authors. All rights reserved. 1 # Copyright 2013 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 "<<" { SHL } 58 "<<" { SHL }
59 " " { SPACE } 59 " " { SPACE }
60 eof <<terminate>>''' 60 eof <<terminate>>'''
61 61
62 lexer = Lexer(rules) 62 lexer = Lexer(rules)
63 63
64 string = '<< <\0' 64 string = '<< <\0'
65 self.__verify_action_stream( 65 self.__verify_action_stream(
66 lexer.lex(string), 66 lexer.lex(string),
67 [('SHL', '<<'), ('SPACE', ' '), ('LT', '<')]) 67 [('SHL', '<<'), ('SPACE', ' '), ('LT', '<')])
68
69
70 def test_consecutive_epsilon_transitions(self):
71 # This rule set will create a NFA where we first have an epsilon transition,
72 # then following that, an epsilon transition with an action. This will test
73 # that the action is correctly pulled forward when creating the dfa.
74 rules = '''
75 digit = [0-9];
76 number = (digit+ ("." digit+)?);
77 <default>
78 number { NUMBER }
79 eof <<terminate>>'''
80
81 lexer = Lexer(rules)
82
83 string = '555\0'
84 self.__verify_action_stream(
85 lexer.lex(string),
86 [('NUMBER', '555')])
OLDNEW
« no previous file with comments | « no previous file | tools/lexer_generator/nfa.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698