The problem was elsewhere, not in my usage of ply. Sorry about the noise
2012/10/26 Enrique Pérez <[email protected]> > I am writing a parser for a grammar, and I want to allow Python sections > (delimitd by '\n<-\n' and '\n->\n') within code generated from that > grammar. I do not want to parse Python; I will feed it to exec. I just want > to get the whole lines, including whitespace. > > This is in my lexer: > > def t_begin_pycode(self, t): > r'<-' > t.lexer.begin('pycode') > > def t_pycode_newline(self, t): > r'\n+' > t.lexer.lineno += len(t.value) > > def t_pycode_IMPLIES(self, t): > r'->' > t.lexer.begin('INITIAL') > return t > > def t_pycode_PYCODE(self, t): > r'.+' > return t > > t_pycode_ignore = '' > > However, somewhere between this and the parser, the leading whitespace is > lost... > What am I doing wrong? > > I have looked at the GardenSnake parser by Andrew Dalke but I do not need > to parse indentation or distinguish types of whitespace. > > -- > You received this message because you are subscribed to the Google Groups > "ply-hack" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msg/ply-hack/-/W2Y9RLtuVPMJ. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Enrique Pérez Arnaud [email protected] -- You received this message because you are subscribed to the Google Groups "ply-hack" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
