-
Notifications
You must be signed in to change notification settings - Fork 0
/
programme.grm
132 lines (113 loc) · 4.23 KB
/
programme.grm
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Used symbols
#
# + addition, concatenation
# - subtraction, unary-minus
# * multiplication, any-label-value
# / division
# % modulo
# ^ exponential
# ! not, rule-loop
# ¬ not, mark-absent
# [ graph-start
# ] graph-end
# | or, graph-separator
# & and
# : if/when-separator
# ; rule/proc-end
# " string-start, string-end
# # mark-start
# { choice-start
# } choice-end
# ( group-start
# ) group-end
# -> edge-arrow
# <-> edge-arrow
# => rule-application
# < less-than, variable-start
# <= less-than-equal
# > greater-than, variable-end
# >= greater-than-equal
# ^= starts-with
# $= ends-with
# ~= contains
#
# Unused symbols
#
# ~
# $
# @
# ?
# `
# '
# ::
# |=
# ?=
# <<
# >>
# :=
programme -> declaration* EOF
declaration -> rule_def
| proc_def
| rule_app
rule_def -> "rule" IDENTIFIER var_list?
graph_def "=>" graph_def
condition? addendum? ";"
var_list -> "<" (TYPE ":" IDENTIFIER ("," IDENTIFER)* ","?)* ">"
condition -> "where" expression
addendum -> "also" statement
graph_def -> "[" node_def? ("," node_def)* ","? (
"|" edge_def? ("," edge_def)* ","? )? "]"
node_def -> NODE_ID label?
edge_def -> NODE_ID "<"? "->" NODE_ID label?
label -> "(" value ( "," markset )? ","? ")"
| "(" ( markset )? ","? ")"
value -> literal_value
| IDENTIFIER # only in rule graphs
| expression # only in RHS graphs
markset -> mark ( "," mark )*
| "unmarked"
mark -> "#" IDENTIFER
| "¬" IDENTIFER
literal_value -> INTEGER_VALUE
| STRING_VALUE
| REAL_VALUE
| BOOLEAN_VALUE
proc_def -> "proc" IDENTIFER rule_app* ";"
rule_app -> "try" "(" rule_seq ")" # try
| "if" "(" rule_seq (":" rule_seq)? (":" rule_seq)? ")" # if
| "with" "(" rule_seq (":" rule_seq)? (":" rule_seq)? ")" # with
| "{" rule_seq ("," rule_seq)* "}" # choose
| "(" rule_seq ")" # sequence (for grouping)
| rule_app "!" # loop
| "noop" # noop
| "invalid" # invalid
| IDENTIFER # rule/proc
rule_seq -> rule_app+
expression -> func_call # builtin in/out/adj functions
| expression "^" expression
| expression "/" expression
| expression "*" expression
| expression "+" expression
| expression "-" expression
| expression "%" expression
| expression "=" expression
| expression "!=" expression
| expression "<" expression
| expression "<=" expression
| expression ">" expression
| expression ">=" expression
| expression "&" expression
| expression "and" expression
| expression "|" expression
| expression "or" expression
| expression "xor" expression
| expression "^=" expression
| expression "$=" expression
| expression "~=" expression
| "¬" expression
| "not" expression
| IDENTIFER
| literal_value
func_call -> IDENTIFER "(" func_args? ")"
func_args -> expression ( "," expression )*
statement -> func_call # builtin print/debug procedures