Skip to Content.
Sympa Menu

k-user - Re: [K-user] [syntax] Best practice for representing a list of somethings

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] [syntax] Best practice for representing a list of somethings


Chronological Thread 
  • From: Radu Mereuta <headness13 AT gmail.com>
  • To: "Park, Daejun" <dpark69 AT illinois.edu>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: Re: [K-user] [syntax] Best practice for representing a list of somethings
  • Date: Sat, 19 Oct 2013 13:28:51 +0300
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

There is also
syntax EPlus ::= NeList{E, ""} // standing for not empty list

Regarding the others, I'm not sure that we have a convention, I think with SDF all of them work correctly. Just don't forget to add the [left] or [right] attribute:
syntax EPlus ::= E | EPlus EPlus [left]

The difference between List{...} and '__ is that the first one creates a cons list with an empty element that signifies the end of the list. The second one, creates a cons list, but you are responsible of handling it in all cases (empty list, one element, more than one element).

Radu




On Fri, Oct 18, 2013 at 10:29 PM, Park, Daejun <dpark69 AT illinois.edu> wrote:
Hi,

This is my first question as a K user!

When it comes to represent the following syntax, what would be the best practice?
- e? : zero or one
- e* : more than or equal to zero
- e+ : more than zero

What I've been trying is:

syntax EOpt  ::= E | "" [onlyLabel, klabel("'epsilon")]  
syntax EStar ::= List{E, ""}
syntax EPlus ::= ??

Am I right? Or, is there more elegant way?

Also, if I should use either of the follows, which one will be better?

syntax EPlus ::= E | E     EPlus
syntax EPlus ::= E | EPlus EPlus

Thanks in advance!

Daejun

_______________________________________________
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