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

Unified Diff: tools/lexer_generator/generator.py

Issue 59643002: Experimental parser: simplified rule lexer and parser (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lexer/lexer_py.re ('k') | tools/lexer_generator/rule_lexer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lexer_generator/generator.py
diff --git a/tools/testrunner/local/junit_output.py b/tools/lexer_generator/generator.py
similarity index 64%
copy from tools/testrunner/local/junit_output.py
copy to tools/lexer_generator/generator.py
index 437adb178931f82364aa87e66315231b7b57a56d..c4dea29229192cdd7e2a26bdadf5472321da61a9 100644
--- a/tools/testrunner/local/junit_output.py
+++ b/tools/lexer_generator/generator.py
@@ -25,25 +25,36 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+from nfa import Nfa
+from dfa import Dfa
+from rule_lexer import RuleLexer
+from rule_parser import RuleParser
+from regex_parser import RegexParser
-import xml.etree.ElementTree as xml
+def lex_file(file_name):
+ lexer = RuleLexer()
+ lexer.build()
+ with open(file_name, 'r') as f:
+ lexer.lexer.input(f.read())
+ while True:
+ tok = lexer.lexer.token()
+ if not tok: break # No more input
+ print tok
+def parse_file(file_name):
+ rule_parser = RuleParser()
+ rule_parser.build()
+ with open(file_name, 'r') as f:
+ rule_parser.parse(f.read())
+ print "aliases"
+ for k, v in rule_parser.aliases.items():
+ print "\t%s : %s" % (k, v)
+ print "rules"
+ for k, v in rule_parser.rules.items():
+ print "\t%s" % k
+ for t in v:
+ print "\t\t%s" % str(t)
-class JUnitTestOutput:
- def __init__(self, test_suite_name):
- self.root = xml.Element("testsuite")
- self.root.attrib["name"] = test_suite_name
-
- def HasRunTest(self, test_name, test_duration, test_failure):
- testCaseElement = xml.Element("testcase")
- testCaseElement.attrib["name"] = " ".join(test_name)
- testCaseElement.attrib["time"] = str(round(test_duration, 3))
- if len(test_failure):
- failureElement = xml.Element("failure")
- failureElement.text = test_failure
- testCaseElement.append(failureElement)
- self.root.append(testCaseElement)
-
- def FinishAndWrite(self, file):
- xml.ElementTree(self.root).write(file, "UTF-8")
-
+if __name__ == '__main__':
+ # lex_file('src/lexer/lexer_py.re')
+ parse_file('src/lexer/lexer_py.re')
« no previous file with comments | « src/lexer/lexer_py.re ('k') | tools/lexer_generator/rule_lexer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698