Skip to main content

Module lang

Module lang 

Source
Expand description

§Language Module

This module contains facilities for language transformations and analysis. The root module lang contains code for navigating any syntax tree, and general code for interacting with the CLI or the language servers.

The syntax trees are generated using Tree-sitter parsers, which reside in their own crates.

The submodules contain the specific language transformations and analysis.

The language servers themselves are compiled to separate executables, and as such, per rust convention, are in src/bin. In particular, communication with a language client is handled there, not here.

Modules§

applesoft
Applesoft analysis and transformations
disk_server
General disk image access optimized for language servers
integer
Integer BASIC analysis and transformations
merlin
Merlin analysis and transformations
server
Generics and traits for language servers

Structs§

Document
Text document packed up with URI string and version information. This is similar to the LSP TextDocumentItem, except that it originates on the server side, or from the CLI. There are internally defined URI’s for strings and macros.

Enums§

Error
Navigation

Traits§

Navigate
Trait for navigating a syntax tree in any language.

Functions§

apply_edits
Strategy is to sort edits bottom to top and apply in that sequence, this way the meaning of a row doesn’t change as we make the replacements. Overlaps not allowed. This is consistent with the LSP. Preserves CRLF or LF, unless there is a mixture, in which case LF wins. Panics if row is out of range.
eprint_diagnostic
eprint_lines_sexpr
extended_range
Extend a zero range one code point in either direction, if possible. Finite ranges are not modified. The byte range is not modified in any case.
is_lang
Test for the given language, returns false if there is any syntax error, does not always return true otherwise (additional criteria may be used). Warnings may be emitted if the results are ambiguous. Works for any language, provided it is line-oriented.
line_entry
Gather program lines from the console, panics if stdin is not the console
lsp_range
Take a range from a tree-sitter parser and convert it to an LSP range. The row argument is used when we are parsing line by line. The col argument is only needed to subtract out parsing hints.
named_sibling
node_integer
Parse a node that is expected to be an integer literal and put into generic type, if node cannot be parsed return None. This will ignore all spaces. Actually this will work for floating point types as well.
node_radix
Parse a node that may use a prefix to indicate radix, e.g., $0F or %00001111. This will ignore all spaces and underscores, except for an underscore prefix.
node_text
Get text of the node, returning null string if there is any error
normalize_client_uri
Take a URI from the client and recreate it using the server’s conventions. This is needed in order to make reliable file system comparisons. If the URI cannot be interpreted by std::path the input is returned unchanged.
normalize_client_uri_str
Convenience function calling normalize_client_uri
pathbuf_from_uri
range_contains_pos
range_contains_range
range_union
translate_pos
update_json_bool
Try to update a named boolean from a serde Value presumed to be an object. If there is any error do not change the value.
update_json_f64
Try to update a named float from a serde Value presumed to be an object. If there is any error do not change the value.
update_json_i64
Try to update a named integer from a serde Value presumed to be an object. If there is any error do not change the value.
update_json_severity
Try to update a named severity from a serde Value presumed to be an object. If there is any error do not change the value.
update_json_string
Try to update a named string from a serde Value presumed to be an object. If there is any error do not change the value.
update_json_string_opt
Try to update a named optional string from a serde Value presumed to be an object. If there is any error do not change the value.
update_json_vec
Try to update a named list of integers from a serde Value presumed to be an object. If there is any error do not change the value.
update_json_vec_str
Try to update a named list of strings from a serde Value presumed to be an object. If there is any error do not change the value.
uri_from_path
uri_from_path_str
N.b. path_str should be a full path
verify_str
Simple verify, returns an error if syntax check fails, but does not run full diagnostics. This is used by the CLI to interrupt the pipeline when a bad language file is encountered. Works for any language, provided it is line-oriented.