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
dee64a2f
Commit
dee64a2f
authored
8 years ago
by
Henning Glawe
Browse files
Options
Downloads
Patches
Plain Diff
improve comments
parent
d4f6f1ab
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
parser/parser-fplo/FploInputParser.py
+9
-2
9 additions, 2 deletions
parser/parser-fplo/FploInputParser.py
with
9 additions
and
2 deletions
parser/parser-fplo/FploInputParser.py
+
9
−
2
View file @
dee64a2f
...
@@ -94,23 +94,28 @@ class FploInputParser(object):
...
@@ -94,23 +94,28 @@ class FploInputParser(object):
def
state_root
(
self
,
line
,
pos_in_line
):
def
state_root
(
self
,
line
,
pos_in_line
):
"""
state: no open section, i.e. at the root of the namelist
"""
"""
state: no open section, i.e. at the root of the namelist
"""
# match identifier or keyword
m
=
cRE_kw_ident
.
match
(
line
,
pos_in_line
)
m
=
cRE_kw_ident
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BRIGHT_GREEN
)
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BRIGHT_GREEN
)
self
.
statement
.
append
(
m
.
group
(
1
))
self
.
statement
.
append
(
m
.
group
(
1
))
return
m
.
end
()
return
m
.
end
()
# match subscript of previous identifier
m
=
cRE_subscript
.
match
(
line
,
pos_in_line
)
m
=
cRE_subscript
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_GREEN
)
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_GREEN
)
return
m
.
end
()
return
m
.
end
()
# match literals
m
=
cRE_literal
.
match
(
line
,
pos_in_line
)
m
=
cRE_literal
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
annotate
(
m
.
group
(),
ANSI
.
BG_YELLOW
)
self
.
annotate
(
m
.
group
(),
ANSI
.
BG_YELLOW
)
return
m
.
end
()
return
m
.
end
()
# match operators
m
=
cRE_operator
.
match
(
line
,
pos_in_line
)
m
=
cRE_operator
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_YELLOW
)
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_YELLOW
)
return
m
.
end
()
return
m
.
end
()
# match block-open
m
=
cRE_opening_brace
.
match
(
line
,
pos_in_line
)
m
=
cRE_opening_brace
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BRIGHT_CYAN
)
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BRIGHT_CYAN
)
...
@@ -118,24 +123,26 @@ class FploInputParser(object):
...
@@ -118,24 +123,26 @@ class FploInputParser(object):
self
.
statement
.
append
([])
self
.
statement
.
append
([])
self
.
statement
=
self
.
statement
[
-
1
]
self
.
statement
=
self
.
statement
[
-
1
]
return
m
.
end
()
return
m
.
end
()
# match block-close
m
=
cRE_closing_brace
.
match
(
line
,
pos_in_line
)
m
=
cRE_closing_brace
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
statement
=
self
.
parent_stack
.
pop
()
self
.
statement
=
self
.
parent_stack
.
pop
()
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BRIGHT_CYAN
)
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BRIGHT_CYAN
)
return
m
.
end
()
return
m
.
end
()
# match statement-finishing semicolon
m
=
cRE_end_statement
.
match
(
line
,
pos_in_line
)
m
=
cRE_end_statement
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
statement
=
[]
self
.
statement
=
[]
self
.
parent_stack
[
-
1
].
append
(
self
.
statement
)
self
.
parent_stack
[
-
1
].
append
(
self
.
statement
)
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BRIGHT_YELLOW
)
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BRIGHT_YELLOW
)
return
m
.
end
()
return
m
.
end
()
#
but comments may appear here
#
match up-to-eol comments
m
=
cRE_comment
.
match
(
line
,
pos_in_line
)
m
=
cRE_comment
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BLUE
)
self
.
annotate
(
m
.
group
(),
ANSI
.
FG_BLUE
)
# self.onComment(m.group('comment'))
# self.onComment(m.group('comment'))
return
m
.
end
()
return
m
.
end
()
#
as well as whitespace-only lines
#
ignore remaining whitespace
m
=
cRE_trailing_whitespace
.
match
(
line
,
pos_in_line
)
m
=
cRE_trailing_whitespace
.
match
(
line
,
pos_in_line
)
if
m
is
not
None
:
if
m
is
not
None
:
self
.
annotate
(
m
.
group
(),
ANSI
.
BG_BLUE
)
self
.
annotate
(
m
.
group
(),
ANSI
.
BG_BLUE
)
...
...
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