Skip to Content.
Sympa Menu

maude-help - [Maude-help] Re: Parsing question (answer + new question)

maude-help AT lists.cs.illinois.edu

Subject: Maude-help mailing list

List archive

[Maude-help] Re: Parsing question (answer + new question)


Chronological Thread 
  • From: Todd Wilson <twilson AT csufresno.edu>
  • To: maude-help AT maude.cs.uiuc.edu
  • Subject: [Maude-help] Re: Parsing question (answer + new question)
  • Date: Tue, 01 Nov 2005 22:37:23 -0800
  • List-archive: <http://maude.cs.uiuc.edu/pipermail/maude-help>
  • List-id: Maude help list <maude-help.maude.cs.uiuc.edu>

I recently asked:
Is there a way that I can get Maude to (meta)parse literal constants
without also automatically parsing expressions involving these?

My problem was that using metaParse(upModule(M),...), where M was 'NAT, 'FLOAT, 'STRING, or some module like EXP that imported these together, didn't work, because all of the operations defined on the respective sorts were also imported. (My examples had some minor errors, as well.)

Well, by doing some experiments, I found that the following works:

fmod EXP is
sorts Nat Float String Exp .
subsorts Nat Float String < Exp .
op 0 : -> Nat .
op s_ : Nat -> Nat [iter special (
id-hook SuccSymbol ()
term-hook zeroTerm (0))] .
op <Floats> : -> Float [special (id-hook FloatSymbol ())] .
op <Strings> : -> String [special (id-hook StringSymbol ())] .

op f : Exp -> Exp .
endfm

Now, entering the following

select META-LEVEL .
red metaParse(upModule('EXP,false), 'f '`( '123 '`), 'Exp) .
red metaParse(upModule('EXP,false), 'f '`( '1.23 '`), 'Exp) .
red metaParse(upModule('EXP,false), 'f '`( '"123" '`), 'Exp) .
red metaParse(upModule('EXP,false), 'f '`( '123 '+ '1 '`), 'Exp) .

gives the results I wanted, namely:

result ResultPair: {'f['s_^123['0.Nat]],'Exp}
result ResultPair: {'f['1.23.Float],'Exp}
result ResultPair: {'f['"123".String],'Exp}
result ResultPair?: noParse(3)

I copied the "special" declarations used in EXP above from prelude.maude, hoping that they might produce the parsing behavior I was looking for, and I was rewarded. However, now, my question becomes: what is the link between these specials and the way Maude parses integers, floats, and strings? More generally, does there exist any documentation of these special attributes, id-hook, op-hook, term-hook, etc.? Am I creating some possible problems by using these features to parse literal constants in my applications?

Todd Wilson
Department of Computer Science
California State University, Fresno






Archive powered by MHonArc 2.6.16.

Top of Page