Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
macaon
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
Franck Dary
macaon
Commits
0514221a
Commit
0514221a
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added more detailed error messages and fixed invalid read in assert actions
parent
078e0446
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
reading_machine/src/Action.cpp
+24
-4
24 additions, 4 deletions
reading_machine/src/Action.cpp
reading_machine/src/Transition.cpp
+15
-6
15 additions, 6 deletions
reading_machine/src/Transition.cpp
with
39 additions
and
10 deletions
reading_machine/src/Action.cpp
+
24
−
4
View file @
0514221a
...
...
@@ -384,8 +384,18 @@ Action Action::assertIsEmpty(const std::string & colName, Config::Object object,
auto
appliable
=
[
colName
,
object
,
relativeIndex
](
const
Config
&
config
,
const
Action
&
)
{
auto
lineIndex
=
config
.
getRelativeWordIndex
(
object
,
relativeIndex
);
return
util
::
isEmpty
(
config
.
getAsFeature
(
colName
,
lineIndex
));
try
{
if
(
!
config
.
hasRelativeWordIndex
(
object
,
relativeIndex
))
return
false
;
auto
lineIndex
=
config
.
getRelativeWordIndex
(
object
,
relativeIndex
);
return
util
::
isEmpty
(
config
.
getAsFeature
(
colName
,
lineIndex
));
}
catch
(
std
::
exception
&
e
)
{
util
::
myThrow
(
fmt
::
format
(
"colName='{}' object='{}' relativeIndex='{}' {}"
,
colName
,
object
==
Config
::
Object
::
Stack
?
"Stack"
:
"Buffer"
,
relativeIndex
,
e
.
what
()));
}
return
false
;
};
return
{
Type
::
Check
,
apply
,
undo
,
appliable
};
...
...
@@ -403,8 +413,18 @@ Action Action::assertIsNotEmpty(const std::string & colName, Config::Object obje
auto
appliable
=
[
colName
,
object
,
relativeIndex
](
const
Config
&
config
,
const
Action
&
)
{
auto
lineIndex
=
config
.
getRelativeWordIndex
(
object
,
relativeIndex
);
return
!
util
::
isEmpty
(
config
.
getAsFeature
(
colName
,
lineIndex
));
try
{
if
(
!
config
.
hasRelativeWordIndex
(
object
,
relativeIndex
))
return
false
;
auto
lineIndex
=
config
.
getRelativeWordIndex
(
object
,
relativeIndex
);
return
!
util
::
isEmpty
(
config
.
getAsFeature
(
colName
,
lineIndex
));
}
catch
(
std
::
exception
&
e
)
{
util
::
myThrow
(
fmt
::
format
(
"colName='{}' object='{}' relativeIndex='{}' {}"
,
colName
,
object
==
Config
::
Object
::
Stack
?
"Stack"
:
"Buffer"
,
relativeIndex
,
e
.
what
()));
}
return
false
;
};
return
{
Type
::
Check
,
apply
,
undo
,
appliable
};
...
...
This diff is collapsed.
Click to expand it.
reading_machine/src/Transition.cpp
+
15
−
6
View file @
0514221a
...
...
@@ -81,19 +81,28 @@ void Transition::apply(Config & config)
bool
Transition
::
appliable
(
const
Config
&
config
)
const
{
if
(
!
state
.
empty
()
&&
state
!=
config
.
getState
())
return
false
;
for
(
const
Action
&
action
:
sequence
)
if
(
!
action
.
appliable
(
config
,
action
))
try
{
if
(
!
state
.
empty
()
&&
state
!=
config
.
getState
())
return
false
;
for
(
const
Action
&
action
:
sequence
)
if
(
!
action
.
appliable
(
config
,
action
))
return
false
;
}
catch
(
std
::
exception
&
e
)
{
util
::
myThrow
(
fmt
::
format
(
"transition '{}' {}"
,
name
,
e
.
what
()));
}
return
true
;
}
int
Transition
::
getCost
(
const
Config
&
config
)
const
{
return
cost
(
config
);
try
{
return
cost
(
config
);}
catch
(
std
::
exception
&
e
)
{
util
::
myThrow
(
fmt
::
format
(
"transition '{}' {}"
,
name
,
e
.
what
()));}
return
0
;
}
const
std
::
string
&
Transition
::
getName
()
const
...
...
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