Problems with dparser grammar

  • Thread starter =?ISO-8859-1?Q?Joachim_M=E5rtensson?=
  • Start date
?

=?ISO-8859-1?Q?Joachim_M=E5rtensson?=

Hello, I am playing around a little bit with dparser, and I thought that
maybe someone on this list can help me out(There does not seem to be a
dparser list, atleast not an active one). I am total n00b to parsers so
this might be very easy. I want a parser that can parse both these lines
(What I am looking to construct is a parser of a _very_ limited subset
of objective-c).

[[self _rowsForAddingContentObject:content] retain]
NSArray *contentRowArray

This is what I have so far.

from dparser import Parser

def d_objcmsg(t):
'objcmsg: "\[" (objcmsg|var) msg "\]" '
def d_varDef(t):
'varDef: classname "\*" var'
def d_classname(t):
'classname: "[A-Z][A-Za-z_0-9]*"'
def d_var(t):
'var: "[a-z_][A-Za-z_0-9]*" '
def d_msg(t):
'msg: (msgWithArg|"[a-z_][A-Za-z_0-9]*")'
def d_msgWithArg(t):
'msgWithArg: "[a-z_][A-Za-z_0-9]*" ":" (var|objcmsg)'
Parser().parse("[[self _rowsForAddingContentObject:content]
retain]",print_debug_info=1)
Parser().parse("NSArray *contentRowArray",print_debug_info=1)

this makes the "[[self _rowsForAddingContentObject:content] retain]"
line pass, however I get a syntax error on the other one. Switching the
placing of d_obcmsg and d_varDef makes the other line pass, but then the
first fail with a syntax error. I want both of the lines to pass. Anyone
have any ideas?

Thanks in advance.
Joachim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top