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
f6af1524
Commit
f6af1524
authored
14 years ago
by
ilor
Browse files
Options
Downloads
Patches
Plain Diff
add parsing of position operators
parent
773fffa0
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libwccl/parser/Parser.cpp
+42
-0
42 additions, 0 deletions
libwccl/parser/Parser.cpp
libwccl/parser/Parser.h
+7
-0
7 additions, 0 deletions
libwccl/parser/Parser.h
libwccl/parser/grammar.g
+16
-1
16 additions, 1 deletion
libwccl/parser/grammar.g
with
65 additions
and
1 deletion
libwccl/parser/Parser.cpp
+
42
−
0
View file @
f6af1524
...
...
@@ -108,6 +108,36 @@ boost::shared_ptr<ANTLRParserResult<Wccl::TSet> > Parser::parseSymSetOperator(
return
parser
.
parse_sym_set_operator
(
tagset_
);
}
// ----------------------------------------------------------------------------
/**
* @desc Parse a position operator contained in a std::string. Converts the
* string to a stream and calls parseSymSetOperator with it
* @arg str operator string
* @return the parsed operator via a shared pointer
*/
boost
::
shared_ptr
<
ANTLRParserResult
<
Wccl
::
Position
>
>
Parser
::
parsePositionOperator
(
const
std
::
string
&
str
)
const
{
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
ss
<<
str
;
return
this
->
parsePositionOperator
(
ss
);
}
/**
* @desc Parse a position operator. Runs parse_sym_set_operator rule
* in the parser grammar.
* @arg istr input stream with the operator
* @return the parsed operator via a shared pointer
*/
boost
::
shared_ptr
<
ANTLRParserResult
<
Wccl
::
Position
>
>
Parser
::
parsePositionOperator
(
std
::
istream
&
istr
)
const
{
ANTLRLexer
lexer
(
istr
);
ANTLRParser
parser
(
lexer
);
return
parser
.
parse_position_operator
(
tagset_
);
}
// ----------------------------------------------------------------------------
/**
* @desc Parse any operator contained in a std::string. Converts the string to
...
...
@@ -174,6 +204,18 @@ boost::shared_ptr<ANTLRParserResultBase> Parser::parseAnyOperator(
// ignore, try another type
}
}
if
(
!
result
)
{
ss
.
clear
();
ss
.
seekg
(
0
,
std
::
ios
::
beg
);
ANTLRLexer
lexer
(
ss
);
ANTLRParser
parser
(
lexer
);
try
{
result
=
parser
.
parse_position_operator
(
tagset_
);
}
catch
(
antlr
::
ANTLRException
&
e
)
{
errors
<<
"(as position) "
<<
e
.
getMessage
()
<<
"
\n
"
;
// ignore, try another type
}
}
if
(
!
result
)
{
throw
ParserException
(
errors
.
str
());
}
...
...
This diff is collapsed.
Click to expand it.
libwccl/parser/Parser.h
+
7
−
0
View file @
f6af1524
...
...
@@ -45,6 +45,13 @@ public:
boost
::
shared_ptr
<
ANTLRParserResult
<
Wccl
::
TSet
>
>
parseSymSetOperator
(
std
::
istream
&
)
const
;
// ---------------------------------------------------------------------------
// methods for parsing position operators
boost
::
shared_ptr
<
ANTLRParserResult
<
Wccl
::
Position
>
>
parsePositionOperator
(
const
std
::
string
&
)
const
;
boost
::
shared_ptr
<
ANTLRParserResult
<
Wccl
::
Position
>
>
parsePositionOperator
(
std
::
istream
&
)
const
;
// ---------------------------------------------------------------------------
// methods for parsing any operators
boost
::
shared_ptr
<
ANTLRParserResultBase
>
...
...
This diff is collapsed.
Click to expand it.
libwccl/parser/grammar.g
+
16
−
1
View file @
f6af1524
...
...
@@ -147,6 +147,21 @@ parse_sym_set_operator
}
;
// ----------------------------------------------------------------------------
// Rules for parsing position operators
// Returns boost::shared_ptr<Wccl::Function<Wccl::Position> >
parse_position_operator
[const Corpus2::Tagset &tagset]
returns [boost::shared_ptr<ANTLRParserResult<Wccl::Position> > res]
{
res.reset(new ANTLRParserResult<Wccl::Position>());
boost::shared_ptr<Wccl::Function<Wccl::Position> > op;
}
: op = position_operators [tagset, *res->variables.get()] {
res->op = op;
}
;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// VALUES
...
...
@@ -265,7 +280,7 @@ position_literal
val.reset(new Wccl::Position(Wccl::Position(Wccl::Position::Nowhere)));
}
;
// Constat position value
// Consta
n
t position value
// Returns boost::shared_ptr<Wccl::Constant<Wccl::Position> >
position_value
returns [boost::shared_ptr<Wccl::Constant<Wccl::Position> > val]
...
...
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