CHANGES revision 2632:1bb2f91485ea
1Version 1.3 2------------------------------ 312/10/02: jmdyck 4 Various minor adjustments to the code that Dave checked in today. 5 Updated test/yacc_{inf,unused}.exp to reflect today's changes. 6 712/10/02: beazley 8 Incorporated a variety of minor bug fixes to empty production 9 handling and infinite recursion checking. Contributed by 10 Michael Dyck. 11 1212/10/02: beazley 13 Removed bogus recover() method call in yacc.restart() 14 15Version 1.2 16------------------------------ 1711/27/02: beazley 18 Lexer and parser objects are now available as an attribute 19 of tokens and slices respectively. For example: 20 21 def t_NUMBER(t): 22 r'\d+' 23 print t.lexer 24 25 def p_expr_plus(t): 26 'expr: expr PLUS expr' 27 print t.lexer 28 print t.parser 29 30 This can be used for state management (if needed). 31 3210/31/02: beazley 33 Modified yacc.py to work with Python optimize mode. To make 34 this work, you need to use 35 36 yacc.yacc(optimize=1) 37 38 Furthermore, you need to first run Python in normal mode 39 to generate the necessary parsetab.py files. After that, 40 you can use python -O or python -OO. 41 42 Note: optimized mode turns off a lot of error checking. 43 Only use when you are sure that your grammar is working. 44 Make sure parsetab.py is up to date! 45 4610/30/02: beazley 47 Added cloning of Lexer objects. For example: 48 49 import copy 50 l = lex.lex() 51 lc = copy.copy(l) 52 53 l.input("Some text") 54 lc.input("Some other text") 55 ... 56 57 This might be useful if the same "lexer" is meant to 58 be used in different contexts---or if multiple lexers 59 are running concurrently. 60 6110/30/02: beazley 62 Fixed subtle bug with first set computation and empty productions. 63 Patch submitted by Michael Dyck. 64 6510/30/02: beazley 66 Fixed error messages to use "filename:line: message" instead 67 of "filename:line. message". This makes error reporting more 68 friendly to emacs. Patch submitted by Fran�ois Pinard. 69 7010/30/02: beazley 71 Improvements to parser.out file. Terminals and nonterminals 72 are sorted instead of being printed in random order. 73 Patch submitted by Fran�ois Pinard. 74 7510/30/02: beazley 76 Improvements to parser.out file output. Rules are now printed 77 in a way that's easier to understand. Contributed by Russ Cox. 78 7910/30/02: beazley 80 Added 'nonassoc' associativity support. This can be used 81 to disable the chaining of operators like a < b < c. 82 To use, simply specify 'nonassoc' in the precedence table 83 84 precedence = ( 85 ('nonassoc', 'LESSTHAN', 'GREATERTHAN'), # Nonassociative operators 86 ('left', 'PLUS', 'MINUS'), 87 ('left', 'TIMES', 'DIVIDE'), 88 ('right', 'UMINUS'), # Unary minus operator 89 ) 90 91 Patch contributed by Russ Cox. 92 9310/30/02: beazley 94 Modified the lexer to provide optional support for Python -O and -OO 95 modes. To make this work, Python *first* needs to be run in 96 unoptimized mode. This reads the lexing information and creates a 97 file "lextab.py". Then, run lex like this: 98 99 # module foo.py 100 ... 101 ... 102 lex.lex(optimize=1) 103 104 Once the lextab file has been created, subsequent calls to 105 lex.lex() will read data from the lextab file instead of using 106 introspection. In optimized mode (-O, -OO) everything should 107 work normally despite the loss of doc strings. 108 109 To change the name of the file 'lextab.py' use the following: 110 111 lex.lex(lextab="footab") 112 113 (this creates a file footab.py) 114 115 116Version 1.1 October 25, 2001 117------------------------------ 118 11910/25/01: beazley 120 Modified the table generator to produce much more compact data. 121 This should greatly reduce the size of the parsetab.py[c] file. 122 Caveat: the tables still need to be constructed so a little more 123 work is done in parsetab on import. 124 12510/25/01: beazley 126 There may be a possible bug in the cycle detector that reports errors 127 about infinite recursion. I'm having a little trouble tracking it 128 down, but if you get this problem, you can disable the cycle 129 detector as follows: 130 131 yacc.yacc(check_recursion = 0) 132 13310/25/01: beazley 134 Fixed a bug in lex.py that sometimes caused illegal characters to be 135 reported incorrectly. Reported by Sverre J�rgensen. 136 1377/8/01 : beazley 138 Added a reference to the underlying lexer object when tokens are handled by 139 functions. The lexer is available as the 'lexer' attribute. This 140 was added to provide better lexing support for languages such as Fortran 141 where certain types of tokens can't be conveniently expressed as regular 142 expressions (and where the tokenizing function may want to perform a 143 little backtracking). Suggested by Pearu Peterson. 144 1456/20/01 : beazley 146 Modified yacc() function so that an optional starting symbol can be specified. 147 For example: 148 149 yacc.yacc(start="statement") 150 151 Normally yacc always treats the first production rule as the starting symbol. 152 However, if you are debugging your grammar it may be useful to specify 153 an alternative starting symbol. Idea suggested by Rich Salz. 154 155Version 1.0 June 18, 2001 156-------------------------- 157Initial public offering 158 159