Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for guide text #611

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion impls/tests/step1_read_print.mal
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ false
;=>(with-meta [1 2 3] {"a" 1})


;; Non alphanumerice characters in strings
;; Non alphanumeric characters in strings
;;; \t is not specified enough to be tested
"\n"
;=>"\n"
Expand Down
62 changes: 31 additions & 31 deletions process/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ expression support.

* Add a `reader.qx` file to hold functions related to the reader.

* If the target language has objects types (OOP), then the next step
* If the target language has object types (OOP), then the next step
is to create a simple stateful Reader object in `reader.qx`. This
object will store the tokens and a position. The Reader object will
have two methods: `next` and `peek`. `next` returns the token at
Expand Down Expand Up @@ -368,7 +368,7 @@ expression support.

* Add the function `read_list` to `reader.qx`. This function will
repeatedly call `read_form` with the Reader object until it
encounters a ')' token (if it reach EOF before reading a ')' then
encounters a ')' token (if it reaches EOF before reading a ')' then
that is an error). It accumulates the results into a List type. If
your language does not have a sequential data type that can hold mal
type values you may need to implement one (in `types.qx`). Note
Expand All @@ -384,7 +384,7 @@ expression support.
the other fundamental mal types: nil, true, false, and string. The
remaining scalar mal type, keyword does not
need to be implemented until step A (but can be implemented at any
point between this step and that). BTW, symbols types are just an
point between this step and that). BTW, symbol types are just an
object that contains a single string name value (some languages have
symbol types already).

Expand Down Expand Up @@ -522,7 +522,7 @@ functionality to the evaluator (`EVAL`).
Compare the pseudocode for step 1 and step 2 to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step1_read_print.txt ../process/step2_eval.txt
diff -u ../process/step1_read_print.txt ../process/step2_eval.txt
```

* Copy `step1_read_print.qx` to `step2_eval.qx`.
Expand Down Expand Up @@ -574,7 +574,7 @@ Try some simple expressions:
* `(+ 2 (* 3 4))` -> `14`

The most likely challenge you will encounter is how to properly call
a function references using an arguments list.
a function reference using an arguments list.

Now go to the top level, run the step 2 tests and fix the errors.
```
Expand Down Expand Up @@ -620,7 +620,7 @@ chain).
Compare the pseudocode for step 2 and step 3 to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step2_eval.txt ../process/step3_env.txt
diff -u ../process/step2_eval.txt ../process/step3_env.txt
```

* Copy `step2_eval.qx` to `step3_env.qx`.
Expand Down Expand Up @@ -739,7 +739,7 @@ In some Lisps, this special form is named "lambda".
Compare the pseudocode for step 3 and step 4 to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step3_env.txt ../process/step4_if_fn_do.txt
diff -u ../process/step3_env.txt ../process/step4_if_fn_do.txt
```

* Copy `step3_env.qx` to `step4_if_fn_do.qx`.
Expand Down Expand Up @@ -802,7 +802,7 @@ Try out the basic functionality you have implemented:

* Add the following functions to `core.ns`:
* `prn`: call `pr_str` on the first parameter with `print_readably`
set to true, prints the result to the screen and then return
set to true, print the result to the screen and then return
`nil`. Note that the full version of `prn` is a deferrable below.
* `list`: take the parameters and return them as a list.
* `list?`: return true if the first parameter is a list, false
Expand Down Expand Up @@ -846,7 +846,7 @@ from a neat toy to a full featured language.
call the `rep` function with this string:
"(def! not (fn* (a) (if a false true)))".

