forked from kframework/c-semantics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
annotation.k
26 lines (20 loc) · 953 Bytes
/
annotation.k
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module C-ANNOTATION-SYNTAX
imports C-SYNTAX
syntax KItem ::= generateRuleAnnotation(CId)
syntax String ::= #generateRuleAnnotation(CId, K) [function, hook(C_SEMANTICS.generateRuleAnnotation), impure]
syntax KItem ::= writeAnnotation(String)
endmodule
module C-ANNOTATION
imports C-ANNOTATION-SYNTAX
imports C-CONFIGURATION
imports C-ABSTRACT-SYNTAX
rule <k> (PragmaKccRule(S:String) => .K) ~> CodeLoc(FunctionDefinition(_, _), _) ...</k>
<annotation> _ => S </annotation>
rule <k> generateRuleAnnotation(X:CId) => writeAnnotation(#generateRuleAnnotation(X, S)) ...</k>
<annotation> S:String => "" </annotation>
requires S =/=K ""
rule <k> generateRuleAnnotation(_) => .K ...</k>
<annotation> "" </annotation>
rule <k> writeAnnotation(S:String) => .K ...</k>
<generated-annotations>... .List => ListItem(S) </generated-annotations>
endmodule