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

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

Issue 61683006: Experimental lexer generator: Fix action printing. (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 | « tools/lexer_generator/dfa.py ('k') | no next file » | 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 365
366 def f(node, node_content): 366 def f(node, node_content):
367 for key, values in node.transitions().items(): 367 for key, values in node.transitions().items():
368 if key == TransitionKey.epsilon(): 368 if key == TransitionKey.epsilon():
369 key = "ε" 369 key = "ε"
370 key = str(key).replace('\\', '\\\\') 370 key = str(key).replace('\\', '\\\\')
371 for value in values: 371 for value in values:
372 if value[1]: 372 if value[1]:
373 node_content.append( 373 node_content.append(
374 " S_%d -> S_%d [ label = \"%s {%s} -> %s\" ];" % 374 " S_%d -> S_%d [ label = \"%s {%s} -> %s\" ];" %
375 (node.node_number(), value[0].node_number(), key, value[1][0], 375 (node.node_number(), value[0].node_number(), key, value[1][1],
376 value[1][1])) 376 value[1][2]))
377 else: 377 else:
378 node_content.append( 378 node_content.append(
379 " S_%d -> S_%d [ label = \"%s\" ];" % 379 " S_%d -> S_%d [ label = \"%s\" ];" %
380 (node.node_number(), value[0].node_number(), key)) 380 (node.node_number(), value[0].node_number(), key))
381 return node_content 381 return node_content
382 382
383 node_content = self.__visit_all_edges(f, []) 383 node_content = self.__visit_all_edges(f, [])
384 384
385 return ''' 385 return '''
386 digraph finite_state_machine { 386 digraph finite_state_machine {
387 rankdir=LR; 387 rankdir=LR;
388 node [shape = circle, style=filled, bgcolor=lightgrey]; S_%s 388 node [shape = circle, style=filled, bgcolor=lightgrey]; S_%s
389 node [shape = doublecircle, style=unfilled]; S_%s 389 node [shape = doublecircle, style=unfilled]; S_%s
390 node [shape = circle]; 390 node [shape = circle];
391 %s 391 %s
392 } 392 }
393 ''' % (self.__start.node_number(), 393 ''' % (self.__start.node_number(),
394 self.__end.node_number(), 394 self.__end.node_number(),
395 "\n".join(node_content)) 395 "\n".join(node_content))
OLDNEW
« no previous file with comments | « tools/lexer_generator/dfa.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698