* Implement the strings functions in `core.qx`. To implement these
* Implement the string functions in `core.qx`. To implement these
functions, you will need to implement the string support in the
reader and printer (deferrable section of step 1). Each of the string
functions takes multiple mal values, prints them (`pr_str`) and
Expand Down Expand Up @@ -890,7 +890,7 @@ iteration.
Compare the pseudocode for step 4 and step 5 to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step4_if_fn_do.txt ../process/step5_tco.txt
diff -u ../process/step4_if_fn_do.txt ../process/step5_tco.txt
```

* Copy `step4_if_fn_do.qx` to `step5_tco.qx`.
Expand Down Expand Up @@ -930,15 +930,15 @@ diff -urp ../process/step4_if_fn_do.txt ../process/step5_tco.txt

* The default "apply"/invoke case of `EVAL` must now be changed to
account for the new object/structure returned by the `fn*` form.
Continue to call `eval_ast` on `ast`. The first element of the
Continue to call `eval_ast` on `ast`. The first element of the
result of `eval_ast` is `f` and the remaining elements are in `args`.
Switch on the type of `f`:
* regular function (not one defined by `fn*`): apply/invoke it as
before (in step 4).
* a `fn*` value: set `ast` to the `ast` attribute of `f`. Generate
a new environment using the `env` and `params` attributes of `f`
as the `outer` and `binds` arguments and `args` as the `exprs`
argument. Set `env` to the new environment. Continue at the
as the `outer` and `binds` arguments and `args` as the `exprs`
argument. Set `env` to the new environment. Continue at the
beginning of the loop.

Run some manual tests from previous steps to make sure you have not
Expand Down Expand Up @@ -980,7 +980,7 @@ holding off on that you will need to go back and do so.
Compare the pseudocode for step 5 and step 6 to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step5_tco.txt ../process/step6_file.txt
diff -u ../process/step5_tco.txt ../process/step6_file.txt
```

* Copy `step5_tco.qx` to `step6_file.qx`.
Expand Down Expand Up @@ -1054,7 +1054,7 @@ You'll need to add 5 functions to the core namespace to support atoms:

Optionally, you can add a reader macro `@` which will serve as a short form for
`deref`, so that `@a` is equivalent to `(deref a)`. In order to do that, modify
the conditional in reader `read_form` function and add a case which deals with
the conditional in reader function `read_form` and add a case which deals with
the `@` token: if the token is `@` (at sign) then return a new list that
contains the symbol `deref` and the result of reading the next form
(`read_form`).
Expand Down Expand Up @@ -1119,7 +1119,7 @@ value that it evaluates to. Likewise with lists. For example, consider
the following:

* `(prn abc)`: this will lookup the symbol `abc` in the current
evaluation environment and print it. This will result in error if
evaluation environment and print it. This will result in an error if
`abc` is not defined.
* `(prn (quote abc))`: this will print "abc" (prints the symbol
itself). This will work regardless of whether `abc` is defined in
Expand Down Expand Up @@ -1152,7 +1152,7 @@ manifest when it is used together with macros (in the next step).
Compare the pseudocode for step 6 and step 7 to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step6_file.txt ../process/step7_quote.txt
diff -u ../process/step6_file.txt ../process/step7_quote.txt
```

* Copy `step6_file.qx` to `step7_quote.qx`.
Expand Down Expand Up @@ -1182,7 +1182,7 @@ Mal borrows most of its syntax and feature-set).
following conditional.
- If `ast` is a list starting with the "unquote" symbol, return its
second element.
- If `ast` is a list failing previous test, the result will be a
- If `ast` is a list failing the previous test, the result will be a
list populated by the following process.

The result is initially an empty list.
Expand Down Expand Up @@ -1223,7 +1223,7 @@ Mal borrows most of its syntax and feature-set).
of the `quasiquote` internal function.

* Add the `quasiquote` special form.
This form does the same than `quasiquoteexpand`,
This form does the same as `quasiquoteexpand`,
but evaluates the result in the current environment before returning it,
either by recursively calling `EVAL` with the result and `env`,
or by assigning `ast` with the result and continuing execution at
Expand All @@ -1247,8 +1247,8 @@ macros.
short-hand syntaxes are known as reader macros because they allow us
to manipulate mal code during the reader phase. Macros that run
during the eval phase are just called "macros" and are described in
the next section. Expand the conditional with reader `read_form`
function to add the following four cases:
the next section. Expand the conditional in reader function
`read_form` to add the following four cases:
* token is "'" (single quote): return a new list that contains the
symbol "quote" and the result of reading the next form
(`read_form`).
Expand Down Expand Up @@ -1296,7 +1296,7 @@ the mal language itself.
Compare the pseudocode for step 7 and step 8 to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step7_quote.txt ../process/step8_macros.txt
diff -u ../process/step7_quote.txt ../process/step8_macros.txt
```

* Copy `step7_quote.qx` to `step8_macros.qx`.
Expand Down Expand Up @@ -1360,7 +1360,7 @@ recommend a couple of approaches:
* Add a debug print statement to the top of your main `eval` function
(inside the TCO loop) to print the current value of `ast` (hint use
`pr_str` to get easier to debug output). Pull up the step8
implementation from another language and uncomment its `eval`
implementation from another language and instrument its `eval`
function (yes, I give you permission to violate the rule this once).
Run the two side-by-side. The first difference is likely to point to
the bug.
Expand Down Expand Up @@ -1388,11 +1388,11 @@ implementation. Let us continue!
as arguments, returns the element of the list at the given index.
If the index is out of range, this function raises an exception.
* `first`: this function takes a list (or vector) as its argument
and return the first element. If the list (or vector) is empty or
and returns the first element. If the list (or vector) is empty or
is `nil` then `nil` is returned.
* `rest`: this function takes a list (or vector) as its argument and
returns a new list containing all the elements except the first. If
the list (or vector) is empty or is `nil` then `()` (empty list)
the list (or vector) is empty or is `nil` then `()` (empty list)
is returned.

* In the main program, call the `rep` function with the following
Expand Down Expand Up @@ -1421,7 +1421,7 @@ functional programming pedigree of your implementation by adding the
Compare the pseudocode for step 8 and step 9 to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step8_macros.txt ../process/step9_try.txt
diff -u ../process/step8_macros.txt ../process/step9_try.txt
```

* Copy `step8_macros.qx` to `step9_try.qx`.
Expand Down Expand Up @@ -1480,7 +1480,7 @@ diff -urp ../process/step8_macros.txt ../process/step9_try.txt
function against every element of the list (or vector) one at
a time and returns the results as a list.

* Add some type predicates core functions. In Lisp, predicates are
* Add some type predicate core functions. In Lisp, predicates are
functions that return true/false (or true value/nil) and typically
end in "?" or "p".
* `nil?`: takes a single argument and returns true (mal true value)
Expand Down Expand Up @@ -1575,7 +1575,7 @@ implementation to self-host.
Compare the pseudocode for step 9 and step A to get a basic idea of
the changes that will be made during this step:
```
diff -urp ../process/step9_try.txt ../process/stepA_mal.txt
diff -u ../process/step9_try.txt ../process/stepA_mal.txt
```

* Copy `step9_try.qx` to `stepA_mal.qx`.
Expand Down Expand Up @@ -1608,7 +1608,7 @@ make "test^quux^stepA"

Once you have passed all the non-optional step A tests, it is time to
try self-hosting. Run your step A implementation as normal, but use
the file argument mode you added in step 6 to run a each of the step
the file argument mode you added in step 6 to run each step
from the mal implementation:
```
./stepA_mal.qx ../mal/step1_read_print.mal
Expand Down Expand Up @@ -1672,7 +1672,7 @@ implementation.
result of reading the next next form (2nd argument) (`read_form`) and the
next form (1st argument) in that order
(metadata comes first with the ^ macro and the function second).
* If you implemented as `defmacro!` to mutate an existing function
* If you implemented `defmacro!` as mutating an existing function
without copying it, you can now use the function copying mechanism
used for metadata to make functions immutable even in the
defmacro! case...
Expand All @@ -1699,7 +1699,7 @@ implementation.
* `seq`: takes a list, vector, string, or nil. If an empty list,
empty vector, or empty string ("") is passed in then nil is
returned. Otherwise, a list is returned unchanged, a vector is
converted into a list, and a string is converted to a list that
converted into a list, and a string is converted to a list
containing the original string split into single character
strings.
* For interop with the target language, add this core function:
Expand Down