Skipping input until first match

20 views
Skip to first unread message

Felipe Balbi

unread,
Dec 8, 2014, 1:16:54 PM12/8/14
to treet...@googlegroups.com
Hi,

is there a way to skip input until my first matching rule with treetop ?

I'm trying to parse a subset of C (some static struct definitions) to convert it
into another language.

Thanks

markus

unread,
Dec 8, 2014, 5:10:11 PM12/8/14
to treet...@googlegroups.com
Some are you maybe looking for something like:

rule main
# We're looking for a start mark, that may be proceeded
# by any amount of goop we don't care about.
goop* start_mark good_stuff
end

rule start_mark
"static" " "+ "struct"
end

rule goop
# Match any character that isn't the start of the start_mark
!start_mark .
end

rule good_stuff
# Real work lives here
end

-- Markus


Reply all
Reply to author
Forward
0 new messages