FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-mvdxml/mvdxml_expression.py at master · opensourceBIM/python-mvdxml · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
opensourceBIM
/
python-mvdxml
Public
Notifications
You must be signed in to change notification settings
Fork
13
Star
32
Code
Issues
4
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-mvdxml
/
mvdxml_expression.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
46 lines (36 loc) · 1.41 KB
Breadcrumbs
python-mvdxml
/
mvdxml_expression.py
Copy path
File metadata and controls
46 lines (36 loc) · 1.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from
__future__
import
annotations
from
dataclasses
import
dataclass
import
pyparsing
as
pp
@
dataclass
(
frozen
=
True
)
class
node
:
a
:
str
|
None
b
:
str
|
None
c
:
str
@
classmethod
def
from_tokens
(
cls
,
args
:
pp
.
ParseResults
)
->
node
:
if
len
(
args
)
==
3
and
args
[
1
]
==
"="
:
return
cls
(
args
[
0
],
None
,
args
[
2
])
if
(
args
[
1
],
args
[
3
],
args
[
4
])
==
(
"["
,
"]"
,
"="
):
return
cls
(
args
[
0
],
args
[
2
],
args
[
5
])
return
cls
(
None
,
args
[
1
],
args
[
4
])
def
__repr__
(
self
):
return
"{%s[%s]=%s}"
%
(
self
.
a
,
self
.
b
,
self
.
c
)
word
=
pp
.
Word
(
pp
.
alphanums
+
"_"
+
" "
+
"/"
+
"#"
)
quoted
=
pp
.
Combine
(
"'"
+
word
+
"'"
)
bool_value
=
pp
.
CaselessLiteral
(
"TRUE"
)
|
pp
.
CaselessLiteral
(
"FALSE"
)
ref_val
=
word
+
"["
+
word
+
"]"
rhs
=
quoted
|
bool_value
|
ref_val
|
word
stmt
=
(
pp
.
Optional
(
word
)
+
pp
.
Optional
(
"["
+
word
+
"]"
)
+
"="
+
rhs
).
setParseAction
(
node
.
from_tokens
)
bool_op
=
pp
.
CaselessLiteral
(
"AND"
)
|
pp
.
CaselessLiteral
(
"OR"
)
grammar
=
stmt
+
pp
.
Optional
(
pp
.
OneOrMore
(
bool_op
+
stmt
))
def
parse
(
exprs
:
str
)
->
tuple
[
tuple
[
node
|
str
, ...], ...]:
parsed
:
list
[
tuple
[
node
|
str
, ...]]
=
[]
for
expression
in
exprs
.
split
(
";"
):
expression
=
""
.
join
(
character
for
character
in
expression
if
character
not
in
"
\r
\n
"
)
if
expression
:
parsed
.
append
(
tuple
(
grammar
.
parseString
(
expression
,
parseAll
=
True
)))
return
tuple
(
parsed
)
Back
|
FazBrowse Home
|
New Git URL