From 0ab9c023d9c387f16fd13437cba90a10527863de Mon Sep 17 00:00:00 2001 From: sevki Date: Wed, 17 Jul 2024 19:58:56 +0000 Subject: [PATCH] more ledgible theme, better naming (#8) Reviewed-on: https://ok.software/ok/src/pulls/8 --- .gitignore | 2 +- Cargo.lock | 76 +- Cargo.toml | 14 +- build.rs | 8 +- crates/src-derive-test/Cargo.toml | 11 - .../Cargo.toml | 4 +- .../src/lib.rs | 0 .../{src-derive => srclang_derive}/Cargo.toml | 2 +- .../{src-derive => srclang_derive}/src/lib.rs | 0 .../src/node.rs | 0 .../src/snapshots/src_derive__tests__.snap | 0 ... . visit () ; self . rhs . visit () ;.snap | 0 crates/srclang_derive_test/Cargo.toml | 11 + .../src/main.rs | 2 +- .../Cargo.toml | 6 +- .../src/lib.rs | 0 .../src/tokenizer.rs | 2 +- .../Cargo.toml | 6 +- .../src/db.rs | 4 +- .../src/lib.rs | 4 +- .../src/server.rs | 2 +- docs/0intro.md | 4 +- docs/SUMMARY.md | 251 +- docs/playground/index.md | 2 +- docs/theme/index.hbs | 2 +- ok.css | 83 +- src/ast/mod.rs | 2 +- src/lexer/mod.rs | 85 +- ...ng__parser__parser_snap_tests__effect.snap | 509 ++++ ...arser__parser_snap_tests__enum_parser.snap | 2506 +++++++++++++++++ ...parser_with_multiple_args_and_strings.snap | 212 ++ ...ser__parser_snap_tests__fn_def_parser.snap | 425 +++ ...ser__parser_snap_tests__struct_parser.snap | 202 ++ versions.txt | 4 +- 34 files changed, 4070 insertions(+), 371 deletions(-) delete mode 100644 crates/src-derive-test/Cargo.toml rename crates/{src-collections => srclang_collections}/Cargo.toml (66%) rename crates/{src-collections => srclang_collections}/src/lib.rs (100%) rename crates/{src-derive => srclang_derive}/Cargo.toml (93%) rename crates/{src-derive => srclang_derive}/src/lib.rs (100%) rename crates/{src-derive => srclang_derive}/src/node.rs (100%) rename crates/{src-derive => srclang_derive}/src/snapshots/src_derive__tests__.snap (100%) rename crates/{src-derive => srclang_derive}/src/snapshots/src_derive__tests__self . lhs . visit () ; self . rhs . visit () ;.snap (100%) create mode 100644 crates/srclang_derive_test/Cargo.toml rename crates/{src-derive-test => srclang_derive_test}/src/main.rs (99%) rename crates/{src-lsp-browser => srclang_lsp_browser}/Cargo.toml (74%) rename crates/{src-lsp-browser => srclang_lsp_browser}/src/lib.rs (100%) rename crates/{src-lsp-browser => srclang_lsp_browser}/src/tokenizer.rs (99%) rename crates/{src-lsp-server => srclang_lsp_server}/Cargo.toml (83%) rename crates/{src-lsp-server => srclang_lsp_server}/src/db.rs (99%) rename crates/{src-lsp-server => srclang_lsp_server}/src/lib.rs (72%) rename crates/{src-lsp-server => srclang_lsp_server}/src/server.rs (99%) create mode 100644 src/parser/snapshots/srclang__parser__parser_snap_tests__effect.snap create mode 100644 src/parser/snapshots/srclang__parser__parser_snap_tests__enum_parser.snap create mode 100644 src/parser/snapshots/srclang__parser__parser_snap_tests__fn_call_parser_with_multiple_args_and_strings.snap create mode 100644 src/parser/snapshots/srclang__parser__parser_snap_tests__fn_def_parser.snap create mode 100644 src/parser/snapshots/srclang__parser__parser_snap_tests__struct_parser.snap diff --git a/.gitignore b/.gitignore index 08a9dbb..c143a8e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ node_modules packages/app/assets dist -docs/crates/src_* \ No newline at end of file +docs/crates/srclang* diff --git a/Cargo.lock b/Cargo.lock index 095d52a..423d82c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1914,37 +1914,7 @@ dependencies = [ ] [[package]] -name = "src-collections" -version = "0.1.0" -dependencies = [ - "indexmap 1.9.3", - "rustc-hash", - "typed-index-collections", -] - -[[package]] -name = "src-derive" -version = "0.1.0" -dependencies = [ - "insta", - "okstd", - "pretty_assertions", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "src-derive-test" -version = "0.1.0" -dependencies = [ - "okstd", - "src-derive", - "src-lang", -] - -[[package]] -name = "src-lang" +name = "srclang" version = "0.1.0" dependencies = [ "anyhow", @@ -1965,20 +1935,41 @@ dependencies = [ "rustdoc-to-markdown", "salsa-2022", "salsa-2022-macros", - "src-derive", + "srclang_derive", "syn 2.0.71", "tiny-keccak", ] [[package]] -name = "src-lsp-browser" +name = "srclang_collections" +version = "0.1.0" +dependencies = [ + "indexmap 1.9.3", + "rustc-hash", + "typed-index-collections", +] + +[[package]] +name = "srclang_derive" +version = "0.1.0" +dependencies = [ + "insta", + "okstd", + "pretty_assertions", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "srclang_lsp_browser" version = "0.0.0" dependencies = [ "console_error_panic_hook", "futures", "js-sys", - "src-lang", - "src-lsp-server", + "srclang", + "srclang_lsp_server", "tower-lsp", "wasm-bindgen", "wasm-bindgen-futures", @@ -1987,7 +1978,7 @@ dependencies = [ ] [[package]] -name = "src-lsp-server" +name = "srclang_lsp_server" version = "0.0.0" dependencies = [ "anyhow", @@ -2005,8 +1996,8 @@ dependencies = [ "salsa-2022", "salsa-2022-macros", "serde_json", - "src-collections", - "src-lang", + "srclang", + "srclang_collections", "thiserror", "tower-lsp", "wasm-bindgen", @@ -2015,6 +2006,15 @@ dependencies = [ "web-sys", ] +[[package]] +name = "srlangc_derive_test" +version = "0.1.0" +dependencies = [ + "okstd", + "srclang", + "srclang_derive", +] + [[package]] name = "str_indices" version = "0.4.3" diff --git a/Cargo.toml b/Cargo.toml index 186dcba..8f48a84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,16 @@ [package] -name = "src-lang" +name = "srclang" version = "0.1.0" edition = "2021" [workspace] members = [ "crates/rustdoc-to-markdown", - "crates/src-collections", - "crates/src-derive", - "crates/src-derive-test", - "crates/src-lsp-browser", - "crates/src-lsp-server", + "crates/srclang_collections", + "crates/srclang_derive", + "crates/srclang_derive_test", + "crates/srclang_lsp_browser", + "crates/srclang_lsp_server", ] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -39,7 +39,7 @@ syn = "2.0.60" bitflags = "2.5.0" ropey = { version = "1.6.1", features = ["small_chunks"] } hashbrown = "0.14.5" -src-derive = { version = "0.1.0", path = "crates/src-derive", registry = "oksoftware" } +srclang_derive = { version = "0.1.0", path = "crates/srclang_derive", registry = "oksoftware" } paste = "1.0.15" [dev-dependencies] diff --git a/build.rs b/build.rs index fc915a9..1505b95 100644 --- a/build.rs +++ b/build.rs @@ -179,9 +179,7 @@ fn try_make_books() -> std::result::Result<(), std::io::Error> { .collect::>() .join("/"); - if !base_name.as_str().starts_with("src_lang") - && !base_name.as_str().starts_with("src_derive") - { + if !base_name.as_str().starts_with("srclang") { return None; } let outpath = PathBuf::from(env!("CARGO_MANIFEST_DIR")) @@ -256,7 +254,7 @@ fn try_make_books() -> std::result::Result<(), std::io::Error> { continue; } if full_path.ends_with("playground/index.md") { - title = "src Playground".to_string(); + title = " srclang ide".to_string(); } for c in name.iter().enumerate() { @@ -296,7 +294,7 @@ fn try_make_books() -> std::result::Result<(), std::io::Error> { "Macro" => "", "Constant" => "", "Module" => "", - "Crate" => "", + "Crate" => "", "Crates" => "🦀", _ => "", }; diff --git a/crates/src-derive-test/Cargo.toml b/crates/src-derive-test/Cargo.toml deleted file mode 100644 index 69e87dd..0000000 --- a/crates/src-derive-test/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "src-derive-test" -version = "0.1.0" -edition = "2021" -publish = ["oksoftware"] - -[dependencies] -okstd = { version = "0.1.9", registry = "oksoftware", features = ["macros"] } - -src-derive = { version = "0.1.0", path = "../src-derive", registry = "oksoftware" } -src-lang = { version = "0.1.0", path = "../..", registry = "oksoftware" } diff --git a/crates/src-collections/Cargo.toml b/crates/srclang_collections/Cargo.toml similarity index 66% rename from crates/src-collections/Cargo.toml rename to crates/srclang_collections/Cargo.toml index 7e3702b..d6c17fd 100644 --- a/crates/src-collections/Cargo.toml +++ b/crates/srclang_collections/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "src-collections" +name = "srclang_collections" version = "0.1.0" edition = "2021" publish = ["oksoftware"] @@ -7,4 +7,4 @@ publish = ["oksoftware"] [dependencies] rustc-hash = "1.1.0" indexmap = "1.9.1" -typed-index-collections = "3.0.3" \ No newline at end of file +typed-index-collections = "3.0.3" diff --git a/crates/src-collections/src/lib.rs b/crates/srclang_collections/src/lib.rs similarity index 100% rename from crates/src-collections/src/lib.rs rename to crates/srclang_collections/src/lib.rs diff --git a/crates/src-derive/Cargo.toml b/crates/srclang_derive/Cargo.toml similarity index 93% rename from crates/src-derive/Cargo.toml rename to crates/srclang_derive/Cargo.toml index 8412ac4..d968806 100644 --- a/crates/src-derive/Cargo.toml +++ b/crates/srclang_derive/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "src-derive" +name = "srclang_derive" version = "0.1.0" edition = "2021" publish = ["oksoftware"] diff --git a/crates/src-derive/src/lib.rs b/crates/srclang_derive/src/lib.rs similarity index 100% rename from crates/src-derive/src/lib.rs rename to crates/srclang_derive/src/lib.rs diff --git a/crates/src-derive/src/node.rs b/crates/srclang_derive/src/node.rs similarity index 100% rename from crates/src-derive/src/node.rs rename to crates/srclang_derive/src/node.rs diff --git a/crates/src-derive/src/snapshots/src_derive__tests__.snap b/crates/srclang_derive/src/snapshots/src_derive__tests__.snap similarity index 100% rename from crates/src-derive/src/snapshots/src_derive__tests__.snap rename to crates/srclang_derive/src/snapshots/src_derive__tests__.snap diff --git a/crates/src-derive/src/snapshots/src_derive__tests__self . lhs . visit () ; self . rhs . visit () ;.snap b/crates/srclang_derive/src/snapshots/src_derive__tests__self . lhs . visit () ; self . rhs . visit () ;.snap similarity index 100% rename from crates/src-derive/src/snapshots/src_derive__tests__self . lhs . visit () ; self . rhs . visit () ;.snap rename to crates/srclang_derive/src/snapshots/src_derive__tests__self . lhs . visit () ; self . rhs . visit () ;.snap diff --git a/crates/srclang_derive_test/Cargo.toml b/crates/srclang_derive_test/Cargo.toml new file mode 100644 index 0000000..df2224a --- /dev/null +++ b/crates/srclang_derive_test/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "srlangc_derive_test" +version = "0.1.0" +edition = "2021" +publish = ["oksoftware"] + +[dependencies] +okstd = { version = "0.1.9", registry = "oksoftware", features = ["macros"] } + +srclang_derive = { version = "0.1.0", path = "../srclang_derive", registry = "oksoftware" } +srclang = { version = "0.1.0", path = "../..", registry = "oksoftware" } diff --git a/crates/src-derive-test/src/main.rs b/crates/srclang_derive_test/src/main.rs similarity index 99% rename from crates/src-derive-test/src/main.rs rename to crates/srclang_derive_test/src/main.rs index 516cb84..e0fa9e3 100644 --- a/crates/src-derive-test/src/main.rs +++ b/crates/srclang_derive_test/src/main.rs @@ -1,4 +1,4 @@ -use src_derive::node; +use srclang_derive::node; use srclang::lexer::Location; use srclang::ops; use srclang::parser::span::Spanned; diff --git a/crates/src-lsp-browser/Cargo.toml b/crates/srclang_lsp_browser/Cargo.toml similarity index 74% rename from crates/src-lsp-browser/Cargo.toml rename to crates/srclang_lsp_browser/Cargo.toml index d8de40d..45c1a8c 100644 --- a/crates/src-lsp-browser/Cargo.toml +++ b/crates/srclang_lsp_browser/Cargo.toml @@ -1,7 +1,7 @@ [package] publish = false edition = "2021" -name = "src-lsp-browser" +name = "srclang_lsp_browser" version = "0.0.0" [features] @@ -12,7 +12,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] console_error_panic_hook = "0.1.7" -src-lsp-server = { version = "0.0", path = "../src-lsp-server", default-features = false } +srclang_lsp_server = { version = "0.0", path = "../srclang_lsp_server", default-features = false } futures = "0.3.21" js-sys = "0.3.57" tower-lsp = { version = "0.17.0", default-features = false } @@ -21,7 +21,7 @@ wasm-bindgen-futures = { version = "0.4.30", features = [ "futures-core-03-stream", ] } wasm-streams = "0.2.3" -src-lang = { version = "0.1.0", path = "../..", registry = "oksoftware" } +srclang = { version = "0.1.0", path = "../..", registry = "oksoftware" } web-sys = { version = "0.3.69", features = [ "console", "HtmlTextAreaElement", diff --git a/crates/src-lsp-browser/src/lib.rs b/crates/srclang_lsp_browser/src/lib.rs similarity index 100% rename from crates/src-lsp-browser/src/lib.rs rename to crates/srclang_lsp_browser/src/lib.rs diff --git a/crates/src-lsp-browser/src/tokenizer.rs b/crates/srclang_lsp_browser/src/tokenizer.rs similarity index 99% rename from crates/src-lsp-browser/src/tokenizer.rs rename to crates/srclang_lsp_browser/src/tokenizer.rs index 6264b7c..252dd2e 100644 --- a/crates/src-lsp-browser/src/tokenizer.rs +++ b/crates/srclang_lsp_browser/src/tokenizer.rs @@ -1,5 +1,5 @@ use js_sys::JsString; -use src_lang::lexer::{self}; +use srclang::lexer::{self}; use wasm_bindgen::prelude::*; #[wasm_bindgen] diff --git a/crates/src-lsp-server/Cargo.toml b/crates/srclang_lsp_server/Cargo.toml similarity index 83% rename from crates/src-lsp-server/Cargo.toml rename to crates/srclang_lsp_server/Cargo.toml index f83dbe3..0dd4fc9 100644 --- a/crates/src-lsp-server/Cargo.toml +++ b/crates/srclang_lsp_server/Cargo.toml @@ -1,7 +1,7 @@ [package] publish = false edition = "2021" -name = "src-lsp-server" +name = "srclang_lsp_server" version = "0.0.0" [features] @@ -23,7 +23,7 @@ lsp = { version = "0.93", package = "lsp-types" } lsp-text = "0.9" ropey = "1.6.1" serde_json = "1.0" -src-lang = { version = "0.1.0", path = "../..", registry = "oksoftware" } +srclang = { version = "0.1.0", path = "../..", registry = "oksoftware" } salsa = { version = "0.1.0", registry = "oksoftware", package = "salsa-2022" } salsa-macros = { version = "0.1.0", registry = "oksoftware", package = "salsa-2022-macros" } thiserror = "1.0" @@ -33,7 +33,7 @@ wasm-bindgen-futures = { version = "0.4.30", features = [ "futures-core-03-stream", ] } wasm-streams = "0.2.3" -src-collections = { version = "0.1.0", path = "../src-collections", registry = "oksoftware" } +srclang_collections = { version = "0.1.0", path = "../srclang_collections", registry = "oksoftware" } lazy_static = "1.4.0" [dependencies.web-sys] diff --git a/crates/src-lsp-server/src/db.rs b/crates/srclang_lsp_server/src/db.rs similarity index 99% rename from crates/src-lsp-server/src/db.rs rename to crates/srclang_lsp_server/src/db.rs index 692ed78..17afc01 100644 --- a/crates/src-lsp-server/src/db.rs +++ b/crates/srclang_lsp_server/src/db.rs @@ -2,8 +2,8 @@ use lsp::{InitializeParams, InitializeResult, Url}; use lsp_text::RopeExt; use salsa::function::DynDb; -use src_collections::Map; -use src_lang::{ +use srclang_collections::Map; +use srclang::{ analyzer::{self, span_text}, compiler::text::{self, Document, SourceProgram}, parser::{ diff --git a/crates/src-lsp-server/src/lib.rs b/crates/srclang_lsp_server/src/lib.rs similarity index 72% rename from crates/src-lsp-server/src/lib.rs rename to crates/srclang_lsp_server/src/lib.rs index f84713c..a6a2142 100644 --- a/crates/src-lsp-server/src/lib.rs +++ b/crates/srclang_lsp_server/src/lib.rs @@ -7,8 +7,8 @@ mod server; mod db; -use src_lang::compiler; +use srclang::compiler; pub use server::*; -pub use src_lang::Jar; +pub use srclang::Jar; diff --git a/crates/src-lsp-server/src/server.rs b/crates/srclang_lsp_server/src/server.rs similarity index 99% rename from crates/src-lsp-server/src/server.rs rename to crates/srclang_lsp_server/src/server.rs index 58297cd..7fae2a1 100644 --- a/crates/src-lsp-server/src/server.rs +++ b/crates/srclang_lsp_server/src/server.rs @@ -1,5 +1,5 @@ use anyhow::anyhow; -use src_lang::parser; +use srclang::parser; use std::result::Result::Ok; use std::sync::Arc; use tower_lsp::{jsonrpc, lsp_types::*, LanguageServer}; diff --git a/docs/0intro.md b/docs/0intro.md index 9322e09..9a455b6 100644 --- a/docs/0intro.md +++ b/docs/0intro.md @@ -3,8 +3,8 @@ # src Language -> [!NOTE] -> {{#include ../versions.txt}} +> [!WARNING] +> This very much exists so I don't have to setup the open-source infrastructure after open-sourcing the project. There are lots of moving parts to the documentation, like the [rustdocs](./crates/index.md) is generated and included in the book. Also There is a IDE of sorts in [playground](./playground/index.md) and a [language server](./lsp/index.md) that is used to provide the IDE. `src` is a domain specific language for manipulating source code and building, progressively distiributed apps or [PDA](https://fistfulofbytes.com/progressive-distributed-apps/). diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 80b9a12..07177f7 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -1,132 +1,131 @@ - [ src Language](0intro.md) - [ Language Specification](language/0intro.md) - [ Examples](examples.md) -- [ src Playground](playground/index.md) +- [  srclang ide](playground/index.md) - [ Skills](skill-tree.md) - [ Research](research.md) - [🦀 Crates](crates/index.md) - - [ Crate src_derive](crates/src_derive/index.md) - - [ node](crates/src_derive/attr.node.md) - - [ Crate src_lang](crates/src_lang/index.md) - - [ analyzer](crates/src_lang/analyzer/index.md) - - [ db](crates/src_lang/analyzer/db/index.md) - - [ Database](crates/src_lang/analyzer/db/struct.Database.md) - - [ add_file](crates/src_lang/analyzer/fn.add_file.md) - - [ get_symbol](crates/src_lang/analyzer/fn.get_symbol.md) - - [ span_text](crates/src_lang/analyzer/fn.span_text.md) - - [ SyntaxTree](crates/src_lang/analyzer/struct.SyntaxTree.md) - - [ Url](crates/src_lang/analyzer/struct.Url.md) - - [ add_file](crates/src_lang/analyzer/struct.add_file.md) - - [ get_symbol](crates/src_lang/analyzer/struct.get_symbol.md) - - [ span_text](crates/src_lang/analyzer/struct.span_text.md) - - [ ast](crates/src_lang/ast/index.md) - - [ Kw](crates/src_lang/ast/enum.Kw.md) - - [ Literal](crates/src_lang/ast/enum.Literal.md) - - [ Node](crates/src_lang/ast/enum.Node.md) - - [ Operator](crates/src_lang/ast/enum.Operator.md) - - [ Visibility](crates/src_lang/ast/enum.Visibility.md) - - [ Field](crates/src_lang/ast/struct.Field.md) - - [ Ident](crates/src_lang/ast/struct.Ident.md) - - [ Keyword](crates/src_lang/ast/struct.Keyword.md) - - [ FieldVisitor](crates/src_lang/ast/trait.FieldVisitor.md) - - [ IdentVisitor](crates/src_lang/ast/trait.IdentVisitor.md) - - [ KeywordVisitor](crates/src_lang/ast/trait.KeywordVisitor.md) - - [ compiler](crates/src_lang/compiler/index.md) - - [ errors](crates/src_lang/compiler/errors/index.md) - - [ Errors](crates/src_lang/compiler/errors/struct.Errors.md) - - [ add_imports](crates/src_lang/compiler/fn.add_imports.md) - - [ compile](crates/src_lang/compiler/fn.compile.md) - - [ compile_effect](crates/src_lang/compiler/fn.compile_effect.md) - - [ ir](crates/src_lang/compiler/ir/index.md) - - [ EffectDef](crates/src_lang/compiler/ir/struct.EffectDef.md) - - [ Function](crates/src_lang/compiler/ir/struct.Function.md) - - [ Import](crates/src_lang/compiler/ir/struct.Import.md) - - [ InternedEffect](crates/src_lang/compiler/ir/struct.InternedEffect.md) - - [ Mangled](crates/src_lang/compiler/ir/struct.Mangled.md) - - [ Program](crates/src_lang/compiler/ir/struct.Program.md) - - [ Symbol](crates/src_lang/compiler/ir/struct.Symbol.md) - - [ __EffectDefConfig](crates/src_lang/compiler/ir/struct.__EffectDefConfig.md) - - [ __FunctionConfig](crates/src_lang/compiler/ir/struct.__FunctionConfig.md) - - [ __ImportConfig](crates/src_lang/compiler/ir/struct.__ImportConfig.md) - - [ __InternedEffectData](crates/src_lang/compiler/ir/struct.__InternedEffectData.md) - - [ __MangledData](crates/src_lang/compiler/ir/struct.__MangledData.md) - - [ __ProgramConfig](crates/src_lang/compiler/ir/struct.__ProgramConfig.md) - - [ __SymbolData](crates/src_lang/compiler/ir/struct.__SymbolData.md) - - [ add_imports](crates/src_lang/compiler/struct.add_imports.md) - - [ compile](crates/src_lang/compiler/struct.compile.md) - - [ compile_effect](crates/src_lang/compiler/struct.compile_effect.md) - - [ text](crates/src_lang/compiler/text/index.md) - - [ calculate_line_lengths](crates/src_lang/compiler/text/fn.calculate_line_lengths.md) - - [ cmp_range](crates/src_lang/compiler/text/fn.cmp_range.md) - - [ to_spans](crates/src_lang/compiler/text/fn.to_spans.md) - - [ Document](crates/src_lang/compiler/text/struct.Document.md) - - [ Position](crates/src_lang/compiler/text/struct.Position.md) - - [ SourceMap](crates/src_lang/compiler/text/struct.SourceMap.md) - - [ SourceProgram](crates/src_lang/compiler/text/struct.SourceProgram.md) - - [ Span](crates/src_lang/compiler/text/struct.Span.md) - - [ SpanOverlap](crates/src_lang/compiler/text/struct.SpanOverlap.md) - - [ Spanned](crates/src_lang/compiler/text/struct.Spanned.md) - - [ __PositionData](crates/src_lang/compiler/text/struct.__PositionData.md) - - [ __SourceMapConfig](crates/src_lang/compiler/text/struct.__SourceMapConfig.md) - - [ __SpanData](crates/src_lang/compiler/text/struct.__SpanData.md) - - [ __SpannedData](crates/src_lang/compiler/text/struct.__SpannedData.md) - - [ calculate_line_lengths](crates/src_lang/compiler/text/struct.calculate_line_lengths.md) - - [ to_spans](crates/src_lang/compiler/text/struct.to_spans.md) - - [ lexer](crates/src_lang/lexer/index.md) - - [ LexicalError](crates/src_lang/lexer/enum.LexicalError.md) - - [ Token](crates/src_lang/lexer/enum.Token.md) - - [ Variable](crates/src_lang/lexer/enum.Variable.md) - - [ Word](crates/src_lang/lexer/enum.Word.md) - - [ Lexer](crates/src_lang/lexer/struct.Lexer.md) - - [ Location](crates/src_lang/lexer/struct.Location.md) - - [ Position](crates/src_lang/lexer/struct.Position.md) - - [ Spanned](crates/src_lang/lexer/struct.Spanned.md) - - [ TripleIterator](crates/src_lang/lexer/struct.TripleIterator.md) - - [ span](crates/src_lang/macro.span.md) - - [ ops](crates/src_lang/ops/index.md) - - [ traversal](crates/src_lang/ops/traversal/index.md) - - [ Control](crates/src_lang/ops/traversal/enum.Control.md) - - [ parser](crates/src_lang/parser/index.md) - - [ ast](crates/src_lang/parser/ast/index.md) - - [ ANON_FN_NAME](crates/src_lang/parser/ast/constant.ANON_FN_NAME.md) - - [ FnArg](crates/src_lang/parser/ast/enum.FnArg.md) - - [ Keyword](crates/src_lang/parser/ast/enum.Keyword.md) - - [ Literal](crates/src_lang/parser/ast/enum.Literal.md) - - [ Node](crates/src_lang/parser/ast/enum.Node.md) - - [ Operator](crates/src_lang/parser/ast/enum.Operator.md) - - [ Value](crates/src_lang/parser/ast/enum.Value.md) - - [ Visibility](crates/src_lang/parser/ast/enum.Visibility.md) - - [ Whitespace](crates/src_lang/parser/ast/enum.Whitespace.md) - - [ Array](crates/src_lang/parser/ast/struct.Array.md) - - [ BinaryOperation](crates/src_lang/parser/ast/struct.BinaryOperation.md) - - [ Binding](crates/src_lang/parser/ast/struct.Binding.md) - - [ Block](crates/src_lang/parser/ast/struct.Block.md) - - [ BranchDef](crates/src_lang/parser/ast/struct.BranchDef.md) - - [ EffectDef](crates/src_lang/parser/ast/struct.EffectDef.md) - - [ FieldAccess](crates/src_lang/parser/ast/struct.FieldAccess.md) - - [ FieldDef](crates/src_lang/parser/ast/struct.FieldDef.md) - - [ FnCall](crates/src_lang/parser/ast/struct.FnCall.md) - - [ FnDef](crates/src_lang/parser/ast/struct.FnDef.md) - - [ FnIdent](crates/src_lang/parser/ast/struct.FnIdent.md) - - [ Ident](crates/src_lang/parser/ast/struct.Ident.md) - - [ ImplDef](crates/src_lang/parser/ast/struct.ImplDef.md) - - [ KeywordAndVisibility](crates/src_lang/parser/ast/struct.KeywordAndVisibility.md) - - [ Module](crates/src_lang/parser/ast/struct.Module.md) - - [ Prototype](crates/src_lang/parser/ast/struct.Prototype.md) - - [ StringLit](crates/src_lang/parser/ast/struct.StringLit.md) - - [ StructDef](crates/src_lang/parser/ast/struct.StructDef.md) - - [ Tuple](crates/src_lang/parser/ast/struct.Tuple.md) - - [ UseDef](crates/src_lang/parser/ast/struct.UseDef.md) - - [ span](crates/src_lang/parser/span/index.md) - - [ ByteOrLineColOrCoord](crates/src_lang/parser/span/enum.ByteOrLineColOrCoord.md) - - [ ByteOrLineColOrCoordInterned](crates/src_lang/parser/span/struct.ByteOrLineColOrCoordInterned.md) - - [ SourceMap](crates/src_lang/parser/span/struct.SourceMap.md) - - [ Spanned](crates/src_lang/parser/span/struct.Spanned.md) - - [ __SourceMapConfig](crates/src_lang/parser/span/struct.__SourceMapConfig.md) - - [ HasChildSpans](crates/src_lang/parser/span/trait.HasChildSpans.md) - - [ Spanning](crates/src_lang/parser/span/trait.Spanning.md) - - [ src](crates/src_lang/parser/src/index.md) - - [ SourceParser](crates/src_lang/parser/src/struct.SourceParser.md) - - [ __ToTriple](crates/src_lang/parser/src/trait.__ToTriple.md) - - [ Jar](crates/src_lang/struct.Jar.md) - - [ Db](crates/src_lang/trait.Db.md) + - [ Crate srclang](crates/srclang/index.md) + - [ analyzer](crates/srclang/analyzer/index.md) + - [ db](crates/srclang/analyzer/db/index.md) + - [ Database](crates/srclang/analyzer/db/struct.Database.md) + - [ add_file](crates/srclang/analyzer/fn.add_file.md) + - [ get_symbol](crates/srclang/analyzer/fn.get_symbol.md) + - [ span_text](crates/srclang/analyzer/fn.span_text.md) + - [ SyntaxTree](crates/srclang/analyzer/struct.SyntaxTree.md) + - [ Url](crates/srclang/analyzer/struct.Url.md) + - [ add_file](crates/srclang/analyzer/struct.add_file.md) + - [ get_symbol](crates/srclang/analyzer/struct.get_symbol.md) + - [ span_text](crates/srclang/analyzer/struct.span_text.md) + - [ ast](crates/srclang/ast/index.md) + - [ Kw](crates/srclang/ast/enum.Kw.md) + - [ Literal](crates/srclang/ast/enum.Literal.md) + - [ Node](crates/srclang/ast/enum.Node.md) + - [ Operator](crates/srclang/ast/enum.Operator.md) + - [ Visibility](crates/srclang/ast/enum.Visibility.md) + - [ Field](crates/srclang/ast/struct.Field.md) + - [ Ident](crates/srclang/ast/struct.Ident.md) + - [ Keyword](crates/srclang/ast/struct.Keyword.md) + - [ FieldVisitor](crates/srclang/ast/trait.FieldVisitor.md) + - [ IdentVisitor](crates/srclang/ast/trait.IdentVisitor.md) + - [ KeywordVisitor](crates/srclang/ast/trait.KeywordVisitor.md) + - [ compiler](crates/srclang/compiler/index.md) + - [ errors](crates/srclang/compiler/errors/index.md) + - [ Errors](crates/srclang/compiler/errors/struct.Errors.md) + - [ add_imports](crates/srclang/compiler/fn.add_imports.md) + - [ compile](crates/srclang/compiler/fn.compile.md) + - [ compile_effect](crates/srclang/compiler/fn.compile_effect.md) + - [ ir](crates/srclang/compiler/ir/index.md) + - [ EffectDef](crates/srclang/compiler/ir/struct.EffectDef.md) + - [ Function](crates/srclang/compiler/ir/struct.Function.md) + - [ Import](crates/srclang/compiler/ir/struct.Import.md) + - [ InternedEffect](crates/srclang/compiler/ir/struct.InternedEffect.md) + - [ Mangled](crates/srclang/compiler/ir/struct.Mangled.md) + - [ Program](crates/srclang/compiler/ir/struct.Program.md) + - [ Symbol](crates/srclang/compiler/ir/struct.Symbol.md) + - [ __EffectDefConfig](crates/srclang/compiler/ir/struct.__EffectDefConfig.md) + - [ __FunctionConfig](crates/srclang/compiler/ir/struct.__FunctionConfig.md) + - [ __ImportConfig](crates/srclang/compiler/ir/struct.__ImportConfig.md) + - [ __InternedEffectData](crates/srclang/compiler/ir/struct.__InternedEffectData.md) + - [ __MangledData](crates/srclang/compiler/ir/struct.__MangledData.md) + - [ __ProgramConfig](crates/srclang/compiler/ir/struct.__ProgramConfig.md) + - [ __SymbolData](crates/srclang/compiler/ir/struct.__SymbolData.md) + - [ add_imports](crates/srclang/compiler/struct.add_imports.md) + - [ compile](crates/srclang/compiler/struct.compile.md) + - [ compile_effect](crates/srclang/compiler/struct.compile_effect.md) + - [ text](crates/srclang/compiler/text/index.md) + - [ calculate_line_lengths](crates/srclang/compiler/text/fn.calculate_line_lengths.md) + - [ cmp_range](crates/srclang/compiler/text/fn.cmp_range.md) + - [ to_spans](crates/srclang/compiler/text/fn.to_spans.md) + - [ Document](crates/srclang/compiler/text/struct.Document.md) + - [ Position](crates/srclang/compiler/text/struct.Position.md) + - [ SourceMap](crates/srclang/compiler/text/struct.SourceMap.md) + - [ SourceProgram](crates/srclang/compiler/text/struct.SourceProgram.md) + - [ Span](crates/srclang/compiler/text/struct.Span.md) + - [ SpanOverlap](crates/srclang/compiler/text/struct.SpanOverlap.md) + - [ Spanned](crates/srclang/compiler/text/struct.Spanned.md) + - [ __PositionData](crates/srclang/compiler/text/struct.__PositionData.md) + - [ __SourceMapConfig](crates/srclang/compiler/text/struct.__SourceMapConfig.md) + - [ __SpanData](crates/srclang/compiler/text/struct.__SpanData.md) + - [ __SpannedData](crates/srclang/compiler/text/struct.__SpannedData.md) + - [ calculate_line_lengths](crates/srclang/compiler/text/struct.calculate_line_lengths.md) + - [ to_spans](crates/srclang/compiler/text/struct.to_spans.md) + - [ lexer](crates/srclang/lexer/index.md) + - [ LexicalError](crates/srclang/lexer/enum.LexicalError.md) + - [ Token](crates/srclang/lexer/enum.Token.md) + - [ Word](crates/srclang/lexer/enum.Word.md) + - [ Lexer](crates/srclang/lexer/struct.Lexer.md) + - [ Location](crates/srclang/lexer/struct.Location.md) + - [ Position](crates/srclang/lexer/struct.Position.md) + - [ Spanned](crates/srclang/lexer/struct.Spanned.md) + - [ TripleIterator](crates/srclang/lexer/struct.TripleIterator.md) + - [ span](crates/srclang/macro.span.md) + - [ ops](crates/srclang/ops/index.md) + - [ traversal](crates/srclang/ops/traversal/index.md) + - [ Control](crates/srclang/ops/traversal/enum.Control.md) + - [ parser](crates/srclang/parser/index.md) + - [ ast](crates/srclang/parser/ast/index.md) + - [ ANON_FN_NAME](crates/srclang/parser/ast/constant.ANON_FN_NAME.md) + - [ FnArg](crates/srclang/parser/ast/enum.FnArg.md) + - [ Keyword](crates/srclang/parser/ast/enum.Keyword.md) + - [ Literal](crates/srclang/parser/ast/enum.Literal.md) + - [ Node](crates/srclang/parser/ast/enum.Node.md) + - [ Operator](crates/srclang/parser/ast/enum.Operator.md) + - [ Value](crates/srclang/parser/ast/enum.Value.md) + - [ Visibility](crates/srclang/parser/ast/enum.Visibility.md) + - [ Whitespace](crates/srclang/parser/ast/enum.Whitespace.md) + - [ Array](crates/srclang/parser/ast/struct.Array.md) + - [ BinaryOperation](crates/srclang/parser/ast/struct.BinaryOperation.md) + - [ Binding](crates/srclang/parser/ast/struct.Binding.md) + - [ Block](crates/srclang/parser/ast/struct.Block.md) + - [ BranchDef](crates/srclang/parser/ast/struct.BranchDef.md) + - [ EffectDef](crates/srclang/parser/ast/struct.EffectDef.md) + - [ FieldAccess](crates/srclang/parser/ast/struct.FieldAccess.md) + - [ FieldDef](crates/srclang/parser/ast/struct.FieldDef.md) + - [ FnCall](crates/srclang/parser/ast/struct.FnCall.md) + - [ FnDef](crates/srclang/parser/ast/struct.FnDef.md) + - [ FnIdent](crates/srclang/parser/ast/struct.FnIdent.md) + - [ Ident](crates/srclang/parser/ast/struct.Ident.md) + - [ ImplDef](crates/srclang/parser/ast/struct.ImplDef.md) + - [ KeywordAndVisibility](crates/srclang/parser/ast/struct.KeywordAndVisibility.md) + - [ Module](crates/srclang/parser/ast/struct.Module.md) + - [ Prototype](crates/srclang/parser/ast/struct.Prototype.md) + - [ StringLit](crates/srclang/parser/ast/struct.StringLit.md) + - [ StructDef](crates/srclang/parser/ast/struct.StructDef.md) + - [ Tuple](crates/srclang/parser/ast/struct.Tuple.md) + - [ UseDef](crates/srclang/parser/ast/struct.UseDef.md) + - [ span](crates/srclang/parser/span/index.md) + - [ ByteOrLineColOrCoord](crates/srclang/parser/span/enum.ByteOrLineColOrCoord.md) + - [ ByteOrLineColOrCoordInterned](crates/srclang/parser/span/struct.ByteOrLineColOrCoordInterned.md) + - [ SourceMap](crates/srclang/parser/span/struct.SourceMap.md) + - [ Spanned](crates/srclang/parser/span/struct.Spanned.md) + - [ __SourceMapConfig](crates/srclang/parser/span/struct.__SourceMapConfig.md) + - [ HasChildSpans](crates/srclang/parser/span/trait.HasChildSpans.md) + - [ Spanning](crates/srclang/parser/span/trait.Spanning.md) + - [ src](crates/srclang/parser/src/index.md) + - [ SourceParser](crates/srclang/parser/src/struct.SourceParser.md) + - [ __ToTriple](crates/srclang/parser/src/trait.__ToTriple.md) + - [ Jar](crates/srclang/struct.Jar.md) + - [ Db](crates/srclang/trait.Db.md) + - [ Crate srclang_derive](crates/srclang_derive/index.md) + - [ node](crates/srclang_derive/attr.node.md) diff --git a/docs/playground/index.md b/docs/playground/index.md index 92b4701..2b13e15 100644 --- a/docs/playground/index.md +++ b/docs/playground/index.md @@ -1,5 +1,5 @@
-# IDE +#  IDE
diff --git a/docs/theme/index.hbs b/docs/theme/index.hbs index d055723..1a27d09 100644 --- a/docs/theme/index.hbs +++ b/docs/theme/index.hbs @@ -54,7 +54,7 @@ - +
diff --git a/ok.css b/ok.css index 54fe0d0..e331cb9 100644 --- a/ok.css +++ b/ok.css @@ -1,76 +1,6 @@ -/* - * okcss - * oknotok.computer 2024 - */ - -/*!***************************************************************************\ - NES.css Framework - Version: development - -\*****************************************************************************/ /*! - * Bootstrap Reboot v4.1.3 (https://getbootstrap.com/) - * Copyright 2011-2018 The Bootstrap Authors - * Copyright 2011-2018 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) - */ -/* cyrillic-ext */ -@font-face { - font-family: "IBM Plex Mono"; - font-style: normal; - font-weight: 400; - src: url(https://fonts.gstatic.com/s/pressstart2p/v15/e3t4euO8T-267oIAQAu6jDQyK3nYivN04w.woff2) - format("woff2"); - unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, - U+FE2E-FE2F; -} -/* cyrillic */ -@font-face { - font-family: "IBM Plex Mono"; - font-style: normal; - font-weight: 400; - src: url(https://fonts.gstatic.com/s/pressstart2p/v15/e3t4euO8T-267oIAQAu6jDQyK3nRivN04w.woff2) - format("woff2"); - unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; -} -/* greek */ -@font-face { - font-family: "IBM Plex Mono"; - font-style: normal; - font-weight: 400; - src: url(https://fonts.gstatic.com/s/pressstart2p/v15/e3t4euO8T-267oIAQAu6jDQyK3nWivN04w.woff2) - format("woff2"); - unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, - U+03A3-03FF; -} -/* latin-ext */ -@font-face { - font-family: "IBM Plex Mono"; - font-style: normal; - font-weight: 400; - src: url(https://fonts.gstatic.com/s/pressstart2p/v15/e3t4euO8T-267oIAQAu6jDQyK3nbivN04w.woff2) - format("woff2"); - unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, - U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; -} -/* latin */ -@font-face { - font-family: "IBM Plex Mono"; - font-style: normal; - font-weight: 400; - src: url(https://fonts.gstatic.com/s/pressstart2p/v15/e3t4euO8T-267oIAQAu6jDQyK3nVivM.woff2) - format("woff2"); - unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, - U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, - U+2193, U+2212, U+2215, U+FEFF, U+FFFD; -} - - @font-face { font-family: "codicon"; - font-display: inline; - font-size: 5em !important; - color: orange; + font-size-adjust: 10; src: url("https://microsoft.github.io/vscode-codicons/dist/codicon.ttf?30960ab01c247f8c3a401322f35802e9") format("truetype"); unicode-range: U+EA60-EA7F, U+EA80-EA9F, U+EAA0-EABF, U+EAC0-EADF, U+EAE0-EAFF, U+EB00-EB1F, U+EB20-EB3F, U+EB40-EB5F, @@ -2094,7 +2024,6 @@ input[type="radio"] { border-image-source: url('data:image/svg+xml;utf8,'); outline-color: #e7e7e7; } -@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap"); @import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap"); .ibm-plex-mono-thin { font-family: "IBM Plex Mono", monospace; @@ -2338,7 +2267,7 @@ nav ul li { nav ul li a { color: rgb(255, 255, 255); text-decoration: none; - font-size: 0.8em !important; + /* font-size: 1em !important; */ } pre { padding: 16px; @@ -2362,7 +2291,7 @@ pre code { } .nes-btn { - /* font-size: 1.1em; */ + font-size: 1em; } #content.content { height: calc(100vh - 104px); @@ -2387,7 +2316,7 @@ body { } .sidebar { - font-size: x-small !important; + font-size: large !important; } h3 code, @@ -2407,9 +2336,9 @@ h4 { } li a strong { - font-size: xx-small !important; + font-size: small !important; } .hljs { /* background-color: darken(var(--sidebar-bg) 10%); */ -} \ No newline at end of file +} diff --git a/src/ast/mod.rs b/src/ast/mod.rs index 8d5eed7..9197efa 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -1,7 +1,7 @@ use crate::lexer::Location; use crate::ops; use crate::parser::span::Spanned; -use src_derive::node; +use srclang_derive::node; use std::fmt::Display; use std::ops::Range; diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index d9bed4c..d971e86 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -6,48 +6,6 @@ use std::{fmt::Display, hash::Hash, iter::Iterator, iter::Peekable, str::Chars}; use okstd::prelude::*; -// Identifier -#[derive(Debug, PartialEq, Clone, Copy)] -pub enum Variable<'input> { - // $$ is the process ID of the shell - ProcessID, - // $! is the process ID of the last background command - LastBackgroundProcessID, - // $? is the exit status of the last command executed - LastCommandExitStatus, - // $- is the current option flags as specified upon invocation, by the set built-in command, or by the shell invocation environment - CurrentOptionFlags, - // $@ is the positional parameters, starting from one - PositionalParameters, - // $# is the number of positional parameters in decimal - PositionalParametersCount, - // $0 is the name of the shell or shell script - ShellName, - // $1...$9 are the positional parameters, starting from zero - PositionalParameter(usize), - // ${parameter} is the value of the variable parameter - Parameter(&'input str), - // ${parameter:-word} is the value of the variable parameter if it is set; otherwise, the expansion of word is substituted - ParameterDefault(&'input str, &'input str), -} - -impl<'input> Display for Variable<'input> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Variable::ProcessID => write!(f, "$$"), - Variable::LastBackgroundProcessID => write!(f, "$!"), - Variable::LastCommandExitStatus => write!(f, "$?"), - Variable::CurrentOptionFlags => write!(f, "$-"), - Variable::PositionalParameters => write!(f, "$@"), - Variable::PositionalParametersCount => write!(f, "$#"), - Variable::ShellName => write!(f, "$0"), - Variable::PositionalParameter(i) => write!(f, "${}", i), - Variable::Parameter(p) => write!(f, "${}", p), - Variable::ParameterDefault(p, w) => write!(f, "${}:{}", p, w), - } - } -} - // LexicalError #[derive(Debug, PartialEq, Clone)] pub enum LexicalError { @@ -223,7 +181,6 @@ pub enum Token<'input> { LessThan, // < GreaterThan, // > // Identifiers - Variable(Variable<'input>), // $a-z, $A-Z, $0-9, $_ // Literals Word(Word<'input>), // a-z, A-Z, 0-9, _ String(&'input str), // "..." @@ -273,11 +230,6 @@ impl<'input> Token<'input> { Token::Equals => "=".chars(), Token::LessThan => "<".chars(), Token::GreaterThan => ">".chars(), - Token::Variable(_identifier) => { - // Implement the conversion to chars for Variable - // based on its fields - "".chars() - } Token::Word(word) => word.chars(), Token::String(string) => string.chars(), Token::Comment(comment) => comment.chars(), @@ -320,7 +272,6 @@ impl<'input> Token<'input> { Token::Equals => "=".to_string(), Token::LessThan => "<".to_string(), Token::GreaterThan => ">".to_string(), - Token::Variable(variable) => variable.to_string(), Token::Word(word) => word.chars().collect(), Token::String(string) => string.to_string(), Token::Comment(comment) => comment.to_string(), @@ -403,7 +354,6 @@ enum State { NewLine, String(Quotation), Op, - Variable, Word, Number, Program, @@ -514,6 +464,7 @@ impl<'input> Lexer<'input> { '@' => Token::At, '/' => Token::Divide, '.' => Token::Dot, + '$' => Token::Dollar, '-' => { if self.buffer.len() == 1 { Token::Minus @@ -542,33 +493,6 @@ impl<'input> Lexer<'input> { .ok_or(LexicalError::UnexpectedEndOfInput)?; Ok(Token::Comment(comment)) } - State::Variable => { - let variable = self.buffer.clone(); - let identifier = match variable.as_str() { - "$$" => Variable::ProcessID, - "$?" => Variable::LastCommandExitStatus, - "$!" => Variable::LastBackgroundProcessID, - "$-" => Variable::CurrentOptionFlags, - "$0" => Variable::ShellName, - "$#" => Variable::PositionalParametersCount, - _ => { - if variable.starts_with('$') && variable.len() > 1 { - let number = variable[1..] - .parse() - .map_err(|_| LexicalError::InvalidVariableFormat)?; - Variable::PositionalParameter(number) - } else { - let var = self - .input - .get(start..end) - .ok_or(LexicalError::UnexpectedEndOfInput)?; - Variable::Parameter(var) - } - } - }; - - Ok(Token::Variable(identifier)) - } State::Word => { let word = self .input @@ -669,10 +593,6 @@ impl<'input> Lexer<'input> { set_state!(self, State::String(Quotation::Single);); return Ok(()); } - '$' => { - set_state!(self, State::Variable;); - return Ok(()); - } 'a'..='z' | 'A'..='Z' | '_' => { set_state!(self, State::Word;); return Ok(()); @@ -686,7 +606,7 @@ impl<'input> Lexer<'input> { return Ok(()); } '(' | ')' | '{' | '}' | '>' | '<' | '|' | '&' | ';' | ',' | ':' | '+' | '*' - | '.' | '[' | ']' | '%' | '@' | '/' | '-' | '=' | '!' => { + | '$' | '.' | '[' | ']' | '%' | '@' | '/' | '-' | '=' | '!' => { set_state!(self, State::Op;); debug!("to state: {:?}", self.state); return Ok(()); @@ -950,7 +870,6 @@ impl<'input> Iterator for Lexer<'input> { } State::NewLine => self.consume_newline(), State::String(quotation) => self.consume_string_literal(quotation), - State::Variable => self.consume_variable(), State::Word => self.consume_word(), State::Number => self.consume_number(), State::Any | State::Program => { diff --git a/src/parser/snapshots/srclang__parser__parser_snap_tests__effect.snap b/src/parser/snapshots/srclang__parser__parser_snap_tests__effect.snap new file mode 100644 index 0000000..8a7a864 --- /dev/null +++ b/src/parser/snapshots/srclang__parser__parser_snap_tests__effect.snap @@ -0,0 +1,509 @@ +--- +source: src/parser/parser_snap_tests.rs +expression: "format!(\"{:#?}\", t.unwrap())" +--- +Module( + [ + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + EffectDef( + EffectDef( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Effect, + Location { + offset: 6, + line: 0, + col: 6, + }, + ), + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Private, + Location { + offset: 0, + line: 0, + col: 0, + }, + ), + ), + Location { + offset: 6, + line: 0, + col: 6, + }, + ), + Spanned( + Location { + offset: 7, + line: 0, + col: 7, + }, + Ident( + "VM", + None, + ), + Location { + offset: 9, + line: 0, + col: 9, + }, + ), + [ + Spanned( + Location { + offset: 11, + line: 0, + col: 11, + }, + Ident( + "async", + None, + ), + Location { + offset: 16, + line: 0, + col: 16, + }, + ), + Spanned( + Location { + offset: 19, + line: 0, + col: 19, + }, + Ident( + "throws", + None, + ), + Location { + offset: 25, + line: 0, + col: 25, + }, + ), + Spanned( + Location { + offset: 28, + line: 0, + col: 28, + }, + Ident( + "execs", + None, + ), + Location { + offset: 33, + line: 0, + col: 33, + }, + ), + ], + Block( + [ + Spanned( + Location { + offset: 40, + line: 1, + col: 4, + }, + Prototype { + name: Spanned( + Location { + offset: 40, + line: 1, + col: 4, + }, + Ident( + "catch", + None, + ), + Location { + offset: 45, + line: 1, + col: 9, + }, + ), + args: [], + ret: None, + effects: [], + }, + Location { + offset: 50, + line: 1, + col: 14, + }, + ), + Spanned( + Location { + offset: 55, + line: 2, + col: 4, + }, + Prototype { + name: Spanned( + Location { + offset: 55, + line: 2, + col: 4, + }, + Ident( + "await", + Some( + [ + Spanned( + Location { + offset: 61, + line: 2, + col: 10, + }, + Ident( + "T", + None, + ), + Location { + offset: 62, + line: 2, + col: 11, + }, + ), + ], + ), + ), + Location { + offset: 63, + line: 2, + col: 12, + }, + ), + args: [ + Spanned( + Location { + offset: 64, + line: 2, + col: 13, + }, + Field( + Spanned( + Location { + offset: 64, + line: 2, + col: 13, + }, + FieldDef( + Spanned( + Location { + offset: 64, + line: 2, + col: 13, + }, + Private, + Location { + offset: 64, + line: 2, + col: 13, + }, + ), + Spanned( + Location { + offset: 64, + line: 2, + col: 13, + }, + Ident( + "f", + None, + ), + Location { + offset: 65, + line: 2, + col: 14, + }, + ), + Spanned( + Location { + offset: 67, + line: 2, + col: 16, + }, + Ident( + "Future", + Some( + [ + Spanned( + Location { + offset: 74, + line: 2, + col: 23, + }, + Ident( + "T", + None, + ), + Location { + offset: 75, + line: 2, + col: 24, + }, + ), + ], + ), + ), + Location { + offset: 76, + line: 2, + col: 25, + }, + ), + ), + Location { + offset: 76, + line: 2, + col: 25, + }, + ), + ), + Location { + offset: 76, + line: 2, + col: 25, + }, + ), + ], + ret: Some( + Spanned( + Location { + offset: 84, + line: 2, + col: 33, + }, + Ident( + "T", + None, + ), + Location { + offset: 85, + line: 2, + col: 34, + }, + ), + ), + effects: [], + }, + Location { + offset: 85, + line: 2, + col: 34, + }, + ), + Spanned( + Location { + offset: 90, + line: 3, + col: 4, + }, + Prototype { + name: Spanned( + Location { + offset: 90, + line: 3, + col: 4, + }, + Ident( + "exec", + None, + ), + Location { + offset: 94, + line: 3, + col: 8, + }, + ), + args: [ + Spanned( + Location { + offset: 95, + line: 3, + col: 9, + }, + Field( + Spanned( + Location { + offset: 95, + line: 3, + col: 9, + }, + FieldDef( + Spanned( + Location { + offset: 95, + line: 3, + col: 9, + }, + Private, + Location { + offset: 95, + line: 3, + col: 9, + }, + ), + Spanned( + Location { + offset: 95, + line: 3, + col: 9, + }, + Ident( + "arg0", + None, + ), + Location { + offset: 99, + line: 3, + col: 13, + }, + ), + Spanned( + Location { + offset: 101, + line: 3, + col: 15, + }, + Ident( + "string", + None, + ), + Location { + offset: 107, + line: 3, + col: 21, + }, + ), + ), + Location { + offset: 107, + line: 3, + col: 21, + }, + ), + ), + Location { + offset: 107, + line: 3, + col: 21, + }, + ), + Spanned( + Location { + offset: 109, + line: 3, + col: 23, + }, + Field( + Spanned( + Location { + offset: 109, + line: 3, + col: 23, + }, + FieldDef( + Spanned( + Location { + offset: 109, + line: 3, + col: 23, + }, + Private, + Location { + offset: 109, + line: 3, + col: 23, + }, + ), + Spanned( + Location { + offset: 109, + line: 3, + col: 23, + }, + Ident( + "args", + None, + ), + Location { + offset: 113, + line: 3, + col: 27, + }, + ), + Spanned( + Location { + offset: 115, + line: 3, + col: 29, + }, + Ident( + "stringvec", + None, + ), + Location { + offset: 124, + line: 3, + col: 38, + }, + ), + ), + Location { + offset: 124, + line: 3, + col: 38, + }, + ), + ), + Location { + offset: 124, + line: 3, + col: 38, + }, + ), + ], + ret: None, + effects: [], + }, + Location { + offset: 128, + line: 3, + col: 42, + }, + ), + ], + ), + ), + ), + Location { + offset: 130, + line: 4, + col: 1, + }, + ), + ], +) diff --git a/src/parser/snapshots/srclang__parser__parser_snap_tests__enum_parser.snap b/src/parser/snapshots/srclang__parser__parser_snap_tests__enum_parser.snap new file mode 100644 index 0000000..562bcca --- /dev/null +++ b/src/parser/snapshots/srclang__parser__parser_snap_tests__enum_parser.snap @@ -0,0 +1,2506 @@ +--- +source: src/parser/parser_snap_tests.rs +expression: "format!(\"{:#?}\", t.unwrap())" +--- +Module( + [ + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + UseDef( + UseDef( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Use, + Location { + offset: 3, + line: 0, + col: 3, + }, + ), + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Private, + Location { + offset: 0, + line: 0, + col: 0, + }, + ), + ), + Location { + offset: 3, + line: 0, + col: 3, + }, + ), + [ + Spanned( + Location { + offset: 6, + line: 0, + col: 6, + }, + Ident( + "exec", + None, + ), + Location { + offset: 10, + line: 0, + col: 10, + }, + ), + ], + Spanned( + Location { + offset: 18, + line: 0, + col: 18, + }, + Ident( + "host", + None, + ), + Location { + offset: 22, + line: 0, + col: 22, + }, + ), + ), + ), + Location { + offset: 22, + line: 0, + col: 22, + }, + ), + Spanned( + Location { + offset: 24, + line: 2, + col: 0, + }, + EffectDef( + EffectDef( + Spanned( + Location { + offset: 24, + line: 2, + col: 0, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 24, + line: 2, + col: 0, + }, + Effect, + Location { + offset: 30, + line: 2, + col: 6, + }, + ), + Spanned( + Location { + offset: 24, + line: 2, + col: 0, + }, + Private, + Location { + offset: 24, + line: 2, + col: 0, + }, + ), + ), + Location { + offset: 30, + line: 2, + col: 6, + }, + ), + Spanned( + Location { + offset: 31, + line: 2, + col: 7, + }, + Ident( + "Make", + None, + ), + Location { + offset: 35, + line: 2, + col: 11, + }, + ), + [ + Spanned( + Location { + offset: 37, + line: 2, + col: 13, + }, + Ident( + "async", + None, + ), + Location { + offset: 42, + line: 2, + col: 18, + }, + ), + Spanned( + Location { + offset: 45, + line: 2, + col: 21, + }, + Ident( + "throws", + None, + ), + Location { + offset: 51, + line: 2, + col: 27, + }, + ), + Spanned( + Location { + offset: 54, + line: 2, + col: 30, + }, + Ident( + "execs", + None, + ), + Location { + offset: 59, + line: 2, + col: 35, + }, + ), + Spanned( + Location { + offset: 62, + line: 2, + col: 38, + }, + Ident( + "reads", + None, + ), + Location { + offset: 67, + line: 2, + col: 43, + }, + ), + Spanned( + Location { + offset: 70, + line: 2, + col: 46, + }, + Ident( + "writes", + None, + ), + Location { + offset: 76, + line: 2, + col: 52, + }, + ), + ], + Block( + [ + Spanned( + Location { + offset: 83, + line: 3, + col: 4, + }, + Prototype { + name: Spanned( + Location { + offset: 83, + line: 3, + col: 4, + }, + Ident( + "catch", + None, + ), + Location { + offset: 88, + line: 3, + col: 9, + }, + ), + args: [], + ret: None, + effects: [ + Spanned( + Location { + offset: 92, + line: 3, + col: 13, + }, + Ident( + "throws", + None, + ), + Location { + offset: 98, + line: 3, + col: 19, + }, + ), + ], + }, + Location { + offset: 99, + line: 3, + col: 20, + }, + ), + Spanned( + Location { + offset: 104, + line: 4, + col: 4, + }, + Prototype { + name: Spanned( + Location { + offset: 104, + line: 4, + col: 4, + }, + Ident( + "await", + Some( + [ + Spanned( + Location { + offset: 110, + line: 4, + col: 10, + }, + Ident( + "T", + None, + ), + Location { + offset: 111, + line: 4, + col: 11, + }, + ), + ], + ), + ), + Location { + offset: 112, + line: 4, + col: 12, + }, + ), + args: [ + Spanned( + Location { + offset: 113, + line: 4, + col: 13, + }, + Field( + Spanned( + Location { + offset: 113, + line: 4, + col: 13, + }, + FieldDef( + Spanned( + Location { + offset: 113, + line: 4, + col: 13, + }, + Private, + Location { + offset: 113, + line: 4, + col: 13, + }, + ), + Spanned( + Location { + offset: 113, + line: 4, + col: 13, + }, + Ident( + "f", + None, + ), + Location { + offset: 114, + line: 4, + col: 14, + }, + ), + Spanned( + Location { + offset: 116, + line: 4, + col: 16, + }, + Ident( + "Future", + Some( + [ + Spanned( + Location { + offset: 123, + line: 4, + col: 23, + }, + Ident( + "T", + None, + ), + Location { + offset: 124, + line: 4, + col: 24, + }, + ), + ], + ), + ), + Location { + offset: 125, + line: 4, + col: 25, + }, + ), + ), + Location { + offset: 125, + line: 4, + col: 25, + }, + ), + ), + Location { + offset: 125, + line: 4, + col: 25, + }, + ), + ], + ret: Some( + Spanned( + Location { + offset: 146, + line: 4, + col: 46, + }, + Ident( + "T", + None, + ), + Location { + offset: 147, + line: 4, + col: 47, + }, + ), + ), + effects: [ + Spanned( + Location { + offset: 128, + line: 4, + col: 28, + }, + Ident( + "async", + None, + ), + Location { + offset: 133, + line: 4, + col: 33, + }, + ), + Spanned( + Location { + offset: 135, + line: 4, + col: 35, + }, + Ident( + "throws", + None, + ), + Location { + offset: 141, + line: 4, + col: 41, + }, + ), + ], + }, + Location { + offset: 147, + line: 4, + col: 47, + }, + ), + Spanned( + Location { + offset: 152, + line: 5, + col: 4, + }, + Prototype { + name: Spanned( + Location { + offset: 152, + line: 5, + col: 4, + }, + Ident( + "exec", + None, + ), + Location { + offset: 156, + line: 5, + col: 8, + }, + ), + args: [ + Spanned( + Location { + offset: 157, + line: 5, + col: 9, + }, + Field( + Spanned( + Location { + offset: 157, + line: 5, + col: 9, + }, + FieldDef( + Spanned( + Location { + offset: 157, + line: 5, + col: 9, + }, + Private, + Location { + offset: 157, + line: 5, + col: 9, + }, + ), + Spanned( + Location { + offset: 157, + line: 5, + col: 9, + }, + Ident( + "arg0", + None, + ), + Location { + offset: 161, + line: 5, + col: 13, + }, + ), + Spanned( + Location { + offset: 163, + line: 5, + col: 15, + }, + Ident( + "string", + None, + ), + Location { + offset: 169, + line: 5, + col: 21, + }, + ), + ), + Location { + offset: 169, + line: 5, + col: 21, + }, + ), + ), + Location { + offset: 169, + line: 5, + col: 21, + }, + ), + Spanned( + Location { + offset: 171, + line: 5, + col: 23, + }, + Field( + Spanned( + Location { + offset: 171, + line: 5, + col: 23, + }, + FieldDef( + Spanned( + Location { + offset: 171, + line: 5, + col: 23, + }, + Private, + Location { + offset: 171, + line: 5, + col: 23, + }, + ), + Spanned( + Location { + offset: 171, + line: 5, + col: 23, + }, + Ident( + "args", + None, + ), + Location { + offset: 175, + line: 5, + col: 27, + }, + ), + Spanned( + Location { + offset: 177, + line: 5, + col: 29, + }, + Ident( + "stringvec", + None, + ), + Location { + offset: 186, + line: 5, + col: 38, + }, + ), + ), + Location { + offset: 186, + line: 5, + col: 38, + }, + ), + ), + Location { + offset: 186, + line: 5, + col: 38, + }, + ), + ], + ret: Some( + Spanned( + Location { + offset: 198, + line: 5, + col: 50, + }, + Ident( + "i32", + None, + ), + Location { + offset: 201, + line: 5, + col: 53, + }, + ), + ), + effects: [ + Spanned( + Location { + offset: 189, + line: 5, + col: 41, + }, + Ident( + "Make", + None, + ), + Location { + offset: 193, + line: 5, + col: 45, + }, + ), + ], + }, + Location { + offset: 201, + line: 5, + col: 53, + }, + ), + Spanned( + Location { + offset: 206, + line: 6, + col: 4, + }, + Prototype { + name: Spanned( + Location { + offset: 206, + line: 6, + col: 4, + }, + Ident( + "read", + None, + ), + Location { + offset: 210, + line: 6, + col: 8, + }, + ), + args: [ + Spanned( + Location { + offset: 211, + line: 6, + col: 9, + }, + Field( + Spanned( + Location { + offset: 211, + line: 6, + col: 9, + }, + FieldDef( + Spanned( + Location { + offset: 211, + line: 6, + col: 9, + }, + Private, + Location { + offset: 211, + line: 6, + col: 9, + }, + ), + Spanned( + Location { + offset: 211, + line: 6, + col: 9, + }, + Ident( + "name", + None, + ), + Location { + offset: 215, + line: 6, + col: 13, + }, + ), + Spanned( + Location { + offset: 217, + line: 6, + col: 15, + }, + Ident( + "string", + None, + ), + Location { + offset: 223, + line: 6, + col: 21, + }, + ), + ), + Location { + offset: 223, + line: 6, + col: 21, + }, + ), + ), + Location { + offset: 223, + line: 6, + col: 21, + }, + ), + ], + ret: Some( + Spanned( + Location { + offset: 236, + line: 6, + col: 34, + }, + Ident( + "string", + None, + ), + Location { + offset: 242, + line: 6, + col: 40, + }, + ), + ), + effects: [ + Spanned( + Location { + offset: 226, + line: 6, + col: 24, + }, + Ident( + "reads", + None, + ), + Location { + offset: 231, + line: 6, + col: 29, + }, + ), + ], + }, + Location { + offset: 242, + line: 6, + col: 40, + }, + ), + Spanned( + Location { + offset: 247, + line: 7, + col: 4, + }, + Prototype { + name: Spanned( + Location { + offset: 247, + line: 7, + col: 4, + }, + Ident( + "write", + None, + ), + Location { + offset: 252, + line: 7, + col: 9, + }, + ), + args: [ + Spanned( + Location { + offset: 253, + line: 7, + col: 10, + }, + Field( + Spanned( + Location { + offset: 253, + line: 7, + col: 10, + }, + FieldDef( + Spanned( + Location { + offset: 253, + line: 7, + col: 10, + }, + Private, + Location { + offset: 253, + line: 7, + col: 10, + }, + ), + Spanned( + Location { + offset: 253, + line: 7, + col: 10, + }, + Ident( + "name", + None, + ), + Location { + offset: 257, + line: 7, + col: 14, + }, + ), + Spanned( + Location { + offset: 259, + line: 7, + col: 16, + }, + Ident( + "string", + None, + ), + Location { + offset: 265, + line: 7, + col: 22, + }, + ), + ), + Location { + offset: 265, + line: 7, + col: 22, + }, + ), + ), + Location { + offset: 265, + line: 7, + col: 22, + }, + ), + Spanned( + Location { + offset: 267, + line: 7, + col: 24, + }, + Field( + Spanned( + Location { + offset: 267, + line: 7, + col: 24, + }, + FieldDef( + Spanned( + Location { + offset: 267, + line: 7, + col: 24, + }, + Private, + Location { + offset: 267, + line: 7, + col: 24, + }, + ), + Spanned( + Location { + offset: 267, + line: 7, + col: 24, + }, + Ident( + "value", + None, + ), + Location { + offset: 272, + line: 7, + col: 29, + }, + ), + Spanned( + Location { + offset: 274, + line: 7, + col: 31, + }, + Ident( + "string", + None, + ), + Location { + offset: 280, + line: 7, + col: 37, + }, + ), + ), + Location { + offset: 280, + line: 7, + col: 37, + }, + ), + ), + Location { + offset: 280, + line: 7, + col: 37, + }, + ), + ], + ret: None, + effects: [ + Spanned( + Location { + offset: 283, + line: 7, + col: 40, + }, + Ident( + "writes", + None, + ), + Location { + offset: 289, + line: 7, + col: 46, + }, + ), + ], + }, + Location { + offset: 290, + line: 7, + col: 47, + }, + ), + ], + ), + ), + ), + Location { + offset: 292, + line: 8, + col: 1, + }, + ), + Spanned( + Location { + offset: 294, + line: 10, + col: 0, + }, + StructDef( + StructDef( + Spanned( + Location { + offset: 294, + line: 10, + col: 0, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 294, + line: 10, + col: 0, + }, + Struct, + Location { + offset: 300, + line: 10, + col: 6, + }, + ), + Spanned( + Location { + offset: 294, + line: 10, + col: 0, + }, + Private, + Location { + offset: 294, + line: 10, + col: 0, + }, + ), + ), + Location { + offset: 300, + line: 10, + col: 6, + }, + ), + Spanned( + Location { + offset: 301, + line: 10, + col: 7, + }, + Ident( + "Local", + None, + ), + Location { + offset: 306, + line: 10, + col: 12, + }, + ), + Block( + [ + Spanned( + Location { + offset: 313, + line: 11, + col: 4, + }, + FieldDef( + Spanned( + Location { + offset: 313, + line: 11, + col: 4, + }, + Private, + Location { + offset: 313, + line: 11, + col: 4, + }, + ), + Spanned( + Location { + offset: 313, + line: 11, + col: 4, + }, + Ident( + "host", + None, + ), + Location { + offset: 317, + line: 11, + col: 8, + }, + ), + Spanned( + Location { + offset: 319, + line: 11, + col: 10, + }, + Ident( + "host", + None, + ), + Location { + offset: 323, + line: 11, + col: 14, + }, + ), + ), + Location { + offset: 323, + line: 11, + col: 14, + }, + ), + ], + ), + ), + ), + Location { + offset: 325, + line: 12, + col: 1, + }, + ), + Spanned( + Location { + offset: 327, + line: 14, + col: 0, + }, + ImplDef( + ImplDef( + Spanned( + Location { + offset: 327, + line: 14, + col: 0, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 327, + line: 14, + col: 0, + }, + Impl, + Location { + offset: 331, + line: 14, + col: 4, + }, + ), + Spanned( + Location { + offset: 327, + line: 14, + col: 0, + }, + Private, + Location { + offset: 327, + line: 14, + col: 0, + }, + ), + ), + Location { + offset: 331, + line: 14, + col: 4, + }, + ), + Spanned( + Location { + offset: 332, + line: 14, + col: 5, + }, + Ident( + "Make", + None, + ), + Location { + offset: 336, + line: 14, + col: 9, + }, + ), + Some( + Spanned( + Location { + offset: 341, + line: 14, + col: 14, + }, + Ident( + "Local", + None, + ), + Location { + offset: 346, + line: 14, + col: 19, + }, + ), + ), + Block( + [ + Spanned( + Location { + offset: 353, + line: 15, + col: 4, + }, + FnDef( + FnDef( + Spanned( + Location { + offset: 353, + line: 15, + col: 4, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 353, + line: 15, + col: 4, + }, + Fn, + Location { + offset: 355, + line: 15, + col: 6, + }, + ), + Spanned( + Location { + offset: 353, + line: 15, + col: 4, + }, + Private, + Location { + offset: 353, + line: 15, + col: 4, + }, + ), + ), + Location { + offset: 355, + line: 15, + col: 6, + }, + ), + Spanned( + Location { + offset: 356, + line: 15, + col: 7, + }, + Prototype { + name: Spanned( + Location { + offset: 356, + line: 15, + col: 7, + }, + Ident( + "catch", + None, + ), + Location { + offset: 361, + line: 15, + col: 12, + }, + ), + args: [ + Spanned( + Location { + offset: 362, + line: 15, + col: 13, + }, + Reciever, + Location { + offset: 366, + line: 15, + col: 17, + }, + ), + ], + ret: None, + effects: [ + Spanned( + Location { + offset: 369, + line: 15, + col: 20, + }, + Ident( + "throws", + None, + ), + Location { + offset: 375, + line: 15, + col: 26, + }, + ), + ], + }, + Location { + offset: 376, + line: 15, + col: 27, + }, + ), + Block( + [], + ), + ), + ), + Location { + offset: 384, + line: 16, + col: 5, + }, + ), + Spanned( + Location { + offset: 389, + line: 17, + col: 4, + }, + FnDef( + FnDef( + Spanned( + Location { + offset: 389, + line: 17, + col: 4, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 389, + line: 17, + col: 4, + }, + Fn, + Location { + offset: 391, + line: 17, + col: 6, + }, + ), + Spanned( + Location { + offset: 389, + line: 17, + col: 4, + }, + Private, + Location { + offset: 389, + line: 17, + col: 4, + }, + ), + ), + Location { + offset: 391, + line: 17, + col: 6, + }, + ), + Spanned( + Location { + offset: 392, + line: 17, + col: 7, + }, + Prototype { + name: Spanned( + Location { + offset: 392, + line: 17, + col: 7, + }, + Ident( + "await", + Some( + [ + Spanned( + Location { + offset: 398, + line: 17, + col: 13, + }, + Ident( + "T", + None, + ), + Location { + offset: 399, + line: 17, + col: 14, + }, + ), + ], + ), + ), + Location { + offset: 400, + line: 17, + col: 15, + }, + ), + args: [ + Spanned( + Location { + offset: 401, + line: 17, + col: 16, + }, + Field( + Spanned( + Location { + offset: 401, + line: 17, + col: 16, + }, + FieldDef( + Spanned( + Location { + offset: 401, + line: 17, + col: 16, + }, + Private, + Location { + offset: 401, + line: 17, + col: 16, + }, + ), + Spanned( + Location { + offset: 401, + line: 17, + col: 16, + }, + Ident( + "f", + None, + ), + Location { + offset: 402, + line: 17, + col: 17, + }, + ), + Spanned( + Location { + offset: 404, + line: 17, + col: 19, + }, + Ident( + "Future", + Some( + [ + Spanned( + Location { + offset: 411, + line: 17, + col: 26, + }, + Ident( + "T", + None, + ), + Location { + offset: 412, + line: 17, + col: 27, + }, + ), + ], + ), + ), + Location { + offset: 413, + line: 17, + col: 28, + }, + ), + ), + Location { + offset: 413, + line: 17, + col: 28, + }, + ), + ), + Location { + offset: 413, + line: 17, + col: 28, + }, + ), + ], + ret: Some( + Spanned( + Location { + offset: 434, + line: 17, + col: 49, + }, + Ident( + "T", + None, + ), + Location { + offset: 435, + line: 17, + col: 50, + }, + ), + ), + effects: [ + Spanned( + Location { + offset: 416, + line: 17, + col: 31, + }, + Ident( + "async", + None, + ), + Location { + offset: 421, + line: 17, + col: 36, + }, + ), + Spanned( + Location { + offset: 423, + line: 17, + col: 38, + }, + Ident( + "trhows", + None, + ), + Location { + offset: 429, + line: 17, + col: 44, + }, + ), + ], + }, + Location { + offset: 435, + line: 17, + col: 50, + }, + ), + Block( + [ + Spanned( + Location { + offset: 446, + line: 18, + col: 8, + }, + FnCall( + FnCall( + Spanned( + Location { + offset: 446, + line: 18, + col: 8, + }, + Ident( + "yield", + None, + ), + Location { + offset: 451, + line: 18, + col: 13, + }, + ), + [], + ), + ), + Location { + offset: 453, + line: 18, + col: 15, + }, + ), + ], + ), + ), + ), + Location { + offset: 459, + line: 19, + col: 5, + }, + ), + Spanned( + Location { + offset: 464, + line: 20, + col: 4, + }, + FnDef( + FnDef( + Spanned( + Location { + offset: 464, + line: 20, + col: 4, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 464, + line: 20, + col: 4, + }, + Fn, + Location { + offset: 466, + line: 20, + col: 6, + }, + ), + Spanned( + Location { + offset: 464, + line: 20, + col: 4, + }, + Private, + Location { + offset: 464, + line: 20, + col: 4, + }, + ), + ), + Location { + offset: 466, + line: 20, + col: 6, + }, + ), + Spanned( + Location { + offset: 467, + line: 20, + col: 7, + }, + Prototype { + name: Spanned( + Location { + offset: 467, + line: 20, + col: 7, + }, + Ident( + "exec", + None, + ), + Location { + offset: 471, + line: 20, + col: 11, + }, + ), + args: [ + Spanned( + Location { + offset: 472, + line: 20, + col: 12, + }, + Reciever, + Location { + offset: 476, + line: 20, + col: 16, + }, + ), + Spanned( + Location { + offset: 478, + line: 20, + col: 18, + }, + Field( + Spanned( + Location { + offset: 478, + line: 20, + col: 18, + }, + FieldDef( + Spanned( + Location { + offset: 478, + line: 20, + col: 18, + }, + Private, + Location { + offset: 478, + line: 20, + col: 18, + }, + ), + Spanned( + Location { + offset: 478, + line: 20, + col: 18, + }, + Ident( + "arg0", + None, + ), + Location { + offset: 482, + line: 20, + col: 22, + }, + ), + Spanned( + Location { + offset: 484, + line: 20, + col: 24, + }, + Ident( + "string", + None, + ), + Location { + offset: 490, + line: 20, + col: 30, + }, + ), + ), + Location { + offset: 490, + line: 20, + col: 30, + }, + ), + ), + Location { + offset: 490, + line: 20, + col: 30, + }, + ), + Spanned( + Location { + offset: 492, + line: 20, + col: 32, + }, + Field( + Spanned( + Location { + offset: 492, + line: 20, + col: 32, + }, + FieldDef( + Spanned( + Location { + offset: 492, + line: 20, + col: 32, + }, + Private, + Location { + offset: 492, + line: 20, + col: 32, + }, + ), + Spanned( + Location { + offset: 492, + line: 20, + col: 32, + }, + Ident( + "args", + None, + ), + Location { + offset: 496, + line: 20, + col: 36, + }, + ), + Spanned( + Location { + offset: 498, + line: 20, + col: 38, + }, + Ident( + "vec", + Some( + [ + Spanned( + Location { + offset: 502, + line: 20, + col: 42, + }, + Ident( + "string", + None, + ), + Location { + offset: 508, + line: 20, + col: 48, + }, + ), + ], + ), + ), + Location { + offset: 509, + line: 20, + col: 49, + }, + ), + ), + Location { + offset: 509, + line: 20, + col: 49, + }, + ), + ), + Location { + offset: 509, + line: 20, + col: 49, + }, + ), + ], + ret: Some( + Spanned( + Location { + offset: 519, + line: 20, + col: 59, + }, + Ident( + "i32", + None, + ), + Location { + offset: 522, + line: 20, + col: 62, + }, + ), + ), + effects: [ + Spanned( + Location { + offset: 512, + line: 20, + col: 52, + }, + Ident( + "Vm", + None, + ), + Location { + offset: 514, + line: 20, + col: 54, + }, + ), + ], + }, + Location { + offset: 522, + line: 20, + col: 62, + }, + ), + Block( + [ + Spanned( + Location { + offset: 533, + line: 21, + col: 8, + }, + FieldAccess( + FieldAccess( + Spanned( + Location { + offset: 533, + line: 21, + col: 8, + }, + FieldAccess( + FieldAccess( + Spanned( + Location { + offset: 533, + line: 21, + col: 8, + }, + FieldAccess( + FieldAccess( + Spanned( + Location { + offset: 533, + line: 21, + col: 8, + }, + Ident( + Spanned( + Location { + offset: 533, + line: 21, + col: 8, + }, + Ident( + "self", + None, + ), + Location { + offset: 537, + line: 21, + col: 12, + }, + ), + ), + Location { + offset: 537, + line: 21, + col: 12, + }, + ), + Spanned( + Location { + offset: 538, + line: 21, + col: 13, + }, + Ident( + Spanned( + Location { + offset: 538, + line: 21, + col: 13, + }, + Ident( + "host", + None, + ), + Location { + offset: 542, + line: 21, + col: 17, + }, + ), + ), + Location { + offset: 542, + line: 21, + col: 17, + }, + ), + ), + ), + Location { + offset: 542, + line: 21, + col: 17, + }, + ), + Spanned( + Location { + offset: 543, + line: 21, + col: 18, + }, + FnCall( + FnCall( + Spanned( + Location { + offset: 543, + line: 21, + col: 18, + }, + Ident( + "read", + None, + ), + Location { + offset: 547, + line: 21, + col: 22, + }, + ), + [ + Spanned( + Location { + offset: 548, + line: 21, + col: 23, + }, + String( + "jobserver", + ), + Location { + offset: 559, + line: 21, + col: 34, + }, + ), + ], + ), + ), + Location { + offset: 560, + line: 21, + col: 35, + }, + ), + ), + ), + Location { + offset: 560, + line: 21, + col: 35, + }, + ), + Spanned( + Location { + offset: 561, + line: 21, + col: 36, + }, + Ident( + Spanned( + Location { + offset: 561, + line: 21, + col: 36, + }, + Ident( + "await", + None, + ), + Location { + offset: 566, + line: 21, + col: 41, + }, + ), + ), + Location { + offset: 566, + line: 21, + col: 41, + }, + ), + ), + ), + Location { + offset: 566, + line: 21, + col: 41, + }, + ), + Spanned( + Location { + offset: 575, + line: 22, + col: 8, + }, + Branch( + BranchDef( + Spanned( + Location { + offset: 578, + line: 22, + col: 11, + }, + FieldAccess( + FieldAccess( + Spanned( + Location { + offset: 578, + line: 22, + col: 11, + }, + FieldAccess( + FieldAccess( + Spanned( + Location { + offset: 578, + line: 22, + col: 11, + }, + FieldAccess( + FieldAccess( + Spanned( + Location { + offset: 578, + line: 22, + col: 11, + }, + Ident( + Spanned( + Location { + offset: 578, + line: 22, + col: 11, + }, + Ident( + "self", + None, + ), + Location { + offset: 582, + line: 22, + col: 15, + }, + ), + ), + Location { + offset: 582, + line: 22, + col: 15, + }, + ), + Spanned( + Location { + offset: 583, + line: 22, + col: 16, + }, + Ident( + Spanned( + Location { + offset: 583, + line: 22, + col: 16, + }, + Ident( + "host", + None, + ), + Location { + offset: 587, + line: 22, + col: 20, + }, + ), + ), + Location { + offset: 587, + line: 22, + col: 20, + }, + ), + ), + ), + Location { + offset: 587, + line: 22, + col: 20, + }, + ), + Spanned( + Location { + offset: 588, + line: 22, + col: 21, + }, + FnCall( + FnCall( + Spanned( + Location { + offset: 588, + line: 22, + col: 21, + }, + Ident( + "exec", + None, + ), + Location { + offset: 592, + line: 22, + col: 25, + }, + ), + [ + Spanned( + Location { + offset: 593, + line: 22, + col: 26, + }, + Ident( + Spanned( + Location { + offset: 593, + line: 22, + col: 26, + }, + Ident( + "arg0", + None, + ), + Location { + offset: 597, + line: 22, + col: 30, + }, + ), + ), + Location { + offset: 597, + line: 22, + col: 30, + }, + ), + Spanned( + Location { + offset: 599, + line: 22, + col: 32, + }, + Ident( + Spanned( + Location { + offset: 599, + line: 22, + col: 32, + }, + Ident( + "args", + None, + ), + Location { + offset: 603, + line: 22, + col: 36, + }, + ), + ), + Location { + offset: 603, + line: 22, + col: 36, + }, + ), + ], + ), + ), + Location { + offset: 604, + line: 22, + col: 37, + }, + ), + ), + ), + Location { + offset: 604, + line: 22, + col: 37, + }, + ), + Spanned( + Location { + offset: 605, + line: 22, + col: 38, + }, + Ident( + Spanned( + Location { + offset: 605, + line: 22, + col: 38, + }, + Ident( + "await", + None, + ), + Location { + offset: 610, + line: 22, + col: 43, + }, + ), + ), + Location { + offset: 610, + line: 22, + col: 43, + }, + ), + ), + ), + Location { + offset: 610, + line: 22, + col: 43, + }, + ), + [ + ( + Spanned( + Location { + offset: 575, + line: 22, + col: 8, + }, + Bool( + true, + ), + Location { + offset: 578, + line: 22, + col: 11, + }, + ), + Block( + [ + Spanned( + Location { + offset: 625, + line: 23, + col: 12, + }, + FnCall( + FnCall( + Spanned( + Location { + offset: 625, + line: 23, + col: 12, + }, + Ident( + "raise", + None, + ), + Location { + offset: 630, + line: 23, + col: 17, + }, + ), + [ + Spanned( + Location { + offset: 631, + line: 23, + col: 18, + }, + Integer( + 1, + ), + Location { + offset: 632, + line: 23, + col: 19, + }, + ), + ], + ), + ), + Location { + offset: 633, + line: 23, + col: 20, + }, + ), + ], + ), + ), + ], + ), + ), + Location { + offset: 643, + line: 24, + col: 9, + }, + ), + ], + ), + ), + ), + Location { + offset: 649, + line: 25, + col: 5, + }, + ), + ], + ), + ), + ), + Location { + offset: 651, + line: 26, + col: 1, + }, + ), + ], +) diff --git a/src/parser/snapshots/srclang__parser__parser_snap_tests__fn_call_parser_with_multiple_args_and_strings.snap b/src/parser/snapshots/srclang__parser__parser_snap_tests__fn_call_parser_with_multiple_args_and_strings.snap new file mode 100644 index 0000000..215e4eb --- /dev/null +++ b/src/parser/snapshots/srclang__parser__parser_snap_tests__fn_call_parser_with_multiple_args_and_strings.snap @@ -0,0 +1,212 @@ +--- +source: src/parser/parser_snap_tests.rs +expression: "format!(\"{:#?}\", t.unwrap())" +--- +Module( + [ + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + FnDef( + FnDef( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Fn, + Location { + offset: 2, + line: 0, + col: 2, + }, + ), + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Private, + Location { + offset: 0, + line: 0, + col: 0, + }, + ), + ), + Location { + offset: 2, + line: 0, + col: 2, + }, + ), + Spanned( + Location { + offset: 3, + line: 0, + col: 3, + }, + Prototype { + name: Spanned( + Location { + offset: 3, + line: 0, + col: 3, + }, + Ident( + "some", + None, + ), + Location { + offset: 7, + line: 0, + col: 7, + }, + ), + args: [], + ret: None, + effects: [], + }, + Location { + offset: 11, + line: 0, + col: 11, + }, + ), + Block( + [ + Spanned( + Location { + offset: 13, + line: 0, + col: 13, + }, + Binding( + Binding( + Spanned( + Location { + offset: 17, + line: 0, + col: 17, + }, + Ident( + "a", + None, + ), + Location { + offset: 18, + line: 0, + col: 18, + }, + ), + Spanned( + Location { + offset: 21, + line: 0, + col: 21, + }, + FnCall( + FnCall( + Spanned( + Location { + offset: 21, + line: 0, + col: 21, + }, + Ident( + "some_fnExpr", + None, + ), + Location { + offset: 32, + line: 0, + col: 32, + }, + ), + [ + Spanned( + Location { + offset: 33, + line: 0, + col: 33, + }, + Integer( + 1, + ), + Location { + offset: 34, + line: 0, + col: 34, + }, + ), + Spanned( + Location { + offset: 36, + line: 0, + col: 36, + }, + String( + "2", + ), + Location { + offset: 39, + line: 0, + col: 39, + }, + ), + Spanned( + Location { + offset: 41, + line: 0, + col: 41, + }, + Integer( + 3, + ), + Location { + offset: 42, + line: 0, + col: 42, + }, + ), + ], + ), + ), + Location { + offset: 43, + line: 0, + col: 43, + }, + ), + ), + ), + Location { + offset: 43, + line: 0, + col: 43, + }, + ), + ], + ), + ), + ), + Location { + offset: 44, + line: 0, + col: 44, + }, + ), + ], +) diff --git a/src/parser/snapshots/srclang__parser__parser_snap_tests__fn_def_parser.snap b/src/parser/snapshots/srclang__parser__parser_snap_tests__fn_def_parser.snap new file mode 100644 index 0000000..57b2aec --- /dev/null +++ b/src/parser/snapshots/srclang__parser__parser_snap_tests__fn_def_parser.snap @@ -0,0 +1,425 @@ +--- +source: src/parser/parser_snap_tests.rs +expression: "format!(\"{:#?}\", t.unwrap())" +--- +Module( + [ + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + FnDef( + FnDef( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Fn, + Location { + offset: 2, + line: 0, + col: 2, + }, + ), + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Private, + Location { + offset: 0, + line: 0, + col: 0, + }, + ), + ), + Location { + offset: 2, + line: 0, + col: 2, + }, + ), + Spanned( + Location { + offset: 3, + line: 0, + col: 3, + }, + Prototype { + name: Spanned( + Location { + offset: 3, + line: 0, + col: 3, + }, + Ident( + "call", + None, + ), + Location { + offset: 7, + line: 0, + col: 7, + }, + ), + args: [ + Spanned( + Location { + offset: 8, + line: 0, + col: 8, + }, + Field( + Spanned( + Location { + offset: 8, + line: 0, + col: 8, + }, + FieldDef( + Spanned( + Location { + offset: 8, + line: 0, + col: 8, + }, + Private, + Location { + offset: 8, + line: 0, + col: 8, + }, + ), + Spanned( + Location { + offset: 8, + line: 0, + col: 8, + }, + Ident( + "a", + None, + ), + Location { + offset: 9, + line: 0, + col: 9, + }, + ), + Spanned( + Location { + offset: 10, + line: 0, + col: 10, + }, + Ident( + "b", + None, + ), + Location { + offset: 11, + line: 0, + col: 11, + }, + ), + ), + Location { + offset: 11, + line: 0, + col: 11, + }, + ), + ), + Location { + offset: 11, + line: 0, + col: 11, + }, + ), + Spanned( + Location { + offset: 13, + line: 0, + col: 13, + }, + Field( + Spanned( + Location { + offset: 13, + line: 0, + col: 13, + }, + FieldDef( + Spanned( + Location { + offset: 13, + line: 0, + col: 13, + }, + Private, + Location { + offset: 13, + line: 0, + col: 13, + }, + ), + Spanned( + Location { + offset: 13, + line: 0, + col: 13, + }, + Ident( + "b", + None, + ), + Location { + offset: 14, + line: 0, + col: 14, + }, + ), + Spanned( + Location { + offset: 15, + line: 0, + col: 15, + }, + Ident( + "c", + None, + ), + Location { + offset: 16, + line: 0, + col: 16, + }, + ), + ), + Location { + offset: 16, + line: 0, + col: 16, + }, + ), + ), + Location { + offset: 16, + line: 0, + col: 16, + }, + ), + ], + ret: None, + effects: [ + Spanned( + Location { + offset: 19, + line: 0, + col: 19, + }, + Ident( + "throws", + None, + ), + Location { + offset: 25, + line: 0, + col: 25, + }, + ), + Spanned( + Location { + offset: 27, + line: 0, + col: 27, + }, + Ident( + "awaits", + None, + ), + Location { + offset: 33, + line: 0, + col: 33, + }, + ), + Spanned( + Location { + offset: 35, + line: 0, + col: 35, + }, + Ident( + "execs", + None, + ), + Location { + offset: 40, + line: 0, + col: 40, + }, + ), + ], + }, + Location { + offset: 41, + line: 0, + col: 41, + }, + ), + Block( + [ + Spanned( + Location { + offset: 48, + line: 1, + col: 4, + }, + FnCall( + FnCall( + Spanned( + Location { + offset: 48, + line: 1, + col: 4, + }, + Ident( + "call", + None, + ), + Location { + offset: 52, + line: 1, + col: 8, + }, + ), + [ + Spanned( + Location { + offset: 54, + line: 1, + col: 10, + }, + BinaryExpression( + BinaryOperation { + lhs: Spanned( + Location { + offset: 53, + line: 1, + col: 9, + }, + Integer( + 1, + ), + Location { + offset: 54, + line: 1, + col: 10, + }, + ), + op: Add, + rhs: Spanned( + Location { + offset: 55, + line: 1, + col: 11, + }, + Integer( + 1, + ), + Location { + offset: 56, + line: 1, + col: 12, + }, + ), + }, + ), + Location { + offset: 55, + line: 1, + col: 11, + }, + ), + ], + ), + ), + Location { + offset: 57, + line: 1, + col: 13, + }, + ), + Spanned( + Location { + offset: 62, + line: 2, + col: 4, + }, + Binding( + Binding( + Spanned( + Location { + offset: 66, + line: 2, + col: 8, + }, + Ident( + "a", + None, + ), + Location { + offset: 67, + line: 2, + col: 9, + }, + ), + Spanned( + Location { + offset: 70, + line: 2, + col: 12, + }, + Integer( + 1, + ), + Location { + offset: 71, + line: 2, + col: 13, + }, + ), + ), + ), + Location { + offset: 71, + line: 2, + col: 13, + }, + ), + ], + ), + ), + ), + Location { + offset: 73, + line: 3, + col: 1, + }, + ), + ], +) diff --git a/src/parser/snapshots/srclang__parser__parser_snap_tests__struct_parser.snap b/src/parser/snapshots/srclang__parser__parser_snap_tests__struct_parser.snap new file mode 100644 index 0000000..9e5847b --- /dev/null +++ b/src/parser/snapshots/srclang__parser__parser_snap_tests__struct_parser.snap @@ -0,0 +1,202 @@ +--- +source: src/parser/parser_snap_tests.rs +expression: "format!(\"{:#?}\", t.unwrap())" +--- +Module( + [ + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + StructDef( + StructDef( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + KeywordAndVisibility( + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Struct, + Location { + offset: 6, + line: 0, + col: 6, + }, + ), + Spanned( + Location { + offset: 0, + line: 0, + col: 0, + }, + Private, + Location { + offset: 0, + line: 0, + col: 0, + }, + ), + ), + Location { + offset: 6, + line: 0, + col: 6, + }, + ), + Spanned( + Location { + offset: 7, + line: 0, + col: 7, + }, + Ident( + "VM", + None, + ), + Location { + offset: 9, + line: 0, + col: 9, + }, + ), + Block( + [ + Spanned( + Location { + offset: 16, + line: 1, + col: 4, + }, + FieldDef( + Spanned( + Location { + offset: 16, + line: 1, + col: 4, + }, + Private, + Location { + offset: 16, + line: 1, + col: 4, + }, + ), + Spanned( + Location { + offset: 16, + line: 1, + col: 4, + }, + Ident( + "a", + None, + ), + Location { + offset: 17, + line: 1, + col: 5, + }, + ), + Spanned( + Location { + offset: 19, + line: 1, + col: 7, + }, + Ident( + "string", + None, + ), + Location { + offset: 25, + line: 1, + col: 13, + }, + ), + ), + Location { + offset: 25, + line: 1, + col: 13, + }, + ), + Spanned( + Location { + offset: 30, + line: 2, + col: 4, + }, + FieldDef( + Spanned( + Location { + offset: 30, + line: 2, + col: 4, + }, + Private, + Location { + offset: 30, + line: 2, + col: 4, + }, + ), + Spanned( + Location { + offset: 30, + line: 2, + col: 4, + }, + Ident( + "b", + None, + ), + Location { + offset: 31, + line: 2, + col: 5, + }, + ), + Spanned( + Location { + offset: 33, + line: 2, + col: 7, + }, + Ident( + "string", + None, + ), + Location { + offset: 39, + line: 2, + col: 13, + }, + ), + ), + Location { + offset: 39, + line: 2, + col: 13, + }, + ), + ], + ), + ), + ), + Location { + offset: 41, + line: 3, + col: 1, + }, + ), + ], +) diff --git a/versions.txt b/versions.txt index 5f107d7..864e6fd 100644 --- a/versions.txt +++ b/versions.txt @@ -1,2 +1,2 @@ -commit: e44388fca2c935661036e5da47c3d02618fd463e -version: e44388f +commit: 48fbcef0da25c64f1d998b7c979c28a9f8ee49f3 +version: 48fbcef