Skip to content

Commit

Permalink
Camelcase
Browse files Browse the repository at this point in the history
  • Loading branch information
Seggan committed Nov 21, 2023
1 parent 3899bac commit 944d5d7
Show file tree
Hide file tree
Showing 27 changed files with 138 additions and 170 deletions.
32 changes: 0 additions & 32 deletions docs/index.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,6 @@ This will create a JAR file in `app/build/libs` that can be run with `java -jar

@h2 Changelog

@h3 { v1.2.2 }
[
{ Nothing new, just configured Gradle to publish }
]

@h3 { v1.2.1 }
[
{ Fixed `in` giving wrong result }
]

@h3 { v1.2.0 }
[
{ Added a ton of functions to `path` },
{ Added some functions to tables and lists },
{ Fixed `import` not caching to `package.loaded` },
{ Finally documented everything }
]

@h3 { v1.1.0 }
[
{ `.` now behaves like `:` when used with a function that has a `self` argument },
{ Removed `:` operator },
{ Added the `math` module },
{ Moved the `path` module from the core library to the standard library },
{ Added `import` }
]

@h3 { v1.0.0 }
[
{ Initial release }
]

@h2 Credits

Metis is made by @href(`https://github.com/Seggan`) Seggan.
Expand Down
6 changes: 3 additions & 3 deletions docs/lang/core/coroutine.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ If `args` is not given, the function will be called without arguments.

@h2 { Member functions }

@h3 { last_result(self): string }
@h3 { lastResult(self): string }
Returns the last thing returned by `step`.

@h3 { last_yielded(self): any }
@h3 { lastYielded(self): any }
Returns the last thing yielded by the coroutine, if any.

@h3 { run(self): null }
Performs `step` until the coroutine returns something other than `continue`.

@h3 { run_at_most(self, n: number): null }
@h3 { runAtMost(self, n: number): null }
Performs `step` at most `n` times or until the coroutine returns something other than `continue`.

@h3 { step(self): string }
Expand Down
6 changes: 3 additions & 3 deletions docs/lang/core/index.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ If the prompt is `null`, then no prompt is printed. Returns the line of text ent

@h3 { iter(value: any): any }
Returns an iterator for the given value. Requires the `__iter__` metamethod to be defined on the value.
The iterator must have the `has_next(self): boolean` and the `next(self): any` methods defined.
The iterator must have the `hasNext(self): boolean` and the `next(self): any` methods defined.

@h3 { len(value: any): number }
Returns the length of the value. Requires the `__len__` metamethod to be defined on the value.

@h3 { load_chunk(chunk: string): callable }
@h3 { loadChunk(chunk: string): callable }
Loads the given Metis code as a callable function. Returns the function.

@h3 { print(value: any): null }
Expand All @@ -49,7 +49,7 @@ Returns the type of the value as a string. Can be one of the following:
`unknown`
]

@h3 { with_metatable(value: any, metatable: table): any }
@h3 { withMetatable(value: any, metatable: table): any }
Sets the metatable of the value to the given table, and returns the value.

@h3 { yield(value: any): null }
Expand Down
14 changes: 7 additions & 7 deletions docs/lang/core/io.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Returns a reference to the standard input stream.
@h3 { stdout(): native }
Returns a reference to the standard output stream.

@h1 { Submodule `in_stream` }
@h1 { Submodule `inStream` }

This submodule provides a set of functions for manipulating input streams. It is also the
metatable for input streams.
Expand All @@ -32,20 +32,20 @@ Reads a sequence of bytes from the stream into the buffer. Returns the number of
If buffer is not provided or is `null`, the function reads and returns a single byte. Returns
`null` if the end of the stream is reached.

@h3 { read_all(self): bytes }
@h3 { readAll(self): bytes }
Reads all bytes from the stream and returns them.

@h3 { read_line(self): string }
@h3 { readLine(self): string }
Reads a line from the stream and returns it.

@h3 { read_text(self): string }
@h3 { readText(self): string }
Reads all text from the stream and returns it.

@h3 { use(self, f: callable\[native -> any\]): any }
Calls the function `f` with the stream as its argument and returns the result. The stream is
closed after the function returns, even if it throws an error.

@h1 { Submodule `out_stream` }
@h1 { Submodule `outStream` }

This submodule provides a set of functions for manipulating output streams. It is also the
metatable for output streams.
Expand All @@ -66,10 +66,10 @@ the function writes at most `len` bytes starting from the byte at offset `off`.
not provided, the function starts writing from the first byte in the buffer. If `len` is not
provided, the function writes to the end of the buffer.

@h3 { write_line(self, line: string): null }
@h3 { writeLine(self, line: string): null }
Writes a line to the stream.

@h3 { write_text(self, text: string): null }
@h3 { writeText(self, text: string): null }
Writes text to the stream.

