Skip to Content.
Sympa Menu

k-user - Re: [K-user] Once working K program is now broken, need help (do we have changelogs ?)

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Once working K program is now broken, need help (do we have changelogs ?)


Chronological Thread 
  • From: "Rosu, Grigore" <grosu AT illinois.edu>
  • To: Ömer Sinan Ağacan <omeragacan AT gmail.com>, "Radu Mereuta" <headness13 AT gmail.com>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: Re: [K-user] Once working K program is now broken, need help (do we have changelogs ?)
  • Date: Mon, 9 Sep 2013 18:00:41 +0000
  • Accept-language: en-US
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Well, syntax is almost always tricky, so you should not get discouraged. In
our experience, when defining a non-trivial language, defining the syntax
often takes longer than defining the semantics :) But, I would personally
encourage you to fight the syntax until you either win or find a bug in the
tool. Yes, it is frustrating to spend time with "minor" syntactic issues,
but consider that 1) the problem is non-trivial (so the idea that defining
the syntax must be easy tends to be preconceived), and 2) you get two things
from defining your syntax (a parser for your language, and a parser for your
semantics), so it is not a waste.

In defense of 1 above, consider that instead of syntax Lst ::= List{Test, "
"} you wrote syntax Lst ::= List{Test, "c"}. Would you expect `[acb]` to
parse as the c-separated list containing elements a and b?

Grigore

p.s. You may want to avoid the builtin lists until you get more experience
with the tool.



________________________________________
From:
k-user-bounces AT cs.uiuc.edu

[k-user-bounces AT cs.uiuc.edu]
on behalf of Ömer Sinan Ağacan
[omeragacan AT gmail.com]
Sent: Monday, September 09, 2013 10:56 AM
To: Radu Mereuta
Cc:
k-user AT cs.uiuc.edu
Subject: Re: [K-user] Once working K program is now broken, need help (do we
have changelogs ?)

Hi Radu, thanks for your response,

I think one important lesson I learned from my experience with K
framework so far is that it's very, very hard to implement
complex(realistic) syntax in K and it's even harder to match that
syntax in rules(e.g. inside configurations).

So I decided to go on with very simple syntax, for instance, if my
language has a for-in syntax(like `for a in ... do ... end`) I'll try
to have something like ForIn(Id, Exp, Exp) in my syntax of semantics.
This makes testing harder because for each change I need to update my
external parser but my guess is it makes my work easier in general.

---
Ömer Sinan Ağacan
http://osa1.net


2013/9/9 Radu Mereuta
<headness13 AT gmail.com>:
> Hi Ömer,
>
> Try using List{Test,""}, without the space inside the separation terminal.
> The problem lays with SDF, the parser that we are using in K. Space is part
> of the layout definition (whitespaces that separate tokens in the grammar)
> and sometimes it has problems handling spaces, eol... inside terminals.
>
> If you use the list without the space, you will get a similar grammar for
> your language. Since Ids will match in a greedy way, the input `[a b]` will
> parse the same with both grammars. In your original grammar the space
> between the 'a' and 'b' should go to the list separator, and in the second
> grammar, the space would parse as layout, and will automatically be
> discarded when creating the AST.
>
> I will discuss this with the rest of the group and negotiate a warning
> message that disallows whitespace inside terminals.
>
> Radu
> K developer
>
>
> On Fri, Sep 6, 2013 at 11:31 PM, Ömer Sinan Ağacan
> <omeragacan AT gmail.com>
> wrote:
>>
>> Dear K users,
>>
>>
>> This simple K program demonstrates a feature that works in an older
>> version K framework but fails with latest version:
>>
>>
>> module TEST-SYNTAX
>>
>> syntax Lst ::= List{Test, " "}
>>
>> syntax Test ::= Id
>> | "[" Lst "]"
>>
>> endmodule
>>
>> module TEST
>>
>> imports TEST-SYNTAX
>>
>> endmodule
>>
>>
>> This compiles fine with both old and latest versions .. The problem is
>> it doesn't parse this simple program `[a b]` in latest version(fails
>> with "Critical: Parse error: Syntax error near unexpected character
>> 'b'")
>>
>> Anyone has ideas on this?
>>
>> Thanks.
>>
>>
>> ---
>> Ömer Sinan Ağacan
>> http://osa1.net
>>
>> _______________________________________________
>> k-user mailing list
>> k-user AT cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/k-user
>
>

_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user




Archive powered by MHonArc 2.6.16.

Top of Page