Skip to Content.
Sympa Menu

k-user - Re: [[K-user] ] How to specify a new style of comments for a language?

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [[K-user] ] How to specify a new style of comments for a language?


Chronological Thread 
  • From: Christos Kloukinas <c.kloukinas AT gmail.com>
  • To: 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 14:33:59 +0300

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. Leavens
        437D Harris Center (Bldg. 116)
        Computer Science, University of Central Florida
        4000 Central Florida Blvd., Orlando, FL 32816-2362 USA
        http://www.cs.ucf.edu/~leavens  phone: +1-407-823-4758
        leavens AT cs.ucf.edu




Archive powered by MHonArc 2.6.19.

Top of Page