Implement proper-oriented-quotes-sugar in parser.
Chris Pressey
11 years ago
149 | 149 | return lhs |
150 | 150 | |
151 | 151 | def expr5(self): |
152 | OQ = u'“'.encode('UTF-8') | |
153 | CQ = u'”'.encode('UTF-8') | |
154 | ||
152 | 155 | if self.consume('('): |
153 | 156 | e = self.expr0() |
154 | 157 | self.expect(')') |
166 | 169 | elif self.peek()[0] == '"': |
167 | 170 | s = self.consume_any()[1:-1] |
168 | 171 | return Call(Prodref('$', 'expect'), [AtomNode(s)]) |
172 | elif len(self.peek()) >= len(OQ) and self.peek()[0:len(OQ)] == OQ: | |
173 | s = self.consume_any()[len(OQ):-len(CQ)] | |
174 | node = None | |
175 | for c in s: | |
176 | expect = Call(Prodref('$', 'expect'), [AtomNode(c)]) | |
177 | if node is None: | |
178 | node = expect | |
179 | else: | |
180 | node = And(node, expect) | |
181 | return node | |
169 | 182 | elif self.consume(u'«') or self.consume('<<'): |
170 | 183 | t = self.texpr() |
171 | 184 | if self.consume(u'»') or self.consume('>>'): |