k-user AT lists.siebelschool.illinois.edu
Subject: K-user mailing list
List archive
- From: "Rosu, Grigore" <grosu AT illinois.edu>
- To: Corbin Simpson <mostawesomedude AT gmail.com>, "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
- Subject: Re: [K-user] Turning identifiers into matchable strings
- Date: Sun, 26 Jan 2014 12:54:06 +0000
- Accept-language: en-US
- List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
- List-id: <k-user.cs.uiuc.edu>
You should declare the particular Id names that you want to give semantics to:
rule E:Int . "mul" ( (X:Int) ) => E *Int X
rule E:Int . mul ( (X:Int) ) => E *Int X
Where the syntax generating the original pattern is:
syntax Exprs ::= List{Expr, ","}
syntax Expr ::= Expr "." Id "(" Exprs ")" [seqstrict]
I've been through many of the tutorial videos but haven't seen a language where specialization is handled this way. Do I have to specialize every one of these special messages in the syntax?
Thanks,
~ C.
--
When the facts change, I change my mind. What do you do, sir? ~ Keynes
Corbin Simpson
<MostAwesomeDude AT gmail.com>
syntax Id ::= "mul" | "plus" | ...
That's because the generic Ids are just tokens which are NOT included in the parser for the semantics automatically, to avoid parsing ambiguities. This must be explained in SIMPLE and KOOL, where special IDs have special
meaning.
Also, it seems you gave your operations the wrong strictness, because probably you do not want to evaluate the method name m as well in o.m(o1,o2). You probably want
syntax Exprs ::= List{Expr, ","} [seqstrict]
syntax Expr ::= Expr "." Id "(" Exprs ")" [seqstrict(1,3)]
syntax Expr ::= Expr "." Id "(" Exprs ")" [seqstrict(1,3)]
Grigore
From: k-user-bounces AT cs.uiuc.edu [k-user-bounces AT cs.uiuc.edu] on behalf of Corbin Simpson [mostawesomedude AT gmail.com]
Sent: Sunday, January 26, 2014 2:27 AM
To: k-user AT cs.uiuc.edu
Subject: [K-user] Turning identifiers into matchable strings
Sent: Sunday, January 26, 2014 2:27 AM
To: k-user AT cs.uiuc.edu
Subject: [K-user] Turning identifiers into matchable strings
Hi all,
I'm working on formalizing Kernel-E, a subset of the E language, since it has never had a formal semantics and I'm hoping to pin down exactly what a fast implementation of E would need to pay attention to. In the process, I'm discovering lots of fun things...
Everything's an object in E and objects interact with message passing; i.e. `obj.doThings(with, other, objects)`. I need to specialize some messages, like `mul`, to implement the concrete semantics for types like integers, which are core to the syntax and semantics.
However, I can't quite figure out how to match on the Id sort in rules. I've currently tried these two variants with no success:I'm working on formalizing Kernel-E, a subset of the E language, since it has never had a formal semantics and I'm hoping to pin down exactly what a fast implementation of E would need to pay attention to. In the process, I'm discovering lots of fun things...
Everything's an object in E and objects interact with message passing; i.e. `obj.doThings(with, other, objects)`. I need to specialize some messages, like `mul`, to implement the concrete semantics for types like integers, which are core to the syntax and semantics.
rule E:Int . "mul" ( (X:Int) ) => E *Int X
rule E:Int . mul ( (X:Int) ) => E *Int X
Where the syntax generating the original pattern is:
syntax Exprs ::= List{Expr, ","}
syntax Expr ::= Expr "." Id "(" Exprs ")" [seqstrict]
I've been through many of the tutorial videos but haven't seen a language where specialization is handled this way. Do I have to specialize every one of these special messages in the syntax?
Thanks,
~ C.
--
When the facts change, I change my mind. What do you do, sir? ~ Keynes
Corbin Simpson
<MostAwesomeDude AT gmail.com>
- [K-user] Turning identifiers into matchable strings, Corbin Simpson, 01/26/2014
- Re: [K-user] Turning identifiers into matchable strings, Rosu, Grigore, 01/26/2014
Archive powered by MHonArc 2.6.16.