@h3 { use(self, f: callable\[native -> any\]): any }
Expand Down
2 changes: 1 addition & 1 deletion docs/lang/core/list.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ separator.
@h3 { remove(self, value: any): null }
Removes the first occurrence of the given value from the list.

@h3 { remove_at(self, index: number): any }
@h3 { removeAt(self, index: number): any }
Removes the element at the given index from the list and returns it.

@h3 { reverse(self): list }
Expand Down
4 changes: 2 additions & 2 deletions docs/lang/core/number.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ It is the metatable for all numbers.
@h3 { inf: number }
The infinity value as defined by IEEE 754.

@h3 { neg_inf: number }
@h3 { negInf: number }
The negative infinity value as defined by IEEE 754.

@h3 { nan: number }
Expand All @@ -28,7 +28,7 @@ Parse a string into a number with a given radix. The radix must be between 2 and
@h3 { char(self): string }
Convert a number to its character representation.

@h3 { string_with_radix(self, radix: number): string }
@h3 { stringWithRadix(self, radix: number): string }
Convert a number to a string with a given radix. The radix must be between 2 and 36.

@h2 Metamethods
Expand Down
8 changes: 4 additions & 4 deletions docs/lang/core/string.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ is implementation-defined.

@h2 { Member functions }

@h3 { char_code(self): number }
@h3 { charCode(self): number }
Get the character code of the first character in the string.

@h3 { encode(self, encoding: string = "UTF-8"): bytes }
Encode the string using the specified encoding. The default encoding is UTF-8.

@h3 { equal_ignore_case(self, other: string): boolean }
@h3 { equalIgnoreCase(self, other: string): boolean }
Compare two strings for equality, ignoring case.

@h3 { remove(self, start: number, end: number \| null): string }
Expand Down Expand Up @@ -83,10 +83,10 @@ Clear the builder.
@h3 { delete(self, start: number, end: number): self }
Delete a range of characters from the builder from `start` to `end` (exclusive).

@h3 { delete_at(self, index: number): self }
@h3 { deleteAt(self, index: number): self }
Delete a character from the builder at the specified index.

@h3 { delete_last(self, count: number): self }
@h3 { deleteLast(self, count: number): self }
Delete the last `count` characters from the builder.

@h2 Metamethods
Expand Down
22 changes: 11 additions & 11 deletions docs/lang/index.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ Functions can also have @i upvalues, which are variables that are from an enclos
@metis ```
let x = 5

fn print_x()
fn printX()
print(x)
end

print_x() // 5
printX() // 5
```

Upvalues can also be mutated:

@metis ```
let x = 5

fn add_to_x(y)
fn addToX(y)
x = x + y
end

add_to_x(5)
addToX(5)
print(x) // 10
```

Expand Down Expand Up @@ -101,11 +101,11 @@ a self function from a table, the table is passed as the first argument:
@metis ```
let x = { "a" = 1, "b" = 2 }

fn x.get_a(self)
fn x.getA(self)
return self.a
end

print(x.get_a()) // 1
print(x.getA()) // 1
```

