Skip to content

Commit b04b126

Browse files
Merge branch 'training-one_day' into 'master'
Minor formatting tweaks and some content updates Closes #153 See merge request feng/training/material!179
2 parents 45222d4 + 9e64374 commit b04b126

24 files changed

+5219
-0
lines changed

marketing/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Overview
2+
3+
This folder is a collection of Ada/SPARK overviews culled from the
4+
*fundamentals_of_ada* and *spark_for_ada_programmers* folder in courses.
5+
6+
The folder name will be a blunt description of the content within.
7+
We're starting with "ada_8_hours" which will be an overview of Ada using
8+
content culled from from *fundamentals_of_ada*.
9+
10+
Going forward, we can add other modules (we need "ada_4_hours"), in
11+
addition to things like demos
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
**********
2+
Overview
3+
**********
4+
5+
..
6+
Coding language
7+
8+
.. role:: ada(code)
9+
:language: Ada
10+
11+
.. role:: C(code)
12+
:language: C
13+
14+
.. role:: cpp(code)
15+
:language: C++
16+
17+
..
18+
Math symbols
19+
20+
.. |rightarrow| replace:: :math:`\rightarrow`
21+
.. |forall| replace:: :math:`\forall`
22+
.. |exists| replace:: :math:`\exists`
23+
.. |equivalent| replace:: :math:`\iff`
24+
.. |le| replace:: :math:`\le`
25+
.. |ge| replace:: :math:`\ge`
26+
.. |lt| replace:: :math:`<`
27+
.. |gt| replace:: :math:`>`
28+
29+
..
30+
Miscellaneous symbols
31+
32+
.. |checkmark| replace:: :math:`\checkmark`
33+
34+
===================
35+
About This Course
36+
===================
37+
38+
--------
39+
Styles
40+
--------
41+
42+
* :dfn:`This` is a definition
43+
* :filename:`this/is/a.path`
44+
* :ada:`code is highlighted`
45+
* :command:`commands are emphasised --like-this`
46+
47+
==============
48+
Introduction
49+
==============
50+
51+
-------------------------
52+
*Core* Language Content
53+
-------------------------
54+
55+
* Ada is a **compiled**, **multi-paradigm** language
56+
57+
- Exceptions
58+
- Generic units
59+
- Dynamic memory management
60+
- Low-level programming
61+
- Object-Oriented Programming (OOP)
62+
- Concurrent programming
63+
- Contract-Based Programming
64+
65+
* With a **static** and **strong** type model
66+
67+
=======
68+
Setup
69+
=======
70+
71+
-------------------------
72+
Canonical First Program
73+
-------------------------
74+
75+
.. code:: Ada
76+
77+
1 with Ada.Text_IO;
78+
2 -- Everyone's first program
79+
3 procedure Say_Hello is
80+
4 begin
81+
5 Ada.Text_IO.Put_Line ("Hello, World!");
82+
6 end Say_Hello;
83+
84+
* Line 1 - :ada:`with` - Package dependency
85+
* Line 2 - :ada:`--` - Comment
86+
* Line 3 - :ada:`Say_Hello` - Subprogram name
87+
* Line 4 - :ada:`begin` - Begin executable code
88+
* Line 5 - :ada:`Ada.Text_IO.Put_Line ()` - Subprogram call
89+
* (cont) - :ada:`"Hello, World!"` - String literal (type-checked)
90+
91+
----------------------------------
92+
"Hello World" Lab - Command Line
93+
----------------------------------
94+
95+
* Use an editor to enter the program shown on the previous slide
96+
97+
- Use your favorite editor or just gedit/notepad/etc.
98+
99+
* Save and name the file :filename:`say_hello.adb` exactly
100+
101+
- In a command prompt shell, go to where the new file is located and issue the following command:
102+
103+
+ :command:`gprbuild say_hello`
104+
105+
* In the same shell, invoke the resulting executable:
106+
107+
- :command:`say_hello` (Windows)
108+
- :command:`./say_hello` (Linux/Unix)
109+
110+
---------------------------------------------
111+
"Hello World" Lab - :toolname:`GNAT Studio`
112+
---------------------------------------------
113+
114+
* Start :toolname:`GNAT Studio` from the command-line (:command:`gnatstudio`) or Start Menu
115+
* :menu:`Create new project`
116+
117+
- Select :menu:`Simple Ada Project` and click :menu:`Next`
118+
- Fill in a location to to deploy the project
119+
- Set **main name** to *say_hello* and click :menu:`Apply`
120+
121+
* Expand the **src** level in the Project View and double-click :filename:`say_hello.adb`
122+
123+
- Replace the code in the file with the program shown on the previous slide
124+
125+
* Execute the program by selecting :menu:`Build` :math:`\rightarrow` :menu:`Project` :math:`\rightarrow` :menu:`Build & Run` :math:`\rightarrow` :menu:`say_hello.adb`
126+
127+
- Shortcut is the :math:`\blacktriangleright` in the icons bar
128+
129+
* Result should appear in the bottom pane labeled *Run: say_hello.exe*
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
**************
2+
Declarations
3+
**************
4+
5+
..
6+
Coding language
7+
8+
.. role:: ada(code)
9+
:language: Ada
10+
11+
.. role:: C(code)
12+
:language: C
13+
14+
.. role:: cpp(code)
15+
:language: C++
16+
17+
..
18+
Math symbols
19+
20+
.. |rightarrow| replace:: :math:`\rightarrow`
21+
.. |forall| replace:: :math:`\forall`
22+
.. |exists| replace:: :math:`\exists`
23+
.. |equivalent| replace:: :math:`\iff`
24+
.. |le| replace:: :math:`\le`
25+
.. |ge| replace:: :math:`\ge`
26+
.. |lt| replace:: :math:`<`
27+
.. |gt| replace:: :math:`>`
28+
29+
..
30+
Miscellaneous symbols
31+
32+
.. |checkmark| replace:: :math:`\checkmark`
33+
34+
====================================
35+
Identifiers, Comments, and Pragmas
36+
====================================
37+
38+
-------------
39+
Identifiers
40+
-------------
41+
42+
* Syntax
43+
44+
.. code::
45+
46+
identifier ::= letter {[underline] letter_or_digit}
47+
48+
* Character set **Unicode** 4.0
49+
50+
- 8, 16, 32 bit-wide characters
51+
52+
* Case **not significant**
53+
54+
- `SpacePerson` |equivalent| `SPACEPERSON`
55+
- but **different** from `Space_Person`
56+
57+
* Reserved words are **forbidden**
58+
59+
----------
60+
Comments
61+
----------
62+
63+
* Terminate at end of line (i.e., no comment terminator sequence)
64+
65+
.. code:: Ada
66+
67+
-- This is a multi-
68+
-- line comment
69+
A : B; -- this is an end-of-line comment
70+
71+
---------
72+
Pragmas
73+
---------
74+
75+
* Compiler directives
76+
77+
- Compiler action
78+
- Serve various roles
79+
- May suggest or modify compiler behavior
80+
- May restrict feature usage
81+
- May generate specfic code
82+
- Either standard or implementation-defined
83+
84+
* Unrecognized pragmas
85+
86+
- **No effect**
87+
- Cause **warning** (standard mode)
88+
89+
* Malformed pragmas are **illegal**
90+
91+
.. code:: Ada
92+
93+
pragma Page;
94+
pragma Optimize (Off);
95+
96+
==================
97+
Numeric Literals
98+
==================
99+
100+
--------------------------
101+
Decimal Numeric Literals
102+
--------------------------
103+
104+
* Syntax
105+
106+
.. code::
107+
108+
decimal_literal ::=
109+
numeral [.num] E [+numeral|-numeral]
110+
numeral ::= digit {[underline] digit}
111+
112+
* Underscore is not significant
113+
* **E** (exponent) must always be integer
114+
* Examples
115+
116+
.. code:: Ada
117+
118+
12 0 1E6 123_456
119+
12.0 0.0 3.14159_26 2.3E-4
120+
121+
------------------------
122+
Based Numeric Literals
123+
------------------------
124+
125+
.. code::
126+
127+
based_literal ::= base # numeral [.numeral] # exponent
128+
numeral ::= base_digit { '_' base_digit }
129+
130+
* Base can be 2 .. 16
131+
* Exponent is always a base 10 integer
132+
133+
::
134+
135+
16#FFF# => 4095
136+
2#1111_1111_1111# => 4095 -- With underline
137+
16#F.FF#E+2 => 4095.0
138+
8#10#E+3 => 4096 (8 * 8**3)
139+
140+
=====================
141+
Object Declarations
142+
=====================
143+
144+
--------------
145+
Declarations
146+
--------------
147+
148+
* Associate a :dfn:`name` to an :dfn:`entity`
149+
150+
- Objects
151+
- Types
152+
- Subprograms
153+
- et cetera
154+
155+
* Declaration **must precede** use
156+
* **Some** implicit declarations
157+
158+
- **Standard** types and operations
159+
- **Implementation**-defined
160+
161+
---------------------
162+
Object Declarations
163+
---------------------
164+
165+
* Variables and constants
166+
* Basic Syntax
167+
168+
.. code:: Ada
169+
170+
<name> : subtype_indication [:= <initial value>];
171+
172+
* Examples
173+
174+
.. code:: Ada
175+
176+
Z, Phase : Analog;
177+
Max : constant Integer := 200;
178+
-- variable with a constraint
179+
Count : Integer range 0 .. Max := 0;
180+
-- dynamic initial value via function call
181+
Root : Tree := F(X);
182+
-- Will call G(X) twice, once per variable
183+
A, B : Integer := G(X);

0 commit comments

Comments
 (0)