By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

Problems with dparser grammar

P: n/a
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

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.