Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gazprea/impl/backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ name mangling that occurs to allow class functions. Thus, we recommend
that all runtime functions should be written in C and not in C++. There
is a Makefile in the ``runtime`` folder designed to turn all ``*.c`` and
``*.h`` pairs into part of the unified runtime library ``libruntime.a``.
An example of how to make a runtime function is provided bellow.
An example of how to make a runtime function is provided below.

``functions.c``

Expand Down
23 changes: 11 additions & 12 deletions gazprea/impl/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ new errors. Your compiler is only expected to report the first error it
encounters.

Syntax Errors
~~~~~~~~~~~~~
-------------

ANTLR handles syntax errors automatically, but you are required to override the
behavior and throw the ``SyntaxError`` exception from
Expand Down Expand Up @@ -80,7 +80,7 @@ Here are the compile-time errors your compiler must throw:
* ``TypeError``

Raised during compilation if an operation or statement is applied to or
betweeen expressions with invalid or incompatible types.
between expressions with invalid or incompatible types.

* ``AliasingError``

Expand All @@ -102,7 +102,7 @@ Here are the compile-time errors your compiler must throw:

Raised during compilation if the program detects a function or procedure
with a return value that does not have a return statement reachable by all
control flows. Control flow constructs may be assumed to always be undecideable,
control flows. Control flow constructs may be assumed to always be undecidable,
meaning they may branch in either direction.

If the subroutine has a ``return`` statement with a type that does not
Expand Down Expand Up @@ -146,7 +146,7 @@ Here are the compile-time errors your compiler must throw:
* ``MathError``

May be raised during compile time expression evaluation when division by zero occurs.
Conditions for raising are eqivalent to a runtime ``MathError``.
Conditions for raising are equivalent to a runtime ``MathError``.

* ``IndexError``

Expand All @@ -155,10 +155,9 @@ Here are the compile-time errors your compiler must throw:

* ``SizeError``

May be aised during compilation if the compiler detects an operation or statement
May be raised during compilation if the compiler detects an operation or statement
is applied to or between arrays with invalid or incompatible
sizes. Read more about when a ``SizeError`` should be raised at run-time
instead of compile-time in the :ref:`ssec:errors_sizeErrors` section.
sizes.

* ``StrideError``

Expand Down Expand Up @@ -190,7 +189,7 @@ Run-time errors must be handled by calling the functions defined in
The runtime errors listed below are a subset of compile time errors. Since it is not only impractical,
but undecidable to catch the following errors exclusively at compile time, Gazprea leaves the setting
at which they are raised up to the implementation. To put simply, you can raise runtime errors either
at compile time or at runtime and the tester will accomodate to different implementations.
at compile time or at runtime and the tester will accommodate different implementations.

* ``SizeError``

Expand All @@ -213,7 +212,7 @@ at compile time or at runtime and the tester will accomodate to different implem
``<=0``.

Here is an example invalid program. If your compiler is smart, you may raise the later error, if you
perfer not to implement static analysis, the former error can be emited at runtime.
prefer not to implement static analysis, the former error can be emitted at runtime.

::

Expand All @@ -240,12 +239,12 @@ More Examples
character[3] v = ['a', 'b', 'c']; // Indexing is harder than it looks!
integer i = 10;
v(3) = 'X'; // SyntaxError
v[i] = '?'; // Run-timeerror
v[i] = '?'; // Runtime error
v['a'] = '!'; // TypeError
i[1] = 1; // SymbolError

/* Tuples */
tuple (integerm integer) a = (9, 5);
tuple (integer, integer) a = (9, 5);
integer b;
integer c;
integer d;
Expand Down Expand Up @@ -312,7 +311,7 @@ Additionally, the tester only knows to stop the toolchain prematurely if your pr
terminates with a non-zero exit code. Once you have caught an error make sure to return
a non-zero exit code.

Finally, the tester is lenient towards the type given to a particular errror. Specifically
Finally, the tester is lenient towards the type given to a particular error. Specifically
the tester simply confirms that the substring "Error" is present and for compile
time errors that the correct line is provided.

Expand Down
2 changes: 1 addition & 1 deletion gazprea/impl/part_1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Compiler Implementation — Part 1
This section lists the portions of the *Gazprea* specification that must
be implemented to complete the part 1 of the compiler implementation.
All developers are advised to read the full specification for the
language prior to start the implementation of Part 1 because decisions
language prior to starting the implementation of Part 1 because decisions
made while implementing Part 1 can make the implementation of Part 2
significantly more challenging. Thus, planning ahead for Part 2 is the
recommended strategy.
Expand Down
2 changes: 1 addition & 1 deletion gazprea/impl/part_2.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Compiler Implementation — Part 2
================================

This section list the elements of the *Gazprea* specification that must
This section lists the elements of the *Gazprea* specification that must
be completed for the Part 2 of the compiler implementation. All the
elements of Part 1 must have been completed because Part 2 builds on
Part 1.
Expand Down
2 changes: 1 addition & 1 deletion gazprea/spec/built_in_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ implicitly defined in every file:

procedure stream_state(var input_stream) returns integer;

This function can only be called with the ``std_input`` as a parameter, but it’s
This procedure can only be called with the ``std_input`` as a parameter, but it’s
general enough that it could be used if the language were expanded to include
multiple input streams.

Expand Down
2 changes: 1 addition & 1 deletion gazprea/spec/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ commas, such as in matrix generators.
/* The "i"s both domain expressions are at the same scope, which is
* the one enclosing the loop. Therefore the matrix is: [[0 0 0] [0 1 2] [0 2 4]]
*/
integer[3,3] mat = [ i in 0..i, j in 0..i | i*j ];
integer[3][3] mat = [ i in 0..i, j in 0..i | i*j ];

The domain for the domain expression is only evaluated once. For
instance:
Expand Down
4 changes: 2 additions & 2 deletions gazprea/spec/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ The arguments and return value of functions can have both explicit and inferred
/* Some code here */
}

function transpose3x3(real[3,3] x) returns real[3,3] {
function transpose3x3(real[3][3] x) returns real[3][3] {
/* Some code here */
}

Expand All @@ -198,7 +198,7 @@ Like Rust, array *slices* may be passed as arguments:

Remember that all function parameters are ``const`` in *Gazprea*, so that all
functions are pure. That means that while it is legal to pass arrays and slices
*be reference*, the array contents cannot be modified inside the function,
*by reference*, the array contents cannot be modified inside the function,
because the change would be visible outside the function. You must check that
the ``const`` requirement is honored.

Expand Down
4 changes: 2 additions & 2 deletions gazprea/spec/globals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Globals
=======

Valid global scope statements inclulde:
Valid global scope statements include:

* Variable Declarations
* Struct Declarations
Expand All @@ -15,7 +15,7 @@ All global statements are considered declarations. Global statements may occur
in any order, given respective symbols are defined before being referenced.

Variable Declarations
=====================
---------------------

In *Gazprea* values can be assigned to a global identifier. All globals
must be immutable (``const``). If a global identifier is declared with
Expand Down
14 changes: 7 additions & 7 deletions gazprea/spec/streams.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Streams
=======

*Gazprea* has two streams: ``std_output`` and ``std_input``,
which are used for writting to `stdout` and reading from `stdin` respectively.
which are used for writing to `stdout` and reading from `stdin` respectively.


.. _ssec:output:
Expand Down Expand Up @@ -145,15 +145,15 @@ must be readable.

An ``integer`` from stdin can take any legal format described in the
:ref:`integer literal <sssec:integer_lit>` section. It may also be preceded by
a single negative or positive sign. All preceeding whitespace before the number or
a single negative or positive sign. All preceding whitespace before the number or
sign character may be skipped up to the limit imposed by the 512 byte read restriction.

A ``real`` input from stdin can take any legal format described in the
:ref:`real literal <sssec:real_lit>` section with the exception that no
whitespace may be present. It may also be proceeded by a single negative or
positive sign. Preceeding whitespace may be skipped in the same way as integers.
whitespace may be present. It may also be preceded by a single negative or
positive sign. Preceding whitespace may be skipped in the same way as integers.

A ``boolean`` input from stdin is either ``T`` or ``F``. Preceeding whitespace may be
A ``boolean`` input from stdin is either ``T`` or ``F``. Preceding whitespace may be
skipped in the same way as integers and reals.

For the following program:
Expand Down Expand Up @@ -203,8 +203,8 @@ Reading a ``character`` can never cause an error. The character will either be
successfully read or the end of the stream will be reached and ``-1`` will be
returned on this read.

When an error occurs the the null value is assigned and the input stream
remains pointing to the same position as before the read occured.
When an error occurs the null value is assigned and the input stream
remains pointing to the same position as before the read occurred.

The program below demonstrates 4 reads which set the error
states 1,0,0,2 respectively.
Expand Down
2 changes: 1 addition & 1 deletion gazprea/spec/type_promotion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ converted to ``integer``.
Automatic type conversion follows this table where N/A means no implicit
conversion possible, id means no conversion necessary,
``as<toType>(var)`` means var of type "From type" is converted to type
"toType" using semantics from .
"toType" using semantics from :ref:`sec:typeCasting`.

+----------+-----------+---------+-----------+---------+---------------+
| | **To type** |
Expand Down
4 changes: 2 additions & 2 deletions gazprea/spec/typedef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ new name to refer to the old type. For instance:
typealias integer int;
const int a = 0;

Note that hese new type names can *appear* to conflict with symbol names.
Note that these new type names can *appear* to conflict with symbol names.
However, the compiler can use context to differentiate a type alias from a
symbol. The following is therefore legal:

Expand Down Expand Up @@ -64,7 +64,7 @@ Duplicate alias names should raise a `SymbolError`
Some type aliases may be parameterized with an expression, such as with arrays,
such expressions are restricted to be composed exclusively from arithmetic
operations on scalar literals. Practically speaking, this requires constant
folding but *not* constant propogation.
folding but *not* constant propagation.

::

Expand Down
3 changes: 1 addition & 2 deletions gazprea/spec/types/array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ array instead of a ``real`` array.
If the LHS array is initialized using a RHS array that is too small then the LHS array will
be padded with zeros. However, if the LHS array is initialized with a RHS
array that is too large then a ``SizeError`` should be thrown at
compile-time or run-time. Check the :ref:`ssec:errors_sizeErrors` section to know when you
should throw the error.
compile-time or run-time.

#. Inferred Size Declarations

Expand Down
6 changes: 3 additions & 3 deletions gazprea/spec/types/matrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ matrix respectively. For instance:
integer[*][*] M = [[1, 1, 1], [1, 1, 1]];

integer r = rows(M); /* This has a value of 2 */
integer c = columns(M); /* This has a value of 3 \*/
integer c = columns(M); /* This has a value of 3 */


Matrix indexing is done similarly to array indexing, however, two
indices must be used. Because matrices are arrays of arrays the indexing is
coposite:
composite:

::

Expand All @@ -117,7 +117,7 @@ and column. Both the row and column indices must be integers.

integer[*][*] M = [[11, 12, 13], [21, 22, 23]];

/* M[1, 2] == 12 */
/* M[1][2] == 12 */

As with arrays, out of bounds indexing is an error on Matrices.

Expand Down
4 changes: 2 additions & 2 deletions gazprea/spec/types/string.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Declaration

A string may be declared with the keyword ``string``. The same rules of
:ref:`vector declarations <sssec:vec_decl>` also apply to strings, which means
that all lenghts are inferred:
that all lengths are inferred:

::

Expand All @@ -48,7 +48,7 @@ differently by the compiler:

character[*] carray = ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '\n'];
string vec = carray;
carry -> std_output;
carray -> std_output;
vec -> std_output;

prints:
Expand Down
6 changes: 3 additions & 3 deletions gazprea/spec/types/struct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ and consist of a ``<type id>`` pair:
struct Another (character char, real float, string[256] str, s1 struct_field);
var Another t2;

The examples show two structs declared with types ``s1`` and ``another``.
The examples show two structs declared with types ``s1`` and ``Another``.
Struct type ``s`` has three fields: ``i`` of type ``integer``, ``r`` of type
``real``, and ``iv`` of type ``integer[10]``.
Struct type ``another`` has four fields named ``char``, ``float``, ``str``,
Struct type ``Another`` has four fields named ``char``, ``float``, ``str``,
and ``struct_field``.
The instance variables are ``t1`` and ``t2`` have types ``s1`` and ``another``,
The instance variables ``t1`` and ``t2`` have types ``s1`` and ``Another``,
respectively.


Expand Down
2 changes: 1 addition & 1 deletion gazprea/spec/types/vector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Those greater raise a runtime ``SizeError``.

const vector<character> vec = ['a', 'b', 'c'];
const vector<real[*]> ragged_right = [[1.0], [2.0, 2.0]]; // SizeError
const vector<real[*]> paddeded_right = [[1.0, 2.0], [1.0]]; // Padds second element
const vector<real[*]> padded_right = [[1.0, 2.0], [1.0]]; // Pads second element
const vector<character> const_vec = vec;


Expand Down
Loading