@h2 { Anonymous Functions }
Expand Down Expand Up @@ -415,9 +415,9 @@ end
```

All iterables implement the `__iter__` metamethod, which returns an iterator. The iterator implements
the `next` and `has_next` metamethods (note the absence of underscores). `next` returns the next value,
and `has_next` returns `true` if there are more values, and `false` otherwise. The `for` loop calls
`next` (and assigns it to the loop variable) until `has_next` returns `false`.
the `next` and `hasNext` metamethods (note the absence of underscores). `next` returns the next value,
and `hasNext` returns `true` if there are more values, and `false` otherwise. The `for` loop calls
`next` (and assigns it to the loop variable) until `hasNext` returns `false`.

@h2 { Try Statements }

Expand Down Expand Up @@ -473,15 +473,15 @@ Metis has a module system similar to Python. Modules have the same name as the f
All globals in the module are part of its @i exports. Modules are loaded
with the `import` statement:

@metis `import module_name`
@metis `import moduleName`

This will load the module as a table and assign it to a variable with the same name as the module. The
module table will have the same members as the modules exports, or globals in the module. For example, if
the module is called `foo`, it will be assigned to a variable called `foo`.

Another thing you can do is @i {global imports} with `global import`:

@metis `global import module_name`
@metis `global import moduleName`

This will load the module and assign it to a global variable with the same name as the module. This
can be used for implementing transient modules as such:
Expand Down
8 changes: 4 additions & 4 deletions docs/lang/std/os.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ The `os` module provides functions for interacting with the operating system.

@h2 { Free functions }

@h3 { get_cwd(): string }
@h3 { getCwd(): string }
Returns the current working directory as a string.

@h3 { get_env(name: string): string \| null }
@h3 { getEnv(name: string): string \| null }
Gets the value of an environment variable by providing its name as a string. Returns the value as a
string if the variable is found, or `null` if the variable is not set.

@h3 { set_cwd(path: string): void }
@h3 { setCwd(path: string): void }
Sets the current working directory to the specified absolute path. Raises `IOError` if the provided path
is not absolute.

@h3 { set_env(name: string, value: string): void }
@h3 { setEnv(name: string, value: string): void }
Sets an environment variable with the provided name and value as strings.
30 changes: 15 additions & 15 deletions docs/lang/std/path.papyri
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,41 @@ The path separator for the current platform. This is either `/` or `\`.
@h3 { absolute(path: string): string }
Returns the absolute path of the given path.

@h3 { file_name(path: string): string }
@h3 { fileName(path: string): string }
Returns the filename of the given path.

@h3 { copy(from: string, to: string): null }
Copies the file at the given path `from` to the given path `to`.

@h3 { create_dir(path: string): string }
@h3 { createDir(path: string): string }
Creates a directory at the given path and returns the path of the created directory.

@h3 { create_dirs(path: string): string }
@h3 { createDirs(path: string): string }
Creates a directory at the given path and all parent directories that do not exist yet. Returns
the path of the created directory.

@h3 { delete(path: string): null }
Deletes the file or directory at the given path. Directories must be empty.

@h3 { delete_recursive(path: string): null }
@h3 { deleteRecursive(path: string): null }
Deletes the file or directory at the given path recursively.

@h3 { exists(path: string): boolean }
Returns a boolean value indicating whether the file or directory at the given path exists.

@h3 { is_absolute(path: string): boolean }
@h3 { isAbsolute(path: string): boolean }
Returns a boolean value indicating whether the given path is absolute.

@h3 { is_dir(path: string): boolean }
@h3 { isDir(path: string): boolean }
Returns a boolean value indicating whether the given path points to a directory.

@h3 { is_file(path: string): boolean }
@h3 { isFile(path: string): boolean }
Returns a boolean value indicating whether the given path points to a file.

@h3 { is_hidden(path: string): boolean }
@h3 { isHidden(path: string): boolean }
Returns a boolean value indicating whether the given path is hidden.

@h3 { is_symlink(path: string): boolean }
@h3 { isSymlink(path: string): boolean }
Returns a boolean value indicating whether the given path is a symbolic link.

@h3 { list(path: string): list\[string\] }
Expand All @@ -63,19 +63,19 @@ Moves the file at the given path `from` to the given path `to`.
@h3 { normalize(path: string): string }
Normalizes the given path and returns the normalized path as a string.

@h3 { open_read(path: string): native }
@h3 { openRead(path: string): native }
Opens the file at the given path for reading and returns an input stream.

@h3 { open_write(path: string): native }
@h3 { openWrite(path: string): native }
Opens the file at the given path for writing and returns an output stream.

@h3 { parent(path: string): string }
Returns the parent directory of the given path.

@h3 { read_all(path: string): bytes }
@h3 { readAll(path: string): bytes }
Reads the entire file at the given path and returns the contents as a byte array.

@h3 { read_text(path: string): string }
@h3 { readText(path: string): string }
Reads the entire file at the given path and returns the contents as a string.

@h3 { resolve(base: string, other: string): string }
Expand All @@ -84,8 +84,8 @@ Resolves the given path `other` against the base path `base` and returns the res
@h3 { root(path: string): string }
Returns the root of the given path.

@h3 { write_all(path: string, data: bytes) }
@h3 { writeAll(path: string, data: bytes) }
Writes the given byte array to the file at the given path.

@h3 { write_text(path: string, data: string) }
@h3 { writeText(path: string, data: string) }
Writes the given string to the file at the given path.
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class Compiler private constructor(
+start
+Insn.CopyUnder(0)
+Insn.CopyUnder(0)
+Insn.Push("has_next")
+Insn.Push("hasNext")
+Insn.Index
+Insn.Call(1, true)
+Insn.RawJumpIf(end, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class State(parentState: State? = null) {
io["stderr"] = zeroArgFunction { wrapOutStream(stderr) }
io["stdin"] = zeroArgFunction { wrapInStream(stdin) }

io["in_stream"] = inStreamMetatable
io["out_stream"] = outStreamMetatable
io["inStream"] = inStreamMetatable
io["outStream"] = outStreamMetatable
globals["io"] = io

globals["string"] = Value.String.metatable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class Coroutine(state: State, chunk: Chunk.Instance, args: Value.List) : Value {
result.name.lowercase().metisValue()
}
}
table["last_result"] = oneArgFunction { self ->
table["lastResult"] = oneArgFunction { self ->
self.convertTo<Coroutine>().lastResult.name.lowercase().metisValue()
}
table["last_yielded"] = oneArgFunction { self ->
table["lastYielded"] = oneArgFunction { self ->
self.convertTo<Coroutine>().lastYielded
}

Expand Down
Loading

0 comments on commit 944d5d7

Please sign in to comment.