Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Macao Legacy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MACAO
Macao Legacy
Commits
a35298dc
Commit
a35298dc
authored
Jun 11, 2024
by
Eliott Sammier
Browse files
Options
Downloads
Patches
Plain Diff
Fix MatchParser matching extra unnecessary constructors
parent
562e192d
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
tetras_extraction/macao_12/script/extract_page.py
+8
-2
8 additions, 2 deletions
tetras_extraction/macao_12/script/extract_page.py
with
8 additions
and
2 deletions
tetras_extraction/macao_12/script/extract_page.py
+
8
−
2
View file @
a35298dc
...
...
@@ -326,7 +326,7 @@ class MatchParser(JSParser):
"""
A parser for the JS portion of an activity, that uses Python match statements
to navigate the abstract syntax tree (AST) produced by Esprima
"""
activity
:
Activity
activity
:
Optional
[
Activity
]
=
None
def
__init__
(
self
,
graph
:
Graph
,
act_id
:
str
)
->
None
:
self
.
graph
=
graph
...
...
@@ -338,9 +338,15 @@ class MatchParser(JSParser):
# Try to match our template with one of the top-level statements
for
statement
in
jstree
.
body
:
self
.
match_function
(
statement
.
toDict
())
if
self
.
activity
is
not
None
:
return
self
.
activity
else
:
raise
ParseError
(
"
No activity constructor found
"
)
def
match_constructor_call
(
self
,
new_expr
:
dict
):
if
self
.
activity
is
not
None
:
# Ignore anything after the first match
return
match
new_expr
:
case
{
"
type
"
:
"
NewExpression
"
,
...
...
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