-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatalog.g4
More file actions
41 lines (28 loc) · 711 Bytes
/
Datalog.g4
File metadata and controls
41 lines (28 loc) · 711 Bytes
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
grammar Datalog;
datalogMain : mRule* EOF;
term
: value=Constant # Const
| name=Identifier # Variable
;
atom : name=Identifier ('(' terms=termList? ')')? ;
termList
: term (',' term)* ;
mRule : head=atom (':-' body=literals)? '.' ;
literal
: atom # LiteralAtom
| '!' atom # LiteralNegAtom
;
literals : literal (',' literal)* ;
Identifier : ID_START ID_REST* ;
fragment ID_START : [a-zA-Z_] ;
fragment ID_REST : [a-zA-Z0-9_?] ;
Constant
: '"' DoubleQuotedStringCharacter* '"'
| '\'' SingleQuotedStringCharacter* '\'' ;
fragment
DoubleQuotedStringCharacter
: ~["\r\n\\] | ('\\' .) ;
fragment
SingleQuotedStringCharacter
: ~['\r\n\\] | ('\\' .) ;
WS : [ \t\r\n]+ -> skip ;