[Pyparsing] Combine problem
Brought to you by:
ptmcg
From: Sebastian S. <ssc...@gm...> - 2009-06-11 03:01:30
|
Hello there! This is my first post to this list - first of all thanks for this awesome module, I could not live without it these days! My goal is to parse the following structure: s = """ struct VS_OUTPUT { float4 pos : SV_Position; float2 UV : TEXCOORD0; float3 vVec : TEXCOORD1; float3 lVec : TEXCOORD2; float3 nor : TEXCOORD3; float4 col : TEXCOORD4; float3 tan : TEXCOORD5; float4 lpos : TEXCOORD6; float depth : TEXCOORD7; float2 dof : TEXCOORD8; float2 VelocityUV : TEXCOORD9; };""" entryString = "float3 tan : TEXCOORD5;" def readStruct(s): header = Literal("struct VS_OUTPUT")+"{" regs = Combine("TEXCOORD"+Word(nums)) | "SV_Position" vType = Combine("float"+Optional(Word(nums))) entry = vType+Word(alphanums)+":"+regs+";" struct = header + OneOrMore(entry) + "};" print entry.parseString(entryString) This is working as is - but when i change entry = vType+Word(alphanums)+":"+regs+";" to entry = Combine(vType+Word(alphanums)+":"+regs+";") to make this into a single string, I get a parse Exception - it's not a big problem but I just don't understand why it doesn't work in this case :) Somehow I can't see the difference to where I use Combine in the lines above, where it seems just fine. Maybe I'm missing something really simple.. thanks for looking! seb -- Sebastian Schoellhammer Sr. Technical Artist Square Enix LTD www.square-enix.com |