Skip to content
/ janet Public
forked from janet-lang/janet

Commit

Permalink
Update copyright date, fix types, remove trailing whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakpakin committed Jan 6, 2019
1 parent ef5eed2 commit 6f3bc3d
Show file tree
Hide file tree
Showing 70 changed files with 210 additions and 290 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018 Calvin Rose
Copyright (c) 2019 Calvin Rose

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The language also bridging bridging to native code written in C, meta-programmin

There is a repl for trying out the language, as well as the ability
to run script files. This client program is separate from the core runtime, so
janet could be embedded into other programs. Try janet in your browser at
janet could be embedded into other programs. Try janet in your browser at
[https://janet-lang.org](https://janet-lang.org).

#
Expand Down Expand Up @@ -51,7 +51,7 @@ Janet makes a good system scripting language, or a language to embed in other pr

## Documentation

Documentation can be found in the doc directory of
Documentation can be found in the doc directory of
the repository. There is an introduction
section contains a good overview of the language.

Expand All @@ -66,7 +66,7 @@ documentation for the core library. For example,
(doc doc)
```
Shows documentation for the doc macro.

To get a list of all bindings in the default
environment, use the `(all-symbols)` function.

Expand Down
4 changes: 2 additions & 2 deletions ctest/array_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand All @@ -24,7 +24,7 @@
#include <assert.h>

int main() {

int i;
JanetArray *array1, *array2;

Expand Down
4 changes: 2 additions & 2 deletions ctest/buffer_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand All @@ -24,7 +24,7 @@
#include <assert.h>

int main() {

int i;
JanetBuffer *buffer1, *buffer2;

Expand Down
6 changes: 3 additions & 3 deletions ctest/number_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -27,7 +27,7 @@

/* Check a subset of numbers against system implementation.
* Note that this depends on the system implementation being correct,
* which may not be the case for old or non complient systems. Also,
* which may not be the case for old or non compliant systems. Also,
* we cannot check against bases other 10. */

/* Compare valid c numbers to system implementation. */
Expand All @@ -42,7 +42,7 @@ static void test_valid_str(const char *str) {
}

int main() {

janet_init();

test_valid_str("1.0");
Expand Down
1 change: 0 additions & 1 deletion ctest/system_test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* Copyright (c) 2018 Calvin Rose
*
Expand Down
6 changes: 3 additions & 3 deletions ctest/table_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand All @@ -24,7 +24,7 @@
#include <assert.h>

int main() {

JanetTable *t1, *t2;

janet_init();
Expand All @@ -39,7 +39,7 @@ int main() {

assert(t1->count == 4);
assert(t1->capacity >= t1->count);

assert(janet_equals(janet_table_get(t1, janet_cstringv("hello")), janet_wrap_integer(2)));
assert(janet_equals(janet_table_get(t1, janet_cstringv("akey")), janet_wrap_integer(5)));
assert(janet_equals(janet_table_get(t1, janet_cstringv("box")), janet_wrap_boolean(0)));
Expand Down
2 changes: 1 addition & 1 deletion doc/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Janet is a dynamic, lightweight programming language with strong functional
capabilities as well as support for imperative programming. It to be used
for short lived scripts as well as for building real programs. It can also
be extended with native code (C modules) for better performance and interfacing with
existing software. Janet takes ideas from Lua, Scheme, Racket, Clojure, Smalltalk, Erlang, Arc, and
existing software. Janet takes ideas from Lua, Scheme, Racket, Clojure, Smalltalk, Erlang, Arc, and
a whole bunch of other dynamic languages.
18 changes: 9 additions & 9 deletions doc/Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ notation with a radix besides 10, use the `&` symbol to indicate the exponent ra
## Arithmetic Functions

Besides the 5 main arithmetic functions, janet also supports a number of math functions
taken from the C library `<math.h>`, as well as bitwise operators that behave like they
taken from the C library `<math.h>`, as well as bit-wise operators that behave like they
do in C or Java. Functions like `math/sin`, `math/cos`, `math/log`, and `math/exp` will
behave as expected to a C programmer. They all take either 1 or 2 numeric arguments and
return a real number (never an integer!) Bitwise functions are all prefixed with b.
Thet are `bnot`, `bor`, `bxor`, `band`, `blshift`, `brshift`, and `brushift`. Bitwise
return a real number (never an integer!) Bit-wise functions are all prefixed with b.
They are `bnot`, `bor`, `bxor`, `band`, `blshift`, `brshift`, and `brushift`. Bit-wise
functions only work on integers.

# Strings, Keywords and Symbols
Expand Down Expand Up @@ -321,16 +321,16 @@ there relationship to each other.
| ---------- | ------- | --------------- |
| Indexed | Array | Tuple |
| Dictionary | Table | Struct |
| Byteseq | Buffer | String (Symbol) |
| Bytes | Buffer | String |

Indexed types are linear lists of elements than can be accessed in constant time with an integer index.
Indexed types are backed by a single chunk of memory for fast access, and are indexed from 0 as in C.
Dictionary types associate keys with values. The difference between dictionaries and indexed types
is that dictionaries are not limited to integer keys. They are backed by a hashtable and also offer
constant time lookup (and insertion for the mutable case).
Finally, the 'byteseq' abstraction is any type that contains a sequence of bytes. A byteseq associates
Finally, the 'bytes' abstraction is any type that contains a sequence of bytes. A 'bytes' value or byteseq associates
integer keys (the indices) with integer values between 0 and 255 (the byte values). In this way,
they behave much like Arrays and Tuples. However, one cannot put non integer values into a byteseq.
they behave much like Arrays and Tuples. However, one cannot put non integer values into a byteseq

```lisp
(def mytuple (tuple 1 2 3))
Expand Down Expand Up @@ -544,7 +544,7 @@ control is returned to the calling fiber. The parent fiber must then check what
fiber is in to differentiate errors from return values from user defined signals.

To create a fiber, user the `fiber/new` function. The fiber constructor take one or two arguments.
the first, necessary argument is the function that the fiber will execute. This function must accept
The first, necessary argument is the function that the fiber will execute. This function must accept
an arity of zero. The next optional argument is a collection of flags checking what kinds of
signals to trap and return via `resume`. This is useful so
the programmer does not need to handle all different kinds of signals from a fiber. Any un-trapped signals
Expand Down Expand Up @@ -639,7 +639,7 @@ using janet's builtin quasiquoting facilities.
```

This is functionally identical to our previous version `defn2`, but written in such
a way that the macro output is more clear. The leading backtick is shorthand for the
a way that the macro output is more clear. The leading tilde `~` is shorthand for the
`(quasiquote x)` special form, which is like `(quote x)` except we can unquote
expressions inside it. The comma in front of `name` and `args` is an unquote, which
allows us to put a value in the quasiquote. Without the unquote, the symbol \'name\'
Expand Down Expand Up @@ -720,7 +720,7 @@ to be 10. The problem is the reuse of the symbol x inside the macro, which overs
binding.

Janet provides a general solution to this problem in terms of the `(gensym)` function, which returns
a symbol which is guarenteed to be unique and not collide with any symbols defined previously. We can define
a symbol which is guaranteed to be unique and not collide with any symbols defined previously. We can define
our macro once more for a fully correct macro.

```lisp
Expand Down
13 changes: 6 additions & 7 deletions doc/Parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ false
Janet symbols are represented a sequence of alphanumeric characters
not starting with a digit or a colon. They can also contain the characters
\!, @, $, \%, \^, \&, \*, -, \_, +, =, \|, \~, :, \<, \>, ., \?, \\, /, as
well as any Unicode codepoint not in the ascii range.
well as any Unicode codepoint not in the ASCII range.

By convention, most symbols should be all lower case and use dashes to connect words
(sometimes called kebab case).
Expand Down Expand Up @@ -120,7 +120,7 @@ delimited string. A string can also be define to start with a certain number of
backquotes, and will end the same number of backquotes. Long strings
do not contain escape sequences; all bytes will be parsed literally until
ending delimiter is found. This is useful
for definining multiline strings with literal newline characters, unprintable
for defining multi-line strings with literal newline characters, unprintable
characters, or strings that would otherwise require many escape sequences.

```
Expand Down Expand Up @@ -155,7 +155,7 @@ the buffer must be prefixed with the '@' character.

Tuples are a sequence of white space separated values surrounded by either parentheses
or brackets. The parser considers any of the characters ASCII 32, \\0, \\f, \\n, \\r or \\t
to be whitespace.
to be white-space.

```
(do 1 2 3)
Expand All @@ -173,7 +173,7 @@ Arrays are the same as tuples, but have a leading @ to indicate mutability.

## Structs

Structs are represented by a sequence of whitespace delimited key value pairs
Structs are represented by a sequence of white-space delimited key value pairs
surrounded by curly braces. The sequence is defined as key1, value1, key2, value2, etc.
There must be an even number of items between curly braces or the parser will
signal a parse error. Any value can be a key or value. Using nil as a key or
Expand Down Expand Up @@ -202,10 +202,9 @@ that they are mutable.
## Comments

Comments begin with a \# character and continue until the end of the line.
There are no multiline comments. For ricm multiline comments, use a
string literal.
There are no multi-line comments.

## Shorthands
## Shorthand

Often called reader macros in other lisps, Janet provides several shorthand
notations for some forms.
Expand Down
2 changes: 1 addition & 1 deletion doc/Specials.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ The r-value can be any expression, and the l-value should be a bound var.

Similar to `(quote x)`, but allows for unquoting within x. This makes quasiquote useful for
writing macros, as a macro definition often generates a lot of templated code with a
few custom values. The shorthand for quasiquote is a leading tilda `~` before a form. With
few custom values. The shorthand for quasiquote is a leading tilde `~` before a form. With
that form, `(unquote x)` will evaluate and insert x into the unquote form. The shorthand for
`(unquote x)` is `,x`.

Expand Down
10 changes: 5 additions & 5 deletions doc/The-Janet-Abstract-Machine-Bytecode.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ features.
A Janet Fiber is the type used to represent multiple concurrent processes
in janet. It is basically a wrapper around the idea of a stack. The stack is
divided into a number of stack frames (`JanetStackFrame *` in C), each of which
contains information such as the function that created the stack frame,
contains information such as the function that created the stack frame,
the program counter for the stack frame, a pointer to the previous frame,
and the size of the frame. Each stack frame also is paired with a number
registers.
Expand Down Expand Up @@ -49,7 +49,7 @@ Frame -2
...
...
...
-----
-----
Bottom of stack
```

Expand Down Expand Up @@ -137,7 +137,7 @@ by their short names as presented to the assembler rather than their numerical v
Each instruction is also listed with a signature, which are the arguments the instruction
expects. There are a handful of instruction signatures, which combine the arity and type
of the instruction. The assembler does not
do any typechecking per closure, but does prevent jumping to invalid instructions and
do any type-checking per closure, but does prevent jumping to invalid instructions and
failure to return or error.

### Notation
Expand All @@ -148,7 +148,7 @@ failure to return or error.

* Some operators in the description have the suffix 'i' or 'r'. These indicate
that these operators correspond to integers or real numbers only, respectively. All
bitwise operators and bit shifts only work with integers.
bit-wise operators and bit shifts only work with integers.

* The `>>>` indicates unsigned right shift, as in Java. Because all integers in janet are
signed, we differentiate the two kinds of right bit shift.
Expand All @@ -159,7 +159,7 @@ failure to return or error.

| Instruction | Signature | Description |
| ----------- | --------------------------- | --------------------------------- |
| `add` | `(add dest lhs rhs)` | $dest = $lhs + $rhs |
| `add` | `(add dest lhs rhs)` | $dest = $lhs + $rhs |
| `addim` | `(addim dest lhs im)` | $dest = $lhs + im |
| `band` | `(band dest lhs rhs)` | $dest = $lhs & $rhs |
| `bnot` | `(bnot dest operand)` | $dest = ~$operand |
Expand Down
4 changes: 2 additions & 2 deletions janet.1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ janet \- run the janet language abstract machine
[\fB\-\-\fR]
.IR files ...
.SH DESCRIPTION
Janet is a functional and imperative programming language and bytecode interpreter.
Janet is a functional and imperative programming language and bytecode interpreter.
It is a modern lisp, but lists are replaced by other data structures with better utility
and performance (arrays, tables, structs, tuples). The language also bridging bridging
to native code written in C, meta-programming with macros, and bytecode assembly.
Expand All @@ -19,7 +19,7 @@ into other programs. Try janet in your browser at https://janet-lang.org.

Implemented in mostly standard C99, janet runs on Windows, Linux and macOS.
The few features that are not standard C99 (dynamic library loading, compiler
specific optimizations), are fairly straight forward. Janet can be easily ported to
specific optimizations), are fairly straight forward. Janet can be easily ported to
most new platforms.
.SH DOCUMENTATION

Expand Down
2 changes: 1 addition & 1 deletion src/core/abstract.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down
6 changes: 3 additions & 3 deletions src/core/array.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -197,7 +197,7 @@ static Janet cfun_insert(int32_t argc, Janet *argv) {
JanetArray *array = janet_getarray(argv, 0);
int32_t at = janet_getinteger(argv, 1);
if (at < 0) {
at = array->count + at + 1;
at = array->count + at + 1;
}
if (at < 0 || at > array->count)
janet_panicf("insertion index %d out of range [0,%d]", at, array->count);
Expand All @@ -215,7 +215,7 @@ static Janet cfun_insert(int32_t argc, Janet *argv) {
static const JanetReg cfuns[] = {
{"array/new", cfun_new,
JDOC("(array/new capacity)\n\n"
"Creates a new empty array with a preallocated capacity. The same as "
"Creates a new empty array with a pre-allocated capacity. The same as "
"(array) but can be more efficient if the maximum size of an array is known.")
},
{"array/pop", cfun_pop,
Expand Down
8 changes: 4 additions & 4 deletions src/core/asm.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -55,7 +55,7 @@ struct JanetAssembler {
JanetTable defs; /* symbol -> funcdefs index */
};

/* Janet opcode descriptions in lexographic order. This
/* Janet opcode descriptions in lexicographic order. This
* allows a binary search over the elements to find the
* correct opcode given a name. This works in reasonable
* time and is easier to setup statically than a hash table or
Expand Down Expand Up @@ -742,7 +742,7 @@ JanetAssembleResult janet_asm(Janet source, int flags) {

/* Disassembly */

/* Find the deinfintion of an instruction given the instruction word. Return
/* Find the definition of an instruction given the instruction word. Return
* NULL if not found. */
static const JanetInstructionDef *janet_asm_reverse_lookup(uint32_t instr) {
size_t i;
Expand Down Expand Up @@ -783,7 +783,7 @@ static Janet tup4(Janet w, Janet x, Janet y, Janet z) {
return janet_wrap_tuple(janet_tuple_end(tup));
}

/* Given an argument, convert it to the appriate integer or symbol */
/* Given an argument, convert it to the appropriate integer or symbol */
Janet janet_asm_decode_instruction(uint32_t instr) {
const JanetInstructionDef *def = janet_asm_reverse_lookup(instr);
Janet name;
Expand Down
2 changes: 1 addition & 1 deletion src/core/buffer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down
2 changes: 1 addition & 1 deletion src/core/bytecode.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Calvin Rose
* Copyright (c) 2019 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down
Loading

0 comments on commit 6f3bc3d

Please sign in to comment.