> Also interesting is that our processors, which aren't overly
> far apart in clock speed, vary so greatly in processing this
> problem. Maybe Intel is better *grin*
Urp, turns out I have an "Athlon Inside" label right here on the deck of my
laptop! Maybe the difference is my 1.2Gb of RAM.
s, use an Or, which will match the longest, or reorder the MatchFirstto put the most restrictive _expression_ first.Welcome to pyparsing, please let me know how your project goes!
-- Paul-Original Message-From: Liam Clarke [mailto:[EMAIL PROTECTED]]Sent: Monday, July 25, 2005 8:31 AMTo: Paul McGu
integer expression "masks" the real,
and since it occurs first, it will match first. The two solutions are:
number = (integer ^ real)
Or
number = (real | integer)
That is, use an Or, which will match the longest, or reorder the MatchFirst
to put the most restrictive expression first.
Welcom
x27;10'], ['bar', '20'
[['foo', '10'], ['bar', '20']]
10
20
-- Paul
-Original Message-
From: Liam Clarke [mailto:[EMAIL PROTECTED]
Sent: Monday, July 25, 2005 7:38 AM
To: Paul McGuire
Cc: tutor@python.org
Subject:
Liam -
The two arguments to Word work this way:
- the first argument lists valid *initial* characters
- the second argument lists valid *body* or subsequent characters
For example, in the identifier definition,
identifier = pp.Word(pp.alphas, pp.alphanums + "_/:.")
identifiers *must* start wit
s is about the only optimization I can think of.
-- Paul
-Original Message-
From: Liam Clarke [mailto:[EMAIL PROTECTED]
Sent: Monday, July 25, 2005 7:38 AM
To: Paul McGuire
Cc: tutor@python.org
Subject: Re: [Tutor] Parsing problem
Hi Paul,
Well various tweaks and such done, it parses perfectly,
-Original Message-
From: Liam Clarke [mailto:[EMAIL PROTECTED]
Sent: Sunday, July 24, 2005 10:21 AM
To: Paul McGuire
Cc: tutor@python.org
Subject: Re: [Tutor] Parsing problem
Hi Paul,
That is fantastic. It works, and using that pp.group is the key with the
nested braces.
I just ran th
ted string. Probably good practice to always enclosein quotes the _expression_ being assigned to a Forward using '<<'.-- Paul-Original Message-From: Liam Clarke [mailto:
[EMAIL PROTECTED]]Sent: Saturday, July 23, 2005 9:03 AMTo: Paul McGuireCc: tutor@python.orgSubject: Re: [
^ RHS ) + RBRACE ) )
-- Paul
-Original Message-
From: Liam Clarke [mailto:[EMAIL PROTECTED]
Sent: Sunday, July 24, 2005 10:21 AM
To: Paul McGuire
Cc: tutor@python.org
Subject: Re: [Tutor] Parsing problem
Hi Paul,
That is fantastic. It works, and using that pp.group is the key with the
nest
Hi Paul,
Well various tweaks and such done, it parses perfectly, so much thanks,
I think I now have a rough understanding of the basics of pyparsing.
Now, onto the fun part of optimising it. At the moment, I'm looking at
2 - 5 minutes to parse a 2000 line country section, and that's with
psyco.
Hi Paul,
My apologies, as I was jumping into my car after sending that email, it clicked in my brain.
"Oh yeah... initial & body..."
But good to know about how to accept valid numbers.
Sorry, getting a bit too quick to fire off emails here.
Regards,
Liam ClarkeOn 7/25/05, Paul McGuire <[EMA
x27;, so RHS only worked
if it was handed a quoted string. Probably good practice to always enclose
in quotes the expression being assigned to a Forward using '<<'.
-- Paul
-Original Message-
From: Liam Clarke [mailto:[EMAIL PROTECTED]
Sent: Saturday, July 23, 2005 9:03
*sigh* I just read the documentation more carefully and found the difference between the
| operator and the ^ operator.
Input -
j = { line = { foo = 10 bar = 20 } }
New code
sel = pp.Forward()
values = ((pp.Word(pp.printables) + pp.Suppress("=") + pp.Word(pp.printables)) ^ sel)
sel << (pp.Wo
Hmmm... just a quick update, I've been poking around and I'm obviously making some error of logic.
Given a line -
f = "j = { line = { foo = 10 bar = 20 } }"
And given the following code -
select = pp.Forward()select <<
pp.Word(pp.printables) + pp.Suppress("=") + pp.Suppress("{") +
pp.OneO
Howdy,
I've attempted to follow your lead and have started from scratch, I
could just copy and paste your solution (which works pretty well), but
I want to understand what I'm doing *grin*
However, I've been hitting a couple of ruts in the path to
enlightenment. Is there a way to tell pyparsing
Liam, Kent, and Danny -
It sure looks like pyparsing is taking on a life of its own! I can see I no
longer am the only one pitching pyparsing at some of these applications!
Yes, Liam, it is possible to create dictionary-like objects, that is,
ParseResults objects that have named values in them.
Well, I've been poking around and... well.. this is way better than writing complex regexes.
To suit my needs, I need something that can handle -
foo = bar
foo = 20
foo = { bar 20 }
foo = { bar = 20 baz}
foo = {bar = 20 baz { dave henry}}
OK, so the last one's extreme. So far, I can handle down
Thanks guys, I daresay I will have a lot of questions regarding this,
but at least I have a point to start digging and a better shovel!
Cheers,
Liam ClarkeOn 7/19/05, Danny Yoo <[EMAIL PROTECTED]> wrote:
On Mon, 18 Jul 2005, Liam Clarke wrote:> country = {> tag = ENG> ai = {> flags = { }> combat
On Mon, 18 Jul 2005, Liam Clarke wrote:
> country = {
> tag = ENG
> ai = {
> flags = { }
> combat = { DAU FRA ORL PRO }
> continent = { }
> area = { }
> region = { "British Isles" "NorthSeaSea" "ECAtlanticSea" "NAtlanticSea"
> "TagoSea" "WCAtlanticSea" }
> war = 60
> ferocity = no
> }
> }
[Long
Liam Clarke wrote:
> What I need to do, is to turn this into a data structure, and I think
> this relates to XML in a way. Basically, I want to parse the above (I
> assume I'll be counting braces to find where I am) so that a country
> object called ENG has a dictionary called ai, which points t
Hi all,
I am a Europa Universalis II freak, and in attempting to recreate a
lost saved game, I had to delve into the mechanics of the save game
file.
Which, luckily, is plain text.
It's formatted like this -
country = {
tag = ENG
ai = {
flags = { }
combat = { DAU
21 matches
Mail list logo