/
smpl_grammar.txt
68 lines (43 loc) · 2.39 KB
/
smpl_grammar.txt
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
TODO: markdownify this file
First milestone SmPL grammar:
Adapted from http://coccinelle.lip6.fr/docs/main_grammar.pdf
Note: This grammar is incomplete as it does not cover dot modifiers <...> and <+...+>,
pattern disjunction (p | ... | p) and conjunction (p && ... && p)
These constructs are to be part of the first milestone but could not be
trivially lifted from the official grammar PDF as they are buried in the
C-specific parts of that grammar.
program ::= include_cocci* changeset+
include_cocci ::= #include string
| using string patch-local isomorphism definitions?
| using pathToIsoFile
// | virtual id (,id)*
changeset ::= metavariables transformation
// | script_metavariables script_code
metavariables ::= @@ metadecl* @@ | @ rulename @ metadecl* @@
// rulename ::= id [extends id] [depends on] [scope] dep [iso] [disable-iso] [exists] [rulekind]
rulename ::= id
metadecl ::= identifier ids ;
| type ids ;
| expression [list] ids ;
| statement [list] ids ;
| constant ids ;
| JavaType ids ;
// too much removed to include here
ids ::= pmid (, pmid)*
pmid ::= id | mid
mid ::= rulename_id.id
transformation ::= OPTDOTSEQ(top, when)
top ::= java_expr | java_decl_stmt+ | java_fundecl this is where the java lives
when ::= when != when_code
// | when any lifting shortest path restriction
// | when strict applicable to error states (how are these determined?)
| when exists not all paths need to match
| when forall all paths must match the complete rule
// | when true != expr
// | when false != expr
OPTDOTSEQ(grammar, when) = [... (when)*] grammar (... (when)* grammar)* [... (when)*]
Notable omissions in first milestone:
dots in method calls: foo(...)
"when any" lifting of shortest-path restriction for dots
"fresh identifier" metavariables for code generation
constraints/regexes on metavariable ids