Skip to Content.
Sympa Menu

k-user - [K-user] Fwd: How to escape underscores in syntax

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

[K-user] Fwd: How to escape underscores in syntax


Chronological Thread 
  • From: "Mereuta I. Radu Adrian" <radu.mereuta AT info.uaic.ro>
  • To: <ulrichk AT informatik.uni-bremen.de>, <k-user AT cs.uiuc.edu>
  • Subject: [K-user] Fwd: How to escape underscores in syntax
  • Date: Wed, 12 Sep 2012 11:22:45 +0300
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>
  • Organization: Faculty of Computer Science, Al. I. Cuza University, Iasi, Romania

Hi,

It seems that you are using an older version of the tool.
This was a bug that we fixed a few weeks ago.

To get the latest version go to https://fmse.info.uaic.ro/imgs/

Radu Mereuta
K-framework developer


-------- Original Message --------
Subject: Fwd: [K-user] How to escape underscores in syntax
Date: 2012-09-12 11:14
From: Andrei Arusoaie
<andrei.arusoaie AT gmail.com>
To: "Mereuta I. Radu Adrian"
<radu.mereuta AT info.uaic.ro>

---------- Forwarded message ----------
From: Ulrich Kühne
<ulrichk AT informatik.uni-bremen.de>
Date: 2012/9/12
Subject: [K-user] How to escape underscores in syntax
To:
k-user AT cs.uiuc.edu
Cc:
ulrichk AT informatik.uni-bremen.de


Hi,

I would like to parse a language which has keywords containing underscores
'_'. Unfortunately, since the '_' is a special symbol in K, there seems to
be no way of escaping it in the syntax rules and make it work as expected.
Here is a minimal example:

module FOO
syntax Foo ::= "foo_bar" Int
syntax KResult ::= Int
rule foo_bar X:Int => X
endmodule

What I get is an error message:

$> kompile foo
Some errors occurred..
sdf-load:error: parse error, '_' unexpected
--- input string [file: ./Program.sdf line: 11 col: 14]

I also tried things like "foo\_bar", but this doesn't work either. So an
(unpleasant) workaround would entail preprocessing the source code in order
to remove all underscores. There must be a better way, no?

Thanks in advance.
Ulrich

PS: A reference document would be great, listing all the builtins and
operations. It took me quite some time to figure out the "X in keys(Map)"
trick :-)
______________________________**_________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/**mailman/listinfo/k-user<http://lists.cs.uiuc.edu/mailman/listinfo/k-user>



--
Numai bine,
Andrei


---------- Forwarded message ----------
From: Ulrich Kühne <ulrichk AT informatik.uni-bremen.de>
Date: 2012/9/12
Subject: [K-user] How to escape underscores in syntax
To: k-user AT cs.uiuc.edu
Cc: ulrichk AT informatik.uni-bremen.de


Hi,

I would like to parse a language which has keywords containing underscores '_'. Unfortunately, since the '_' is a special symbol in K, there seems to be no way of escaping it in the syntax rules and make it work as expected. Here is a minimal example:

module FOO
  syntax Foo ::= "foo_bar" Int
  syntax KResult ::= Int
  rule foo_bar X:Int => X
endmodule

What I get is an error message:

$> kompile foo
Some errors occurred..
sdf-load:error: parse error, '_' unexpected
--- input string [file: ./Program.sdf line: 11 col: 14]

I also tried things like "foo\_bar", but this doesn't work either. So an (unpleasant) workaround would entail preprocessing the source code in order to remove all underscores. There must be a better way, no?

Thanks in advance.
Ulrich

PS: A reference document would be great, listing all the builtins and operations. It took me quite some time to figure out the "X in keys(Map)" trick :-)
_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user



--
Numai bine,
Andrei



  • [K-user] Fwd: How to escape underscores in syntax, Mereuta I. Radu Adrian, 09/12/2012

Archive powered by MHonArc 2.6.16.

Top of Page