[Ometa] matching parameter values as literals
Mark J. Nelson
mnelson at cc.gatech.edu
Wed Aug 4 16:53:48 PDT 2010
Hi all,
This might be something obvious I'm overlooking, but I wasn't able to
figure out how to do it:
Is there a way for a rule to take a parameter and match its value
against the input stream? I know apply(param) will take the parameter
and match the rule *named* param, but how do I match the actual value of
param as if it were a literal?
For example, take the following contrived rule schema:
num42toA = 42 -> 'A'
num43toB = 43 -> 'B'
If some function literal(x) existed, one might generalize a higher-order
rule:
num integer:x char:result = literal(x) -> result
Of course, this particular example could be rewritten in more of a
generate-and-test style, with a match against integer:y followed by ?(y
== x), but I'm wondering if there's a way to do it directly. The
built-in 'token' function looks like it must do this for strings, but
alas, it's hand-coded in Javascript in parser.js, not in OMeta syntax.
If my literal() function existed, I'd imagine 'token' would be defined as:
token string:t = spaces* literal(t) -> t
Does such a function exist and I'm just missing it? Or am I on the wrong
track here?
Thanks,
Mark
P.S. - Apart from still working out all the details, and attempting to
get somewhat proficient at debugging grammars (i.e. more proficient than
not at all), I'm quite liking OMeta so far.
--
Mark J. Nelson | http://www.cc.gatech.edu/~mnelson/
Researcher, Expressive Intelligence Studio, UC Santa Cruz
PhD student, School of Interactive Computing, Georgia Tech
More information about the OMeta
mailing list