Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
a99edd7b
Commit
a99edd7b
authored
14 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
"all" positions handling in wcclparser
parent
a7d583e0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wcclparser/main.cpp
+28
-11
28 additions, 11 deletions
wcclparser/main.cpp
with
28 additions
and
11 deletions
wcclparser/main.cpp
+
28
−
11
View file @
a99edd7b
#include
<cstdlib>
#include
<fstream>
#include
<iomanip>
#include
<libwccl/values/strset.h>
#include
<libwccl/parser/Parser.h>
...
...
@@ -88,7 +90,8 @@ void libedit_read_loop(boost::function<bool (const std::string&)>& line_cb)
}
#endif
bool
process_line
(
const
std
::
string
&
line
,
Parser
&
parser
,
Wccl
::
SentenceContext
&
sc
)
bool
process_line
(
const
std
::
string
&
line
,
Parser
&
parser
,
Wccl
::
SentenceContext
&
sc
,
bool
all_positions
)
{
if
(
line
.
empty
()
||
line
==
"exit"
||
line
==
"quit"
)
{
return
true
;
...
...
@@ -102,15 +105,28 @@ bool process_line(const std::string& line, Parser& parser, Wccl::SentenceContext
try
{
retOp
=
parser
.
parseAnyOperator
(
line
);
if
(
retOp
)
{
Wccl
::
FunExecContext
cx
(
sc
,
retOp
->
variables
);
retVal
=
retOp
->
get_op_base
()
->
apply_internal
(
cx
);
if
(
retVal
)
{
std
::
cerr
<<
"Parsed expression: "
<<
retVal
->
to_string
(
parser
.
tagset
())
<<
std
::
endl
;
int
pb
,
pe
;
if
(
all_positions
)
{
pb
=
0
;
pe
=
sc
.
get_sentence
().
empty
()
?
1
:
sc
.
size
();
}
else
{
std
::
cerr
<<
"Problem while parsing -- "
<<
"retVal is NULL!"
<<
std
::
endl
;
pb
=
sc
.
get_position
();
pe
=
sc
.
get_position
()
+
1
;
}
for
(
int
i
=
pb
;
i
<
pe
;
++
i
)
{
sc
.
set_position
(
i
);
Wccl
::
FunExecContext
cx
(
sc
,
boost
::
shared_ptr
<
Wccl
::
Variables
>
(
retOp
->
variables
->
clone
()));
retVal
=
retOp
->
get_op_base
()
->
apply_internal
(
cx
);
if
(
retVal
)
{
std
::
cerr
<<
"["
<<
std
::
setw
(
2
)
<<
sc
.
get_position
()
<<
"] "
<<
"Parsed expression: "
<<
retVal
->
to_string
(
parser
.
tagset
())
<<
std
::
endl
;
}
else
{
std
::
cerr
<<
"Problem while parsing -- "
<<
"retVal is NULL!"
<<
std
::
endl
;
}
}
}
else
{
std
::
cerr
<<
"Problem while parsing -- "
...
...
@@ -195,11 +211,12 @@ int main(int argc, char** argv)
sc
.
set_position
(
pos
);
Parser
parser
(
tagset
);
if
(
!
query
.
empty
())
{
process_line
(
query
,
parser
,
sc
);
process_line
(
query
,
parser
,
sc
,
position
==
"all"
);
return
0
;
}
boost
::
function
<
bool
(
const
std
::
string
&
)
>
f
;
f
=
boost
::
bind
(
&
process_line
,
_1
,
boost
::
ref
(
parser
),
boost
::
ref
(
sc
));
f
=
boost
::
bind
(
&
process_line
,
_1
,
boost
::
ref
(
parser
),
boost
::
ref
(
sc
),
position
==
"all"
);
#ifdef HAVE_LIBEDIT
libedit_read_loop
(
f
);
#else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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