Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
kazoo
Commits
553b2d91
Commit
553b2d91
authored
Dec 17, 2017
by
Maxime Perrotin
Browse files
Start introducing proper command line parser
parent
6db4c5bc
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/aadl_parser.adb
View file @
553b2d91
...
...
@@ -18,7 +18,6 @@ with Ada.Command_Line,
Ocarina
.
Instances
,
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nodes
,
Ocarina
.
Parser
,
Ocarina
.
FE_AADL
.
Parser
,
Parser_Utils
,
Interface_View
,
Deployment_View
;
...
...
@@ -53,7 +52,6 @@ procedure AADL_Parser is
Depl_View_Pos
:
Natural
:=
0
;
Data_View
:
Natural
:=
0
;
Generate_glue
:
Boolean
:=
false
;
AADL_Version
:
AADL_Version_Type
:=
Ocarina
.
AADL_V2
;
procedure
Parse_Command_Line
;
-- procedure Process_DataView (My_Root : Node_Id);
...
...
@@ -252,35 +250,12 @@ procedure AADL_Parser is
FN
:
Name_Id
;
B
:
Location
;
begin
-- Initialization step: we look for ocarina on path to define
-- OCARINA_PATH env. variable. This will indicate Ocarina librrary
-- where to find AADL default property sets, and Ocarina specific
-- packages and property sets.
declare
S
:
constant
GNAT
.
OS_Lib
.
String_Access
:=
GNAT
.
OS_Lib
.
Locate_Exec_On_Path
(
"ocarina"
);
begin
if
S
=
null
then
raise
AADL_Parser_Error
with
"Ocarina is not in your PATH"
;
end
if
;
GNAT
.
OS_Lib
.
Setenv
(
"OCARINA_PATH"
,
S
.
all
(
S
'
First
..
S
'
Last
-
12
));
end
;
-- Display the command line syntax
if
Ada
.
Command_Line
.
Argument_Count
=
0
then
Usage
;
raise
AADL_Parser_Error
with
"Missing command line arguments"
;
end
if
;
Ocarina
.
Initialize
;
Ocarina
.
AADL_Version
:=
AADL_Version
;
Ocarina
.
Configuration
.
Init_Modules
;
Ocarina
.
FE_AADL
.
Parser
.
Add_Pre_Prop_Sets
:=
True
;
AADL_Language
:=
Get_String_Name
(
"aadl"
);
Parse_Command_Line
;
...
...
@@ -362,6 +337,7 @@ procedure AADL_Parser is
begin
Banner
;
Initialize_Ocarina
;
Initialize
;
-- First, we analyze the interface view.
...
...
src/parser_utils.adb
View file @
553b2d91
...
...
@@ -5,15 +5,21 @@
with
Ada
.
Text_IO
,
Parser_Version
,
Ocarina
.
AADL_Values
,
Ocarina
.
Configuration
,
Ocarina
.
FE_AADL
.
Parser
,
Ocarina
.
Instances
.
Queries
,
Ada
.
Characters
.
Latin_1
;
GNAT
.
OS_Lib
,
Ada
.
Characters
.
Latin_1
,
GNAT
.
Command_Line
;
package
body
Parser_Utils
is
use
Ada
.
Text_IO
,
Ocarina
.
Instances
.
Queries
,
Ada
.
Characters
.
Latin_1
,
Ocarina
.
ME_AADL
;
GNAT
.
OS_Lib
,
Ocarina
.
ME_AADL
,
GNAT
.
Command_Line
;
------------
-- Banner --
...
...
@@ -39,37 +45,40 @@ package body Parser_Utils is
procedure
Usage
is
begin
Put_Line
(
"Usage: taste-aadl-parser <options> otherfiles"
);
Put_Line
(
"Where <options> are:"
);
New_Line
;
Put
(
"-l, --glue"
&
HT
&
HT
&
HT
&
HT
);
Put_Line
(
"Generate glue code"
);
Put
(
"-w, --gw"
&
HT
&
HT
&
HT
&
HT
);
Put_Line
(
"Generate code skeletons"
);
Put
(
"-o, --output <outputDir>"
&
HT
&
HT
);
Put_Line
(
"Root directory for the output files"
);
Put
(
"-i, --interfaceview <i_view.aadl>"
&
HT
);
Put_Line
(
"The interface view in AADL"
);
Put
(
"-c, --deploymentview <d_view.aadl>"
&
HT
);
Put_Line
(
"The deployment view in AADL"
);
Put
(
"-d, --dataview <dataview.aadl>"
&
HT
&
HT
);
Put_Line
(
"The data view in AADL"
);
Put
(
"-t, --test"
&
HT
&
HT
&
HT
&
HT
);
Put_Line
(
"Dump model information"
);
Put
(
"-g, --debug"
&
HT
&
HT
&
HT
&
HT
);
Put_Line
(
"Generate runtime debug output"
);
Put
(
"-x, --timer <timer-resolution in ms>"
&
HT
);
Put_Line
(
"Set the timer resolution (default 100 ms)"
);
Put
(
"-v, --version"
&
HT
&
HT
&
HT
&
HT
);
Put_Line
(
"Display taste-aadl-parser version number"
);
Put
(
"-p, --polyorb-hi-c"
&
HT
&
HT
&
HT
);
Put_Line
(
"Interface glue code with PolyORB-HI-C"
);
Put
(
"otherfiles"
&
HT
&
HT
&
HT
&
HT
);
Put_Line
(
"Any other aadl file you want to parse"
);
New_Line
;
New_Line
;
Put_Line
(
"For example, this command will generate your application"
&
" skeletons:"
);
New_Line
;
...
...
@@ -79,6 +88,34 @@ package body Parser_Utils is
end
Usage
;
function
Parse_Command_Line
return
Taste_Configuration
is
Config
:
Command_Line_Configuration
;
Result
:
Taste_Configuration
;
begin
Define_Switch
(
Config
,
Output
=>
Result
.
Interface_View
'
Access
,
Switch
=>
"-i:"
,
Long_Switch
=>
"--interfaceview="
,
Help
=>
"Mandatory interface view (AADL model)"
,
Argument
=>
"InterfaceView.aadl"
);
Define_Switch
(
Config
,
Output
=>
Result
.
Deployment_View
'
Access
,
Switch
=>
"-c:"
,
Long_Switch
=>
"--deploymentview="
,
Help
=>
"Optional deployment view (AADL model)"
,
Argument
=>
"DeploymentView.aadl"
);
Define_Switch
(
Config
,
Output
=>
Result
.
Data_View
'
Access
,
Switch
=>
"-d:"
,
Long_Switch
=>
"--dataview="
,
Help
=>
"Optional data view (AADL model)"
,
Argument
=>
"DataView.aadl"
);
Getopt
(
Config
);
loop
declare
S
:
constant
String
:=
Get_Argument
;
begin
exit
when
S
'
Length
=
0
;
Put_Line
(
"File argument : "
&
S
);
end
;
end
loop
;
return
Result
;
end
Parse_Command_Line
;
-----------------------
-- Get_APLC_Binding --
-----------------------
...
...
@@ -152,4 +189,21 @@ package body Parser_Utils is
return
result
;
end
Get_Properties_Map
;
-- Initialization step: we look for ocarina on path to define
-- OCARINA_PATH env. variable. This will indicate Ocarina librrary
-- where to find AADL default property sets, and Ocarina specific
-- packages and property sets.
procedure
Initialize_Ocarina
is
S
:
constant
GNAT
.
OS_Lib
.
String_Access
:=
GNAT
.
OS_Lib
.
Locate_Exec_On_Path
(
"ocarina"
);
begin
if
S
=
null
then
raise
AADL_Parser_Error
with
"Ocarina is not in your PATH"
;
end
if
;
GNAT
.
OS_Lib
.
Setenv
(
"OCARINA_PATH"
,
S
.
all
(
S
'
First
..
S
'
Last
-
12
));
Ocarina
.
Initialize
;
Ocarina
.
AADL_Version
:=
Ocarina
.
AADL_V2
;
Ocarina
.
Configuration
.
Init_Modules
;
Ocarina
.
FE_AADL
.
Parser
.
Add_Pre_Prop_Sets
:=
True
;
end
Initialize_Ocarina
;
end
Parser_Utils
;
src/parser_utils.ads
View file @
553b2d91
...
...
@@ -12,6 +12,7 @@ with Ocarina,
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nodes
,
Ada
.
Strings
.
Unbounded
,
Option_Type
,
GNAT
.
Strings
,
Interfaces
.
C_Streams
;
use
Ocarina
,
...
...
@@ -90,4 +91,26 @@ package Parser_Utils is
use
Option_ULL
;
subtype
Optional_Long_Long
is
Option_ULL
.
Option
;
procedure
Initialize_Ocarina
;
type
Taste_Configuration
is
record
Interface_View
:
aliased
GNAT
.
Strings
.
String_Access
;
Deployment_View
:
aliased
GNAT
.
Strings
.
String_Access
;
Data_View
:
aliased
GNAT
.
Strings
.
String_Access
;
Use_POHIC
:
aliased
Boolean
;
Glue
:
aliased
Boolean
;
Smp2
:
aliased
Boolean
;
Skeletons
:
aliased
Boolean
;
Test_Flag
:
aliased
Boolean
;
Aadlv2
:
aliased
Boolean
;
Future_Flag
:
aliased
Boolean
;
Output_Dir
:
aliased
GNAT
.
Strings
.
String_Access
;
Timer_Resolution
:
aliased
Natural
;
Version
:
aliased
Boolean
;
Debug_Flag
:
aliased
Boolean
;
end
record
;
function
Parse_Command_Line
return
Taste_Configuration
;
end
Parser_Utils
;
src/parser_version.ads
View file @
553b2d91
package
Parser_Version
is
Parser_Release
:
constant
String
:=
"
2d5f7ec
; Commit Date:
Wed
Dec
6
1
8:21:43
2017 "
;
"
6db4c5b
; Commit Date:
Thu
Dec
7
1
4:05:24
2017 "
;
Ocarina_Version
:
constant
String
:=
"Ocarina 2017.x (Working Copy from r0b92ed3)"
;
end
Parser_Version
;
\ No newline at end of file
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment