Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Using the string "Type" as a syntax form causes an error #2381

Open
canndrew opened this issue Dec 6, 2017 · 5 comments
Open

Using the string "Type" as a syntax form causes an error #2381

canndrew opened this issue Dec 6, 2017 · 5 comments

Comments

@canndrew
Copy link

canndrew commented Dec 6, 2017

I've just done the first tutorial video and I tried to compile this:

module MALK
    syntax Expr ::= Id
                  | Expr Expr
                  | "(" Id ":" Expr ")" "->" Expr
                  | "(" Id ":" Expr ")" "=>" Expr
                  | "Type"
endmodule

The causes an error:

[Error] Critical: Parse error: Syntax error near unexpected character '('
	File: /tmp/tcloop/k/include/builtins/symbolic-k.k
	Location: (160,42,160,42)

However, if rename "Type" to something else...

module MALK
    syntax Expr ::= Id
                  | Expr Expr
                  | "(" Id ":" Expr ")" "->" Expr
                  | "(" Id ":" Expr ")" "=>" Expr
                  | "Zkmfsdfjk"
endmodule

this compiles fine.

@dwightguth
Copy link
Member

What version of K are you using? That include file looks obsolete to me.

@canndrew
Copy link
Author

canndrew commented Dec 6, 2017

Oh wow, I didn't notice you'd replied immediately. Thanks!

I'm using KVM 3.4 I believe. I just downloaded it off the website today.

@canndrew
Copy link
Author

canndrew commented Dec 6, 2017

kompile --version gives me:

K-framework version 3.4.
Git Revision: 08c9271
Build date: Tue Aug 26 13:56:56 PDT 2014

@canndrew
Copy link
Author

canndrew commented Dec 6, 2017

Similarly, I get compile errors if I define an operator called =>. Is there a way to stop the syntax of my language from conflicting with the syntax of the meta-language? (I'm only up to the third tutorial video but I'm trying to play around with the concepts as they're introduced and I'm running into this problem already.)

@radumereuta
Copy link
Member

=> is a reserved keyword for K. It is used in rules to specify rewriting rules.
K3.4 is quite old and had some issues regarding modularity but in K4 you can avoid these by splitting your syntax into different modules: 1. module for semantics, 2. module for program syntax 3. module for common syntax. The idea is to put all the productions that conflict with the builtin K stuff in the second module and keep the rest in the common module which you can include in both.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants