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

Side by Side Diff: tools/nixysa/third_party/ply-3.1/test/lex_optimize3.py

Issue 2043006: WTF NPAPI extension. Early draft. Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 10 years, 7 months 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 # -----------------------------------------------------------------------------
2 # lex_optimize3.py
3 #
4 # Writes table in a subdirectory structure.
5 # -----------------------------------------------------------------------------
6 import sys
7
8 if ".." not in sys.path: sys.path.insert(0,"..")
9 import ply.lex as lex
10
11 tokens = (
12 'NAME','NUMBER',
13 'PLUS','MINUS','TIMES','DIVIDE','EQUALS',
14 'LPAREN','RPAREN',
15 )
16
17 # Tokens
18
19 t_PLUS = r'\+'
20 t_MINUS = r'-'
21 t_TIMES = r'\*'
22 t_DIVIDE = r'/'
23 t_EQUALS = r'='
24 t_LPAREN = r'\('
25 t_RPAREN = r'\)'
26 t_NAME = r'[a-zA-Z_][a-zA-Z0-9_]*'
27
28 def t_NUMBER(t):
29 r'\d+'
30 try:
31 t.value = int(t.value)
32 except ValueError:
33 print("Integer value too large %s" % t.value)
34 t.value = 0
35 return t
36
37 t_ignore = " \t"
38
39 def t_newline(t):
40 r'\n+'
41 t.lineno += t.value.count("\n")
42
43 def t_error(t):
44 print("Illegal character '%s'" % t.value[0])
45 t.lexer.skip(1)
46
47 # Build the lexer
48 lex.lex(optimize=1,lextab="lexdir.sub.calctab",outputdir="lexdir/sub")
49 lex.runmain(data="3+4")
50
51
52
OLDNEW
« no previous file with comments | « tools/nixysa/third_party/ply-3.1/test/lex_optimize2.py ('k') | tools/nixysa/third_party/ply-3.1/test/lex_re1.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698