-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCasbin.bnf
124 lines (108 loc) · 4.14 KB
/
Casbin.bnf
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
{
parserClass="io.github.will7200.plugins.casbin.language.parser.CasbinParser"
parserUtilClass = "io.github.will7200.plugins.casbin.language.parser.CasbinParserUtil"
extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
psiClassPrefix="Casbin"
psiImplClassSuffix="Impl"
psiPackage="io.github.will7200.plugins.casbin.language.psi"
psiImplPackage="io.github.will7200.plugins.casbin.language.psi.impl"
elementTypeHolderClass="io.github.will7200.plugins.casbin.language.psi.CasbinElementTypes"
elementTypeClass="io.github.will7200.plugins.casbin.language.psi.CasbinElementType"
tokenTypeClass="io.github.will7200.plugins.casbin.language.psi.CasbinTokenType"
extends(".*Expr")=Expr
tokens = [
DOT = "."
L_BRACKET = "["
R_BRACKET = "]"
OPEN_QUOTES = "\""
CLOSE_QUOTES = "\""
OPEN_SINGLE_QUOTES = "'"
CLOSE_SINGLE_QUOTES = "'"
ASSIGN = "="
COMMA = ","
OP_AND = "&&"
OP_OR = "||"
OP_EQUALS = "=="
OP_NOT = "!"
ALLOW = "allow"
DENY = "deny"
LINE_COMMENT='regexp:[#;].*'
SECTION_IDENTIFER='regexp:[A-Za-z_]+'
IDENTIFIER='regexp:[A-Za-z]?[A-Za-z_0-9]+'
STRING
STRING_SINGLE_QUOTE
SPACE = "regexp:\s+"
L_PARATHESIS = "("
R_PARATHESIS = ")"
]
psiImplUtilClass = "io.github.will7200.plugins.casbin.language.psi.CasbinPsiUtils"
}
casbinModel ::= section*
section ::= header property* {
mixin="io.github.will7200.plugins.casbin.language.psi.impl.CasbinSectionMixin"
methods=[getProperties hasProperty setProperty getProperty getName setName getPresentation]
}
header ::= L_BRACKET section_name R_BRACKET {
pin=1
recoverWhile=not_next_entry
}
section_name ::= SECTION_IDENTIFER
// Property
property ::= key ASSIGN value {
pin=2
recoverWhile=not_next_entry
mixin="io.github.will7200.plugins.casbin.language.psi.impl.CasbinPropertyMixin"
methods=[getName getKey getValue getPresentation]
}
private key ::= flat_key
private value ::= option_values
// ---- ---- Key ---- ----
flat_key ::= IDENTIFIER
// ---- ---- Value ---- ----
option_values ::= (value_tuple | value_expression | value_identifier)
value_expression ::= Expr
value_tuple ::= attribute_definition (COMMA attribute_definition)+
value_identifier ::= IDENTIFIER
// ---- ---- Expressions ---- ----
function ::= [OP_NOT] function_name L_PARATHESIS function_signature R_PARATHESIS {
mixin="io.github.will7200.plugins.casbin.language.psi.impl.CasbinFunctionMixin"
methods=[getName]
}
function_signature ::= (function | equality | parameters)
parameters ::= ((some_value (COMMA some_value)+) | some_value)
equality ::= some_value (OP_EQUALS | OP_IN) some_value
some_value ::= (object | ALLOW | DENY | strings | tuple)
tuple ::= L_PARATHESIS ((strings (COMMA strings)+) | strings) R_PARATHESIS
object ::= object_identifier DOT attribute (DOT sub_attribute)* {
mixin="io.github.will7200.plugins.casbin.language.psi.impl.CasbinObjectMixin"
methods=[getName]
}
// ---- ---- (Expressions) Condition ---- ----
Expr ::= relationalExpr | primaryGroup
relationalExpr ::= Expr relOp Expr
parenExpr ::= parenConstruct
literalExpr ::= (equality | function | some_value)
private primaryGroup ::= literalExpr | parenExpr
private relOp ::= OP_AND | OP_OR
private parenConstruct ::= '(' [ !')' Expr (',' Expr) * ] ')'
// ---- ---- Low Level Identifiers ---- ----
strings ::= string_double_quotes | string_single_quotes
string_single_quotes::= OPEN_SINGLE_QUOTES STRING_SINGLE_QUOTE CLOSE_SINGLE_QUOTES
string_double_quotes ::= OPEN_QUOTES STRING CLOSE_QUOTES
object_identifier ::= IDENTIFIER
function_name ::= IDENTIFIER
attribute ::= (IDENTIFIER | "_"){
mixin="io.github.will7200.plugins.casbin.language.psi.impl.CasbinAttributeMixin"
methods=[getName]
}
attribute_definition ::= IDENTIFIER | "_"{
mixin="io.github.will7200.plugins.casbin.language.psi.impl.CasbinAttributeDefinitionMixin"
methods=[getName]
}
sub_attribute ::= (IDENTIFIER | "_"){
mixin="io.github.will7200.plugins.casbin.language.psi.impl.CasbinSubAttributeMixin"
methods=[getName]
}
// ---- ---- Recovery ---- ----
private not_header ::= !header
private not_next_entry ::= !(header | value)