Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
822e6c4d
Commit
822e6c4d
authored
Apr 17, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validation not uses new 'clone' function.
parent
d86dda92
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
+15
-18
src/validation.py
src/validation.py
+15
-18
No files found.
src/validation.py
View file @
822e6c4d
from
src.parser
import
Parser
from
parser
import
Parser
from
possibilities
import
apply_suggestion
from
strategy
import
find_possibilities
from
tests.parser
import
ParserWrapper
from
tests.parser
import
ParserWrapper
from
src.possibilities
import
apply_suggestion
def
validate
(
exp
,
result
):
def
validate
(
exp
,
result
):
...
@@ -8,25 +9,21 @@ def validate(exp, result):
...
@@ -8,25 +9,21 @@ def validate(exp, result):
Validate that exp =>* result.
Validate that exp =>* result.
"""
"""
parser
=
ParserWrapper
(
Parser
)
parser
=
ParserWrapper
(
Parser
)
exp
=
parser
.
run
([
exp
])
result
=
parser
.
run
([
result
])
result
=
parser
.
run
([
result
])
return
traverse_preorder
(
parser
,
exp
,
result
)
def
traverse_preorder
(
node
,
result
):
if
node
.
equals
(
result
):
return
True
for
p
in
find_possibilities
(
node
):
# Clone the root node because it will be used in multiple
# substitutions
child
=
apply_suggestion
(
node
.
clone
(),
p
)
def
traverse_preorder
(
parser
,
exp
,
result
):
if
traverse_preorder
(
child
,
result
):
"""
return
True
Traverse the possibility tree using pre-order traversal.
"""
root
=
parser
.
run
([
exp
])
if
root
.
equals
(
result
):
return
root
possibilities
=
parser
.
parser
.
possibilities
for
p
in
possibilities
:
return
False
child
=
apply_suggestion
(
root
,
p
)
next_root
=
traverse_preorder
(
parser
,
str
(
child
),
result
)
if
next_root
:
return
traverse_preorder
(
exp
,
result
)
return
next_root
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment