k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- From: Radu Mereuta <headness13 AT gmail.com>
- To: Christos Kloukinas <c.kloukinas AT gmail.com>
- Cc: k-user AT lists.cs.illinois.edu
- Subject: Re: [[K-user] ] How to specify a new style of comments for a language?
- Date: Wed, 21 Jun 2017 18:29:42 +0200
Hi Gary,
At the moment comments are hard coded in the C style.
In rules we combine the syntax of the language with the K syntax, and handling different styles of layout would considerably complicate rule parsing.
We couldn't find any quick solution so we kind of avoided this problem for now.
Radu Mereuta
On Wed, Jun 21, 2017 at 1:33 PM, Christos Kloukinas <c.kloukinas AT gmail.com> wrote:
Hi,
Checking file k-distribution/samples/bf/bf.k (K 4.0), I can see that it uses the following:
syntax Ignore ::= Token{~[\>\<\+\-\.\,\[\]\ \n\r\t]+}
[regex("[^\\>\\<\\+\\-\\.\\,\\[\\]\\ \n\r\t]+"), token, onlyLabel]
And then below eats up all such tokens:rule I:Ignore => .K
Best
On 21/06/2017 04:25, Gary Leavens wrote:
Hi,
In defining the syntax of a new language in K, how do I specify the comment convention for that language? For example, suppose I want comments to start with-- and continue to the end of the line, as in Haskell. It seems like something along the lines of
syntax Comment ::= Token{"--" ~[\n\r]*[\n\r]}
should work, but then how do I get the parser to ignore these Comment tokens?
Regards,
Gary T. Leavens437D Harris Center (Bldg. 116)Computer Science, University of Central Florida4000 Central Florida Blvd., Orlando, FL 32816-2362 USA
- [[K-user] ] How to specify a new style of comments for a language?, Gary Leavens, 06/20/2017
- Re: [[K-user] ] How to specify a new style of comments for a language?, Christos Kloukinas, 06/21/2017
- Re: [[K-user] ] How to specify a new style of comments for a language?, Radu Mereuta, 06/21/2017
- Re: [[K-user] ] How to specify a new style of comments for a language?, Christos Kloukinas, 06/21/2017
Archive powered by MHonArc 2.6.19.