Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-fplo
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
parser-fplo
Commits
989b4716
Commit
989b4716
authored
8 years ago
by
Henning Glawe
Browse files
Options
Downloads
Patches
Plain Diff
import+setup json backend by default in FploInputParser
parent
e1240a9b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
parser/parser-fplo/FploInputParser.py
+44
-0
44 additions, 0 deletions
parser/parser-fplo/FploInputParser.py
with
44 additions
and
0 deletions
parser/parser-fplo/FploInputParser.py
+
44
−
0
View file @
989b4716
...
...
@@ -17,7 +17,10 @@ import sys
import
os
import
logging
import
json
import
FploCommon
as
FploC
from
nomadcore.match_highlighter
import
ANSI
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
from
nomadcore.caching_backend
import
CachingLevel
,
ActiveBackend
LOGGER
=
logging
.
getLogger
(
__name__
)
...
...
@@ -253,6 +256,16 @@ class AST_node(dict):
if
isinstance
(
child
,
AST_node
):
child
.
declaration_nomadmetainfo
(
output_file
,
child_namespace
)
def
data_nomadmetainfo
(
self
,
backend
,
namespace
):
if
self
.
name
is
not
None
:
child_namespace
=
namespace
+
'
.
'
+
self
.
name
else
:
child_namespace
=
namespace
for
child
in
self
.
child
:
if
isinstance
(
child
,
AST_node
):
child
.
data_nomadmetainfo
(
backend
,
child_namespace
)
class
AST_block
(
AST_node
):
"""
generic block (sequence of statements) in AST
"""
...
...
@@ -284,6 +297,11 @@ class AST_root(AST_block):
'
}
\n
'
)
def
data_nomadmetainfo
(
self
,
backend
,
namespace
):
gIndex
=
backend
.
openSection
(
namespace
)
AST_node
.
data_nomadmetainfo
(
self
,
backend
,
namespace
)
backend
.
closeSection
(
namespace
,
gIndex
)
class
AST_section
(
AST_block
):
"""
section block (sequence of statements) in AST
"""
...
...
@@ -769,6 +787,13 @@ if __name__ == "__main__":
help
=
'
write nomadmetainfo to stdout
'
)
ARGPARSER
.
add_argument
(
'
fplo_input
'
,
type
=
str
,
nargs
=
'
+
'
,
help
=
'
FPLO input files
'
)
ARGS
=
ARGPARSER
.
parse_args
()
cachingLevelForMetaName
=
{}
for
name
in
FploC
.
META_INFO
.
infoKinds
:
# set all temporaries to caching-only
if
name
.
startswith
(
'
x_fplo_t_
'
):
cachingLevelForMetaName
[
name
]
=
CachingLevel
.
Cache
if
ARGS
.
annotate
:
ANNOTATEFILE
=
sys
.
stderr
else
:
...
...
@@ -790,3 +815,22 @@ if __name__ == "__main__":
sys
.
stderr
.
flush
()
if
ARGS
.
autogenerate_metainfo
:
parser
.
AST
.
declaration_nomadmetainfo
(
sys
.
stdout
,
'
x_fplo_in
'
)
else
:
outF
=
sys
.
stdout
jsonBackend
=
JsonParseEventsWriterBackend
(
FploC
.
META_INFO
,
outF
)
sys
.
stderr
.
write
(
'
WTF2:
'
+
str
(
FploC
.
META_INFO
)
+
'
\n
'
)
backend
=
ActiveBackend
.
activeBackend
(
metaInfoEnv
=
FploC
.
META_INFO
,
cachingLevelForMetaName
=
cachingLevelForMetaName
,
defaultDataCachingLevel
=
CachingLevel
.
ForwardAndCache
,
defaultSectionCachingLevel
=
CachingLevel
.
Forward
,
superBackend
=
jsonBackend
)
outF
.
write
(
"
[
"
)
backend
.
startedParsingSession
(
'
file://
'
+
fplo_in
,
FploC
.
PARSER_INFO_DEFAULT
)
run_gIndex
=
backend
.
openSection
(
'
section_run
'
)
method_gIndex
=
backend
.
openSection
(
'
section_method
'
)
parser
.
AST
.
data_nomadmetainfo
(
backend
,
'
x_fplo_in
'
)
backend
.
closeSection
(
'
section_method
'
,
method_gIndex
)
backend
.
closeSection
(
'
section_run
'
,
run_gIndex
)
backend
.
finishedParsingSession
(
"
ParseSuccess
"
,
None
)
outF
.
write
(
"
]
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment