Created
October 21, 2019 17:01
-
-
Save eric-corumdigital/31fadb0fb4078f763096879e8c81fe9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SIMPLE-SYNTAX | |
endmodule | |
module SIMPLE | |
imports BOOL | |
imports INT | |
syntax Bitfield ::= Bitfield Bit | |
| Bit | |
syntax Bit ::= "l" | "h" | |
syntax IntExp ::= "bToI" "(" Bit ")" | |
| "bfToI" "(" Bitfield ")" | |
| "expToI" "(" IntExp "*" IntExp ")" | |
| "expToI" "(" IntExp "+" IntExp ")" | |
| "expToI" "(" Int ")" | |
rule bToI(l:Bit) => 0 | |
rule bToI(h:Bit) => 1 | |
rule bfToI(XS:Bitfield X:Bit) => expToI(expToI(bfToI(XS) * expToI(2)) + bToI(X)) | |
rule bfToI(X:Bit) => bToI(X) | |
rule expToI(A:IntExp * B:IntExp) => expToI(A) *Int expToI(B) | |
rule expToI(A:IntExp + B:IntExp) => expToI(A) +Int expToI(B) | |
rule expToI(A:Int) => A | |
endmodule | |
---------------------------------- | |
# kompile --backend haskell simple.k | |
[WARNING] Running as root is not recommended | |
[Error] Compiler: Had 2 parsing errors. | |
[Error] Inner Parser: Parse error: unexpected token '*Int'. | |
Source(/mnt/c/Users/Bryan/Documents/kframework/frist/./simple.k) | |
Location(27,49,27,53) | |
[Error] Inner Parser: Parse error: unexpected token '+Int'. | |
Source(/mnt/c/Users/Bryan/Documents/kframework/frist/./simple.k) | |
Location(28,49,28,53) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment