From 17394d468e2b386c51ea95538c6022126d817e9c Mon Sep 17 00:00:00 2001 From: Drew Date: Mon, 22 Jun 2026 13:14:30 -0400 Subject: [PATCH 1/5] spec: fix spelling and grammar in prose Correct ~20 single-word spelling/grammar errors across the spec and impl prose (e.g. writting->writing, preceeding->preceding, undecideable->undecidable, accomodate->accommodate, propogation->propagation, be reference->by reference). Also align two terminology slips with the surrounding text: refer to stream_state as a procedure (it is declared as one) and to the struct type as Another (its declared name). No semantic changes. --- gazprea/impl/backend.rst | 2 +- gazprea/impl/errors.rst | 14 +++++++------- gazprea/impl/part_1.rst | 2 +- gazprea/impl/part_2.rst | 2 +- gazprea/spec/built_in_functions.rst | 2 +- gazprea/spec/functions.rst | 2 +- gazprea/spec/globals.rst | 2 +- gazprea/spec/streams.rst | 14 +++++++------- gazprea/spec/typedef.rst | 4 ++-- gazprea/spec/types/matrix.rst | 2 +- gazprea/spec/types/string.rst | 2 +- gazprea/spec/types/struct.rst | 6 +++--- gazprea/spec/types/vector.rst | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/gazprea/impl/backend.rst b/gazprea/impl/backend.rst index cd45e19..cd265e9 100644 --- a/gazprea/impl/backend.rst +++ b/gazprea/impl/backend.rst @@ -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`` diff --git a/gazprea/impl/errors.rst b/gazprea/impl/errors.rst index 349a040..31ffebe 100644 --- a/gazprea/impl/errors.rst +++ b/gazprea/impl/errors.rst @@ -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`` @@ -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 @@ -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`` @@ -155,7 +155,7 @@ 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. @@ -190,7 +190,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`` @@ -213,7 +213,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. :: @@ -312,7 +312,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. diff --git a/gazprea/impl/part_1.rst b/gazprea/impl/part_1.rst index e1833b2..db2509e 100644 --- a/gazprea/impl/part_1.rst +++ b/gazprea/impl/part_1.rst @@ -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. diff --git a/gazprea/impl/part_2.rst b/gazprea/impl/part_2.rst index 8aaf319..fb4da42 100644 --- a/gazprea/impl/part_2.rst +++ b/gazprea/impl/part_2.rst @@ -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. diff --git a/gazprea/spec/built_in_functions.rst b/gazprea/spec/built_in_functions.rst index 3d1fdb0..7032ce5 100644 --- a/gazprea/spec/built_in_functions.rst +++ b/gazprea/spec/built_in_functions.rst @@ -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. diff --git a/gazprea/spec/functions.rst b/gazprea/spec/functions.rst index 5cc1403..946156b 100644 --- a/gazprea/spec/functions.rst +++ b/gazprea/spec/functions.rst @@ -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. diff --git a/gazprea/spec/globals.rst b/gazprea/spec/globals.rst index ee294a4..63b604f 100644 --- a/gazprea/spec/globals.rst +++ b/gazprea/spec/globals.rst @@ -3,7 +3,7 @@ Globals ======= -Valid global scope statements inclulde: +Valid global scope statements include: * Variable Declarations * Struct Declarations diff --git a/gazprea/spec/streams.rst b/gazprea/spec/streams.rst index 610ca35..c788736 100644 --- a/gazprea/spec/streams.rst +++ b/gazprea/spec/streams.rst @@ -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: @@ -145,15 +145,15 @@ must be readable. An ``integer`` from stdin can take any legal format described in the :ref:`integer literal ` 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 ` 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: @@ -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. diff --git a/gazprea/spec/typedef.rst b/gazprea/spec/typedef.rst index 754edad..a533600 100644 --- a/gazprea/spec/typedef.rst +++ b/gazprea/spec/typedef.rst @@ -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: @@ -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. :: diff --git a/gazprea/spec/types/matrix.rst b/gazprea/spec/types/matrix.rst index 00ac607..c9b091f 100644 --- a/gazprea/spec/types/matrix.rst +++ b/gazprea/spec/types/matrix.rst @@ -102,7 +102,7 @@ matrix respectively. For instance: 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: :: diff --git a/gazprea/spec/types/string.rst b/gazprea/spec/types/string.rst index 664f9b7..ebd1b41 100644 --- a/gazprea/spec/types/string.rst +++ b/gazprea/spec/types/string.rst @@ -21,7 +21,7 @@ Declaration A string may be declared with the keyword ``string``. The same rules of :ref:`vector declarations ` also apply to strings, which means -that all lenghts are inferred: +that all lengths are inferred: :: diff --git a/gazprea/spec/types/struct.rst b/gazprea/spec/types/struct.rst index 5a0a424..0a7b086 100644 --- a/gazprea/spec/types/struct.rst +++ b/gazprea/spec/types/struct.rst @@ -27,12 +27,12 @@ and consist of a ```` 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. diff --git a/gazprea/spec/types/vector.rst b/gazprea/spec/types/vector.rst index ff42f8a..d9a3f30 100644 --- a/gazprea/spec/types/vector.rst +++ b/gazprea/spec/types/vector.rst @@ -45,7 +45,7 @@ Those greater raise a runtime ``SizeError``. const vector vec = ['a', 'b', 'c']; const vector ragged_right = [[1.0], [2.0, 2.0]]; // SizeError - const vector paddeded_right = [[1.0, 2.0], [1.0]]; // Padds second element + const vector padded_right = [[1.0, 2.0], [1.0]]; // Pads second element const vector const_vec = vec; From 5ed18d6d8fd4404d5f0ecc0e741f84d76214bf9d Mon Sep 17 00:00:00 2001 From: Drew Date: Mon, 22 Jun 2026 13:14:44 -0400 Subject: [PATCH 2/5] spec: fix typos inside code examples Correct mistakes in example snippets that would mislead readers: the tuple type in errors.rst (integerm integer -> integer, integer), an undefined identifier in string.rst (carry -> carray), a run-on comment (Run-timeerror -> Runtime error), and an erroneously escaped block-comment terminator in matrix.rst (\*/ -> */). --- gazprea/impl/errors.rst | 4 ++-- gazprea/spec/types/matrix.rst | 2 +- gazprea/spec/types/string.rst | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gazprea/impl/errors.rst b/gazprea/impl/errors.rst index 31ffebe..30590b5 100644 --- a/gazprea/impl/errors.rst +++ b/gazprea/impl/errors.rst @@ -240,12 +240,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; diff --git a/gazprea/spec/types/matrix.rst b/gazprea/spec/types/matrix.rst index c9b091f..15c4b1b 100644 --- a/gazprea/spec/types/matrix.rst +++ b/gazprea/spec/types/matrix.rst @@ -97,7 +97,7 @@ 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 diff --git a/gazprea/spec/types/string.rst b/gazprea/spec/types/string.rst index ebd1b41..916ad09 100644 --- a/gazprea/spec/types/string.rst +++ b/gazprea/spec/types/string.rst @@ -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: From b7654ec9eeeb2d1b8c737951161ffd8fdd8f5bd8 Mon Sep 17 00:00:00 2001 From: Drew Date: Mon, 22 Jun 2026 13:15:38 -0400 Subject: [PATCH 3/5] spec: fix inconsistent section heading levels Demote two headings that were marked at the wrong level: the Variable Declarations subsection in globals.rst was underlined as a top-level title (same as the page heading), and Syntax Errors in errors.rst used a deeper underline than its sibling category Compile-time Errors. Both are now second-level headings, matching the surrounding structure. --- gazprea/impl/errors.rst | 2 +- gazprea/spec/globals.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gazprea/impl/errors.rst b/gazprea/impl/errors.rst index 30590b5..de5f3de 100644 --- a/gazprea/impl/errors.rst +++ b/gazprea/impl/errors.rst @@ -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 diff --git a/gazprea/spec/globals.rst b/gazprea/spec/globals.rst index 63b604f..453676f 100644 --- a/gazprea/spec/globals.rst +++ b/gazprea/spec/globals.rst @@ -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 From 4b3ee835abd81c3d8eaf2b6803201167b09de803 Mon Sep 17 00:00:00 2001 From: Drew Date: Mon, 22 Jun 2026 13:16:01 -0400 Subject: [PATCH 4/5] spec: unify 2D array and matrix syntax Use the canonical bracket-chained form everywhere for 2D types and indexing, matching the rest of the matrix documentation: integer[3,3] -> integer[3][3] (expressions), real[3,3] -> real[3][3] (functions), and the M[1, 2] index comment -> M[1][2] (matrix). The comma form was used in only these three places and is inconsistent with the [*][*] / M[i][j] notation defined elsewhere. --- gazprea/spec/expressions.rst | 2 +- gazprea/spec/functions.rst | 2 +- gazprea/spec/types/matrix.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gazprea/spec/expressions.rst b/gazprea/spec/expressions.rst index bde026d..1342e07 100644 --- a/gazprea/spec/expressions.rst +++ b/gazprea/spec/expressions.rst @@ -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: diff --git a/gazprea/spec/functions.rst b/gazprea/spec/functions.rst index 946156b..6beecff 100644 --- a/gazprea/spec/functions.rst +++ b/gazprea/spec/functions.rst @@ -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 */ } diff --git a/gazprea/spec/types/matrix.rst b/gazprea/spec/types/matrix.rst index 15c4b1b..f52cb9c 100644 --- a/gazprea/spec/types/matrix.rst +++ b/gazprea/spec/types/matrix.rst @@ -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. From 676ceb92dceeafb28fd78e3aa37c5450db79c096 Mon Sep 17 00:00:00 2001 From: Drew Date: Mon, 22 Jun 2026 13:16:48 -0400 Subject: [PATCH 5/5] spec: fix broken cross-references Resolve three dangling references. The ssec:errors_sizeErrors label is never defined anywhere in the spec, so remove the two sentences that point to it (in array.rst and errors.rst); the surrounding text already states that SizeError may be raised at compile time or run time. Fill in the empty reference in type_promotion.rst to point at the type-casting section (sec:typeCasting), which defines the conversion semantics being referred to. --- gazprea/impl/errors.rst | 3 +-- gazprea/spec/type_promotion.rst | 2 +- gazprea/spec/types/array.rst | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/gazprea/impl/errors.rst b/gazprea/impl/errors.rst index de5f3de..27ea29b 100644 --- a/gazprea/impl/errors.rst +++ b/gazprea/impl/errors.rst @@ -157,8 +157,7 @@ Here are the compile-time errors your compiler must throw: 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`` diff --git a/gazprea/spec/type_promotion.rst b/gazprea/spec/type_promotion.rst index c5a6325..4d51dbc 100644 --- a/gazprea/spec/type_promotion.rst +++ b/gazprea/spec/type_promotion.rst @@ -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(var)`` means var of type "From type" is converted to type -"toType" using semantics from . +"toType" using semantics from :ref:`sec:typeCasting`. +----------+-----------+---------+-----------+---------+---------------+ | | **To type** | diff --git a/gazprea/spec/types/array.rst b/gazprea/spec/types/array.rst index a0ad9db..25abf00 100644 --- a/gazprea/spec/types/array.rst +++ b/gazprea/spec/types/array.rst @@ -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