Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
WCCL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Analysers
WCCL
Commits
608d1666
Commit
608d1666
authored
Feb 22, 2011
by
Paweł Kędzia
Browse files
Options
Downloads
Patches
Plain Diff
The parser throws ParserException (ParserException inherits from WcclError)
parent
4569eb22
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
libwccl/parser/Parser.cpp
+160
-12
160 additions, 12 deletions
libwccl/parser/Parser.cpp
libwccl/parser/ParserException.h
+6
-5
6 additions, 5 deletions
libwccl/parser/ParserException.h
with
166 additions
and
17 deletions
libwccl/parser/Parser.cpp
+
160
−
12
View file @
608d1666
...
@@ -36,8 +36,13 @@ boost::shared_ptr<Operator<StrSet> > Parser::parseStringOperator(
...
@@ -36,8 +36,13 @@ boost::shared_ptr<Operator<StrSet> > Parser::parseStringOperator(
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
ss
<<
str
;
ss
<<
str
;
try
{
return
this
->
parseStringOperator
(
ss
);
return
this
->
parseStringOperator
(
ss
);
}
}
catch
(
ParserException
&
)
{
throw
;
}
}
/**
/**
* @desc Parse a string operator. Runs parse_string_operator rule
* @desc Parse a string operator. Runs parse_string_operator rule
...
@@ -50,8 +55,27 @@ boost::shared_ptr<Operator<StrSet> > Parser::parseStringOperator(
...
@@ -50,8 +55,27 @@ boost::shared_ptr<Operator<StrSet> > Parser::parseStringOperator(
{
{
ANTLRLexer
lexer
(
istr
);
ANTLRLexer
lexer
(
istr
);
ANTLRParser
parser
(
lexer
);
ANTLRParser
parser
(
lexer
);
boost
::
shared_ptr
<
Operator
<
StrSet
>
>
res
;
try
{
res
=
parser
.
parse_strset_operator
(
tagset_
);
}
catch
(
antlr
::
MismatchedTokenException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
NoViableAltException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
TokenStreamRecognitionException
&
e
)
{
throw
ParserException
(
e
.
getLine
()
+
":"
+
e
.
getColumn
()
+
std
::
string
(
" "
)
+
e
.
getMessage
()
);
}
catch
(
antlr
::
ANTLRException
&
e
)
{
throw
ParserException
(
e
.
getMessage
());
}
return
parser
.
parse_strset_operator
(
tagset_
)
;
return
res
;
}
}
/**
/**
...
@@ -66,8 +90,13 @@ boost::shared_ptr<Operator<Bool> > Parser::parseBoolOperator(
...
@@ -66,8 +90,13 @@ boost::shared_ptr<Operator<Bool> > Parser::parseBoolOperator(
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
ss
<<
str
;
ss
<<
str
;
try
{
return
this
->
parseBoolOperator
(
ss
);
return
this
->
parseBoolOperator
(
ss
);
}
}
catch
(
ParserException
&
)
{
throw
;
}
}
/**
/**
* @desc Parse a predicate. Runs parse_predicates rule in the parser grammar.
* @desc Parse a predicate. Runs parse_predicates rule in the parser grammar.
...
@@ -79,8 +108,27 @@ boost::shared_ptr<Operator<Bool> > Parser::parseBoolOperator(
...
@@ -79,8 +108,27 @@ boost::shared_ptr<Operator<Bool> > Parser::parseBoolOperator(
{
{
ANTLRLexer
lexer
(
istr
);
ANTLRLexer
lexer
(
istr
);
ANTLRParser
parser
(
lexer
);
ANTLRParser
parser
(
lexer
);
boost
::
shared_ptr
<
Operator
<
Bool
>
>
res
;
try
{
res
=
parser
.
parse_bool_operator
(
tagset_
);
}
catch
(
antlr
::
MismatchedTokenException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
NoViableAltException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
TokenStreamRecognitionException
&
e
)
{
throw
ParserException
(
e
.
getLine
()
+
":"
+
e
.
getColumn
()
+
std
::
string
(
" "
)
+
e
.
getMessage
()
);
}
catch
(
antlr
::
ANTLRException
&
e
)
{
throw
ParserException
(
e
.
getMessage
());
}
return
parser
.
parse_bool_operator
(
tagset_
)
;
return
res
;
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
@@ -96,8 +144,13 @@ boost::shared_ptr<Operator<TSet> > Parser::parseSymSetOperator(
...
@@ -96,8 +144,13 @@ boost::shared_ptr<Operator<TSet> > Parser::parseSymSetOperator(
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
ss
<<
str
;
ss
<<
str
;
try
{
return
this
->
parseSymSetOperator
(
ss
);
return
this
->
parseSymSetOperator
(
ss
);
}
}
catch
(
ParserException
&
)
{
throw
;
}
}
/**
/**
* @desc Parse a sym set operator. Runs parse_sym_set_operator rule
* @desc Parse a sym set operator. Runs parse_sym_set_operator rule
...
@@ -110,7 +163,27 @@ boost::shared_ptr<Operator<TSet> > Parser::parseSymSetOperator(
...
@@ -110,7 +163,27 @@ boost::shared_ptr<Operator<TSet> > Parser::parseSymSetOperator(
{
{
ANTLRLexer
lexer
(
istr
);
ANTLRLexer
lexer
(
istr
);
ANTLRParser
parser
(
lexer
);
ANTLRParser
parser
(
lexer
);
return
parser
.
parse_symset_operator
(
tagset_
);
boost
::
shared_ptr
<
Operator
<
TSet
>
>
res
;
try
{
res
=
parser
.
parse_symset_operator
(
tagset_
);
}
catch
(
antlr
::
MismatchedTokenException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
NoViableAltException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
TokenStreamRecognitionException
&
e
)
{
throw
ParserException
(
e
.
getLine
()
+
":"
+
e
.
getColumn
()
+
std
::
string
(
" "
)
+
e
.
getMessage
()
);
}
catch
(
antlr
::
ANTLRException
&
e
)
{
throw
ParserException
(
e
.
getMessage
());
}
return
res
;
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
@@ -126,8 +199,13 @@ boost::shared_ptr<Operator<Position> > Parser::parsePositionOperator(
...
@@ -126,8 +199,13 @@ boost::shared_ptr<Operator<Position> > Parser::parsePositionOperator(
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
ss
<<
str
;
ss
<<
str
;
try
{
return
this
->
parsePositionOperator
(
ss
);
return
this
->
parsePositionOperator
(
ss
);
}
}
catch
(
ParserException
&
)
{
throw
;
}
}
/**
/**
* @desc Parse a position operator. Runs parse_sym_set_operator rule
* @desc Parse a position operator. Runs parse_sym_set_operator rule
...
@@ -140,7 +218,27 @@ boost::shared_ptr<Operator<Position> > Parser::parsePositionOperator(
...
@@ -140,7 +218,27 @@ boost::shared_ptr<Operator<Position> > Parser::parsePositionOperator(
{
{
ANTLRLexer
lexer
(
istr
);
ANTLRLexer
lexer
(
istr
);
ANTLRParser
parser
(
lexer
);
ANTLRParser
parser
(
lexer
);
return
parser
.
parse_position_operator
(
tagset_
);
boost
::
shared_ptr
<
Operator
<
Position
>
>
res
;
try
{
res
=
parser
.
parse_position_operator
(
tagset_
);
}
catch
(
antlr
::
MismatchedTokenException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
NoViableAltException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
TokenStreamRecognitionException
&
e
)
{
throw
ParserException
(
e
.
getLine
()
+
":"
+
e
.
getColumn
()
+
std
::
string
(
" "
)
+
e
.
getMessage
()
);
}
catch
(
antlr
::
ANTLRException
&
e
)
{
throw
ParserException
(
e
.
getMessage
());
}
return
res
;
}
}
/**
/**
...
@@ -304,8 +402,13 @@ boost::shared_ptr<RuleSequence> Parser::parseRuleSequence(
...
@@ -304,8 +402,13 @@ boost::shared_ptr<RuleSequence> Parser::parseRuleSequence(
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
ss
<<
str
;
ss
<<
str
;
try
{
return
this
->
parseRuleSequence
(
ss
);
return
this
->
parseRuleSequence
(
ss
);
}
}
catch
(
ParserException
&
)
{
throw
;
}
}
/**
/**
* @desc Parse a sequence rules. Runs parse_rule_sequence rule in the parser
* @desc Parse a sequence rules. Runs parse_rule_sequence rule in the parser
...
@@ -318,7 +421,27 @@ boost::shared_ptr<RuleSequence> Parser::parseRuleSequence(
...
@@ -318,7 +421,27 @@ boost::shared_ptr<RuleSequence> Parser::parseRuleSequence(
{
{
ANTLRLexer
lexer
(
istr
);
ANTLRLexer
lexer
(
istr
);
ANTLRParser
parser
(
lexer
);
ANTLRParser
parser
(
lexer
);
return
parser
.
parse_rule_sequence
(
tagset_
);
boost
::
shared_ptr
<
RuleSequence
>
res
;
try
{
res
=
parser
.
parse_rule_sequence
(
tagset_
);
}
catch
(
antlr
::
MismatchedTokenException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
NoViableAltException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
TokenStreamRecognitionException
&
e
)
{
throw
ParserException
(
e
.
getLine
()
+
":"
+
e
.
getColumn
()
+
std
::
string
(
" "
)
+
e
.
getMessage
()
);
}
catch
(
antlr
::
ANTLRException
&
e
)
{
throw
ParserException
(
e
.
getMessage
());
}
return
res
;
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
@@ -335,8 +458,13 @@ boost::shared_ptr<Rule> Parser::parseSingleRule(
...
@@ -335,8 +458,13 @@ boost::shared_ptr<Rule> Parser::parseSingleRule(
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
std
::
stringstream
ss
(
std
::
stringstream
::
in
|
std
::
stringstream
::
out
);
ss
<<
str
;
ss
<<
str
;
try
{
return
this
->
parseSingleRule
(
ss
);
return
this
->
parseSingleRule
(
ss
);
}
}
catch
(
ParserException
&
)
{
throw
;
}
}
/**
/**
* @desc Parse a single rule. Runs parse_single_rule rule in the parser
* @desc Parse a single rule. Runs parse_single_rule rule in the parser
...
@@ -349,7 +477,27 @@ boost::shared_ptr<Rule> Parser::parseSingleRule(
...
@@ -349,7 +477,27 @@ boost::shared_ptr<Rule> Parser::parseSingleRule(
{
{
ANTLRLexer
lexer
(
istr
);
ANTLRLexer
lexer
(
istr
);
ANTLRParser
parser
(
lexer
);
ANTLRParser
parser
(
lexer
);
return
parser
.
parse_single_rule
(
tagset_
);
boost
::
shared_ptr
<
Rule
>
res
;
try
{
res
=
parser
.
parse_single_rule
(
tagset_
);
}
catch
(
antlr
::
MismatchedTokenException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
NoViableAltException
&
e
)
{
throw
ParserException
(
e
.
getFileLineColumnString
()
+
" "
+
e
.
getMessage
()
);
}
catch
(
antlr
::
TokenStreamRecognitionException
&
e
)
{
throw
ParserException
(
e
.
getLine
()
+
":"
+
e
.
getColumn
()
+
std
::
string
(
" "
)
+
e
.
getMessage
()
);
}
catch
(
antlr
::
ANTLRException
&
e
)
{
throw
ParserException
(
e
.
getMessage
());
}
return
res
;
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
libwccl/parser/ParserException.h
+
6
−
5
View file @
608d1666
...
@@ -9,6 +9,7 @@ class ParserException : public Wccl::WcclError
...
@@ -9,6 +9,7 @@ class ParserException : public Wccl::WcclError
{
{
public:
public:
ParserException
(
const
std
::
string
);
ParserException
(
const
std
::
string
);
~
ParserException
()
throw
()
{
~
ParserException
()
throw
()
{
}
}
...
...
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