Lexer/Parser question: TPG

2016-11-14 Thread Johannes Bauer
Hi group, this is not really a Python question, but I use Python to lex/parse some input. In particular, I use the amazing TPG (http://cdsoft.fr/tpg/). However, I'm now stuck at a point and am sure I'm not doing something correctly -- since there's a bunch of really smart people here, I hope to ge

Re: csv Parser Question - Handling of Double Quotes

2008-03-28 Thread Aaron Watters
On Mar 27, 6:00 pm, John Machin <[EMAIL PROTECTED]> wrote: > ...The Python csv module emulates Excel in delivering garbage silently in > cases when the expected serialisation protocol has (detectably) not > been followed Fine, but I'd say the heuristic adopted produces bizarre and surprising r

Re: csv Parser Question - Handling of Double Quotes

2008-03-27 Thread John Machin
On Mar 28, 8:40 am, [EMAIL PROTECTED] wrote: > On Mar 27, 1:53 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: > > > > > En Thu, 27 Mar 2008 17:37:33 -0300, Aaron Watters > > <[EMAIL PROTECTED]> escribió: > > > >> "this";"is";"a";"test" > > > >> Resulting in an output of: > > > >> ['this', 'is

Re: csv Parser Question - Handling of Double Quotes

2008-03-27 Thread John Machin
On Mar 28, 7:37 am, Aaron Watters <[EMAIL PROTECTED]> wrote: > > If you want fame and admiration you could fix > the arguably bug in the csv module and send > the patch to the python bugs mailing list. > However, I just had a perusal of csv.py > good luck :). It is *NOT* a bug in the Python CS

Re: csv Parser Question - Handling of Double Quotes

2008-03-27 Thread jwbrown77
On Mar 27, 1:53 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Thu, 27 Mar 2008 17:37:33 -0300, Aaron Watters   > <[EMAIL PROTECTED]> escribió: > > > > >> "this";"is";"a";"test" > > >> Resulting in an output of: > > >> ['this', 'is', 'a', 'test'] > > >> However, if I modify the csv to: > >

Re: csv Parser Question - Handling of Double Quotes

2008-03-27 Thread Gabriel Genellina
En Thu, 27 Mar 2008 17:37:33 -0300, Aaron Watters <[EMAIL PROTECTED]> escribió: >> "this";"is";"a";"test" >> >> Resulting in an output of: >> >> ['this', 'is', 'a', 'test'] >> >> However, if I modify the csv to: >> >> "t"h"is";"is";"a";"test" >> >> The output changes to: >> >> ['th"is"', 'is', '

Re: csv Parser Question - Handling of Double Quotes

2008-03-27 Thread Aaron Watters
> "this";"is";"a";"test" > > Resulting in an output of: > > ['this', 'is', 'a', 'test'] > > However, if I modify the csv to: > > "t"h"is";"is";"a";"test" > > The output changes to: > > ['th"is"', 'is', 'a', 'test'] I'd be tempted to say that this is a bug, except that I think the definition of "c

csv Parser Question - Handling of Double Quotes

2008-03-27 Thread jwbrown77
Hello, I am trying to read a csv file. I have the following functioning code: BEGIN import csv reader = csv.reader(open("test.csv", "rb"), delimiter=';') for row in reader: print row END This code will successfully parse my csv file formatted as such: "this";"is";"a";"t

Re: Option parser question - reading options from file as well as command line

2006-05-22 Thread Tim N. van der Leeuw
Andrew Robert wrote: > Hi Everyone. > > > I tried the following to get input into optionparser from either a file > or command line. > > Hi Andrew, I played around a bit more, not happy that the read_file method which I discovered earlier on the Values - object takes a property-file like input an

Re: Option parser question - reading options from file as well as command line

2006-05-17 Thread Tim N. van der Leeuw
Andrew Robert wrote: > Tim N. van der Leeuw wrote: > > Andrew Robert wrote: [...] > Hi Tim, > > I am using the pymqi module which is freely available at > http://pymqi.sourceforge.net/ . > > Documentation on the module can be found at > http://pymqi.sourceforge.net/pymqidoc.html . > > I have a few

Re: Option parser question - reading options from file as well as command line

2006-05-17 Thread Andrew Robert
Tim N. van der Leeuw wrote: > Andrew Robert wrote: >> Hi Everyone. >> >> >> I tried the following to get input into optionparser from either a file >> or command line. >> >> >> The code below detects the passed file argument and prints the file >> contents but the individual swithces do not get pas

Re: Option parser question - reading options from file as well as command line

2006-05-17 Thread Tim N. van der Leeuw
Andrew Robert wrote: > Hi Everyone. > > > I tried the following to get input into optionparser from either a file > or command line. > > > The code below detects the passed file argument and prints the file > contents but the individual swithces do not get passed to option parser. > After reading

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Max Erickson wrote: > I don't know much about optparse, but since I was bored: > help(o.parse_args) > Help on method parse_args in module optparse: > > parse_args(self, args=None, values=None) method of > optparse.OptionParser instance > parse_args(args : [string] = sys.argv[1:], >

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Max Erickson
Andrew Robert <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Any ideas? I don't know much about optparse, but since I was bored: >>> help(o.parse_args) Help on method parse_args in module optparse: parse_args(self, args=None, values=None) method of optparse.OptionParser instance p

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Max Erickson wrote: > Andrew Robert <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > <\snip> > Check parser.usage, it is likely to look a lot like your infile. > > I'm not sure, but I think you need to pass your alternative arguments > to parser.parse_args. > > max > Hi Max, I tri

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Max Erickson
Andrew Robert <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi Everyone. > > > I tried the following to get input into optionparser from either > a file or command line. > > > The code below detects the passed file argument and prints the > file contents but the individual swithces d

Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Hi Everyone. I tried the following to get input into optionparser from either a file or command line. The code below detects the passed file argument and prints the file contents but the individual swithces do not get passed to option parser. Doing a test print of options.qmanager shows it una

Re: parser question

2005-10-19 Thread Kent Johnson
Micah Elliott wrote: > You might be able to tackle this easily enough with REs if your > structures don't nest arbitrarily. It's hard to tell if this deserves > a formal grammar based on the example. If it does, you could try PLY > (which I've had a pleasant experienc

Re: parser question

2005-10-19 Thread Micah Elliott
On Oct 19, Daniel Sch�le wrote: > I have one format with this structure > > A { > x=1 > y=3 > B { > z = "something here" > } > } > > C { > } > > A { > x=0 > y=0 > B { > z = "other" > } > } > >

Re: parser question

2005-10-19 Thread Daniel Sch
> pattern = re.compile(r"^\s*A\s*{.*}\s*", re.MULTILINE | re.DOTALL) correction pattern = re.compile(r"^\s*A\s*{.*?}\s*", re.MULTILINE | re.DOTALL) I forgot to make it non gready :) -- http://mail.python.org/mailman/listinfo/python-list

parser question

2005-10-19 Thread Daniel Sch
Hello *, I have one format with this structure A { x=1 y=3 B { z = "something here" } } C { } A { x=0 y=0 B { z = "other" } } are there parsers for this kind of structure? specially I am inter