Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
71f55c5b
Commit
71f55c5b
authored
8 years ago
by
Tomáš Pecka
Browse files
Options
Downloads
Patches
Plain Diff
Rename: LeftRG and RightRG: normalize N with base26
parent
ce2d9623
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arename2/src/arename.cpp
+52
-32
52 additions, 32 deletions
arename2/src/arename.cpp
with
52 additions
and
32 deletions
arename2/src/arename.cpp
+
52
−
32
View file @
71f55c5b
...
...
@@ -5,69 +5,89 @@
*
Author
:
Jan
Travnicek
*/
#include
<tclap/CmdLine.h>
#include
<global/GlobalData.h>
#include
<measure>
#include
<sax/FromXMLParserHelper.h>
#include
<tclap/CmdLine.h>
#include
"automaton/simplify/Rename.h"
#include
"exception/CommonException.h"
#include
"factory/XmlDataFactory.hpp"
#include
"
automaton
/simplify/Rename.h"
#include
"
grammar
/simplify/Rename.h"
int
main
(
int
argc
,
char
*
*
argv
)
{
int
main
(
int
argc
,
char
*
*
argv
)
{
try
{
common
::
GlobalData
::
argc
=
argc
;
common
::
GlobalData
::
argv
=
argv
;
TCLAP
::
CmdLine
cmd
(
"Automaton rename binary"
,
' '
,
"0.01"
);
TCLAP
::
CmdLine
cmd
(
"Automaton rename binary"
,
' '
,
"0.01"
);
TCLAP
::
ValueArg
<
std
::
string
>
input
(
"i"
,
"input"
,
"Automaton to rename"
,
false
,
"-"
,
"file"
);
cmd
.
add
(
input
);
TCLAP
::
ValueArg
<
std
::
string
>
input
(
"i"
,
"input"
,
"Automaton to rename"
,
false
,
"-"
,
"file"
);
cmd
.
add
(
input
);
TCLAP
::
SwitchArg
measure
(
"m"
,
"measure"
,
"Measure times"
,
false
);
cmd
.
add
(
measure
);
TCLAP
::
SwitchArg
measure
(
"m"
,
"measure"
,
"Measure times"
,
false
);
cmd
.
add
(
measure
);
TCLAP
::
SwitchArg
verbose
(
"v"
,
"verbose"
,
"Be verbose"
,
false
);
cmd
.
add
(
verbose
);
TCLAP
::
SwitchArg
verbose
(
"v"
,
"verbose"
,
"Be verbose"
,
false
);
cmd
.
add
(
verbose
);
cmd
.
parse
(
argc
,
argv
);
cmd
.
parse
(
argc
,
argv
);
if
(
verbose
.
isSet
()
)
if
(
verbose
.
isSet
(
)
)
common
::
GlobalData
::
verbose
=
true
;
if
(
measure
.
isSet
())
if
(
measure
.
isSet
(
)
)
common
::
GlobalData
::
measure
=
true
;
measurements
::
start
(
"Overal"
,
measurements
::
Type
::
OVERALL
);
measurements
::
start
(
"Input read"
,
measurements
::
Type
::
AUXILIARY
);
measurements
::
start
(
"Overal"
,
measurements
::
Type
::
OVERALL
);
measurements
::
start
(
"Input read"
,
measurements
::
Type
::
AUXILIARY
);
std
::
deque
<
sax
::
Token
>
tokens
=
sax
::
FromXMLParserHelper
::
parseInput
(
input
);
if
(
alib
::
XmlDataFactory
::
first
<
automaton
::
Automaton
>
(
tokens
)
)
{
automaton
::
Automaton
automaton
=
alib
::
XmlDataFactory
::
fromTokens
<
automaton
::
Automaton
>
(
std
::
move
(
tokens
)
);
measurements
::
end
(
);
measurements
::
start
(
"Algorithm"
,
measurements
::
Type
::
MAIN
);
automaton
::
Automaton
res
=
automaton
::
simplify
::
Rename
::
rename
(
automaton
);
measurements
::
end
(
);
measurements
::
start
(
"Output write"
,
measurements
::
Type
::
AUXILIARY
);
automaton
::
Automaton
automaton
=
alib
::
XmlDataFactory
::
fromTokens
<
automaton
::
Automaton
>
(
sax
::
FromXMLParserHelper
::
parseInput
(
input
));
alib
::
XmlDataFactory
::
toStdout
(
res
);
}
else
if
(
alib
::
XmlDataFactory
::
first
<
grammar
::
Grammar
>
(
tokens
)
)
{
grammar
::
Grammar
grammar
=
alib
::
XmlDataFactory
::
fromTokens
<
grammar
::
Grammar
>
(
std
::
move
(
tokens
)
);
measurements
::
end
(
);
measurements
::
start
(
"Algorithm"
,
measurements
::
Type
::
MAIN
);
measurements
::
end
(
);
measurements
::
start
(
"Algorithm"
,
measurements
::
Type
::
MAIN
);
automaton
::
Automaton
res
=
automaton
::
simplify
::
Rename
::
rename
(
automaton
);
grammar
::
Grammar
res
=
grammar
::
simplify
::
Rename
::
rename
(
grammar
);
measurements
::
end
(
);
measurements
::
start
(
"Output write"
,
measurements
::
Type
::
AUXILIARY
);
measurements
::
end
(
);
measurements
::
start
(
"Output write"
,
measurements
::
Type
::
AUXILIARY
);
alib
::
XmlDataFactory
::
toStdout
(
res
);
alib
::
XmlDataFactory
::
toStdout
(
res
);
}
else
{
throw
exception
::
CommonException
(
"Invalid rename command"
);
}
measurements
::
end
(
);
measurements
::
end
(
);
measurements
::
end
(
);
measurements
::
end
(
);
if
(
measure
.
getValue
()
)
std
::
cmeasure
<<
measurements
::
results
(
)
<<
std
::
endl
;
if
(
measure
.
getValue
(
)
)
std
::
cmeasure
<<
measurements
::
results
(
)
<<
std
::
endl
;
return
0
;
}
catch
(
const
exception
::
CommonException
&
exception
)
{
alib
::
XmlDataFactory
::
toStdout
(
exception
);
}
catch
(
const
exception
::
CommonException
&
exception
)
{
alib
::
XmlDataFactory
::
toStdout
(
exception
);
return
1
;
}
catch
(
const
TCLAP
::
ArgException
&
exception
)
{
std
::
cout
<<
exception
.
error
(
)
<<
std
::
endl
;
}
catch
(
const
TCLAP
::
ArgException
&
exception
)
{
std
::
cout
<<
exception
.
error
(
)
<<
std
::
endl
;
return
2
;
}
catch
(
const
std
::
exception
&
exception
)
{
std
::
cerr
<<
"Exception caught: "
<<
exception
.
what
(
)
<<
std
::
endl
;
}
catch
(
const
std
::
exception
&
exception
)
{
std
::
cerr
<<
"Exception caught: "
<<
exception
.
what
(
)
<<
std
::
endl
;
return
3
;
}
catch
(
...)
{
}
catch
(
...
)
{
std
::
cerr
<<
"Unknown exception caught."
<<
std
::
endl
;
return
127
;
}
...
...
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