Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
belr
Commits
b208b0ad
Commit
b208b0ad
authored
Jun 14, 2016
by
Sylvain Berfini
🎩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced cout and cerr by bctbx logger
parent
3818822f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
12 deletions
+21
-12
CMakeLists.txt
CMakeLists.txt
+8
-0
src/CMakeLists.txt
src/CMakeLists.txt
+1
-1
src/grammarbuilder.cc
src/grammarbuilder.cc
+12
-11
No files found.
CMakeLists.txt
View file @
b208b0ad
...
...
@@ -59,6 +59,13 @@ endif()
# find_package should be invoked here to check for libraries - however do NOT
# call include_directories here (see below)
if
(
LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS
)
set
(
BcToolbox_FIND_COMPONENTS tester
)
include
(
"
${
EP_bctoolbox_CONFIG_DIR
}
/BcToolboxConfig.cmake"
)
else
()
find_package
(
BcToolbox 0.0.3 REQUIRED
)
endif
()
if
(
UNIX AND NOT APPLE
)
include
(
CheckIncludeFiles
)
check_include_files
(
libudev.h HAVE_LIBUDEV_H
)
...
...
@@ -67,6 +74,7 @@ endif()
include_directories
(
include/
src/
${
BCTOOLBOX_INCLUDE_DIRS
}
${
CMAKE_CURRENT_BINARY_DIR
}
)
if
(
MSVC
)
...
...
src/CMakeLists.txt
View file @
b208b0ad
...
...
@@ -42,7 +42,7 @@ else()
set_target_properties
(
belr PROPERTIES VERSION
${
BELR_SO_VERSION
}
)
endif
()
target_link_libraries
(
belr
)
target_link_libraries
(
belr
${
BCTOOLBOX_LIBRARIES
}
)
install
(
TARGETS belr EXPORT
${
EXPORT_TARGETS_NAME
}
Targets
RUNTIME DESTINATION bin
...
...
src/grammarbuilder.cc
View file @
b208b0ad
...
...
@@ -3,6 +3,8 @@
#include "belr/grammarbuilder.hh"
#include "belr/parser-impl.cc"
#include "bctoolbox/logging.h"
#include <iostream>
#include <fstream>
#include <sstream>
...
...
@@ -113,7 +115,7 @@ shared_ptr< Recognizer > ABNFElement::buildRecognizer(const shared_ptr< Grammar
else
return
Utils
::
literal
(
mCharVal
);
}
cerr
<<
"
ABNFElement::buildRecognizer is empty, should not happen!"
<<
endl
;
bctbx_error
(
"[belr]
ABNFElement::buildRecognizer is empty, should not happen!"
)
;
abort
();
return
NULL
;
}
...
...
@@ -140,7 +142,7 @@ void ABNFElement::setCharVal(const string& charval){
void
ABNFElement
::
setProseVal
(
const
string
&
prose
){
if
(
!
prose
.
empty
()){
cerr
<<
"
prose-val is not supported."
<<
endl
;
bctbx_error
(
"[belr]
prose-val is not supported."
)
;
abort
();
}
}
...
...
@@ -189,7 +191,7 @@ shared_ptr<ABNFConcatenation> ABNFConcatenation::create(){
shared_ptr
<
Recognizer
>
ABNFConcatenation
::
buildRecognizer
(
const
shared_ptr
<
Grammar
>
&
grammar
){
if
(
mRepetitions
.
size
()
==
0
){
cerr
<<
"
No repetitions set !"
<<
endl
;
bctbx_error
(
"[belr]
No repetitions set !"
)
;
abort
();
}
if
(
mRepetitions
.
size
()
==
1
){
...
...
@@ -239,8 +241,7 @@ shared_ptr<ABNFRule> ABNFRule::create(){
}
void
ABNFRule
::
setName
(
const
string
&
name
){
if
(
!
mName
.
empty
())
cerr
<<
"Rule "
<<
this
<<
" is renamed !!!!!"
<<
endl
;
if
(
!
mName
.
empty
())
bctbx_error
(
"[belr] Rule %s is renamed !!!!!"
,
name
.
c_str
());
//cout<<"Rule "<<this<<" is named "<<name<<endl;
mName
=
name
;
}
...
...
@@ -325,20 +326,20 @@ shared_ptr<Grammar> ABNFGrammarBuilder::createFromAbnf(const string &abnf, const
shared_ptr
<
ABNFBuilder
>
builder
=
mParser
.
parseInput
(
"rulelist"
,
abnf
,
&
parsed
);
if
(
parsed
<
(
size_t
)
abnf
.
size
()){
cerr
<<
"ERROR: only "
<<
parsed
<<
"
bytes parsed over a total of
"
<<
abnf
.
size
()
<<
endl
;
bctbx_error
(
"[belr] Only %i
bytes parsed over a total of
%i."
,
parsed
,
abnf
.
size
()
)
;
return
NULL
;
}
shared_ptr
<
Grammar
>
retGram
;
if
(
gram
==
NULL
)
retGram
=
make_shared
<
Grammar
>
(
abnf
);
else
retGram
=
gram
;
builder
->
buildRecognizer
(
retGram
);
cout
<<
"
Succesfully created grammar with
"
<<
retGram
->
getNumRules
()
<<
" rules."
<<
endl
;
bctbx_message
(
"[belr]
Succesfully created grammar with
%i rules."
,
retGram
->
getNumRules
()
)
;
if
(
retGram
->
isComplete
()){
cout
<<
"
Grammar is complete."
<<
endl
;
bctbx_message
(
"[belr]
Grammar is complete."
)
;
retGram
->
optimize
();
cout
<<
"
Grammar has been optimized."
<<
endl
;
bctbx_message
(
"[belr]
Grammar has been optimized."
)
;
}
else
{
cout
<<
"WARNING: g
rammar is not complete."
<<
endl
;
bctbx_warning
(
"[belr] G
rammar is not complete."
)
;
}
return
gram
;
}
...
...
@@ -346,7 +347,7 @@ shared_ptr<Grammar> ABNFGrammarBuilder::createFromAbnf(const string &abnf, const
shared_ptr
<
Grammar
>
ABNFGrammarBuilder
::
createFromAbnfFile
(
const
string
&
path
,
const
shared_ptr
<
Grammar
>
&
gram
){
ifstream
istr
(
path
);
if
(
!
istr
.
is_open
()){
cerr
<<
"Could not open "
<<
path
<<
endl
;
bctbx_error
(
"[belr] Could not open %s"
,
path
.
c_str
())
;
return
NULL
;
}
stringstream
sstr
;
...
...
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