?
=?iso-8859-2?q?Bo=B9tjan_Jerko?=
Hello !
I am trying to understand pyparsing. Here is a little test program
to check Optional subclass:
from pyparsing import Word,nums,Literal,Optional
lbrack=Literal("[").suppress()
rbrack=Literal("]").suppress()
ddot=Literal(":").suppress()
start = Word(nums+".")
step = Word(nums+".")
end = Word(nums+".")
sequence=lbrack+start+Optional(ddot+step)+ddot+end+rbrack
tokens = sequence.parseString("[0:0.1:1]")
print tokens
tokens1 = sequence.parseString("[1:2]")
print tokens1
It works on tokens, but the error message is showed on
the second string ("[1:2]"). I don't get it. I did use
Optional for ddot and step so I guess they are optional.
Any hints what I am doing wrong?
The versions are pyparsing 1.1.2 and Python 2.3.3.
Thanks,
B.
I am trying to understand pyparsing. Here is a little test program
to check Optional subclass:
from pyparsing import Word,nums,Literal,Optional
lbrack=Literal("[").suppress()
rbrack=Literal("]").suppress()
ddot=Literal(":").suppress()
start = Word(nums+".")
step = Word(nums+".")
end = Word(nums+".")
sequence=lbrack+start+Optional(ddot+step)+ddot+end+rbrack
tokens = sequence.parseString("[0:0.1:1]")
print tokens
tokens1 = sequence.parseString("[1:2]")
print tokens1
It works on tokens, but the error message is showed on
the second string ("[1:2]"). I don't get it. I did use
Optional for ddot and step so I guess they are optional.
Any hints what I am doing wrong?
The versions are pyparsing 1.1.2 and Python 2.3.3.
Thanks,
B.