+
Skip to content

Big rewrite of the parser #41

New issue

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

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

Already on GitHub? Sign in to your account

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e3142ce
Fix inconsistencies in inputs
morr0ne Mar 28, 2025
a9b79d4
Create an initial skeleton for the new parser
morr0ne Mar 28, 2025
7d6dd41
Fix lua implementation
morr0ne Mar 28, 2025
935f6c4
Fix manifest
morr0ne Mar 28, 2025
ace884e
Implement custom deserializer and serializer for Value
morr0ne Mar 29, 2025
55324b4
Move value to its own module
morr0ne Mar 29, 2025
05a910c
Implement a custom integer type
morr0ne Mar 29, 2025
68ea73c
Implement value helpers
morr0ne Mar 29, 2025
fa63a50
Add a warning about missing docs
morr0ne Mar 29, 2025
72ef842
Improve error implementation
morr0ne Mar 29, 2025
dfe4526
Include the readme as the top level doc
morr0ne Mar 29, 2025
95c88b5
Avoid using a deprecated method for integer
morr0ne Mar 29, 2025
d6fdd99
Add myself to the authors
morr0ne Mar 29, 2025
ea9c6d2
Fix parser tests
morr0ne Mar 29, 2025
408f102
Initial deserializer structure implementation
morr0ne Mar 29, 2025
78a4e20
Implement null and booleans
morr0ne Mar 29, 2025
3f39f79
Implement basic integer and let block parsing
morr0ne Mar 29, 2025
8980ba2
Remove left over debug statements
morr0ne Mar 29, 2025
44e7aed
Add basic string parsing
morr0ne Apr 8, 2025
90b9597
Move sequence and object parsing to the bottom
morr0ne Apr 8, 2025
4b127fb
Forward all number deserialization to i64
morr0ne Apr 8, 2025
62033b4
Forward some more deserializer methods
morr0ne Apr 8, 2025
f07b825
Fix array and number parsing
morr0ne Apr 8, 2025
b53d8df
Fix string parser including quote character
morr0ne Apr 8, 2025
2a20261
Forward to deserialize any and include some positioning
morr0ne Apr 18, 2025
ddb1a97
Implement initial input parsing
morr0ne Apr 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
312 changes: 52 additions & 260 deletions Cargo.lock

Large diffs are not rendered by default.

53 changes: 18 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,72 +9,56 @@ license = "MIT"
description = "Parsing engine for Corn, a simple and pain-free configuration language."
repository = "https://github.com/JakeStanger/corn"
categories = ["config", "parsing"]
keywords = ["configuration", "language", "wasm", "pest", "peg"]
authors = ["Jake Stanger <mail@jakestanger.com>"]
keywords = ["configuration", "language", "wasm", "peg"]
authors = [
"Jake Stanger <mail@jakestanger.com>",
"Matilde Morrone <contact@morrone.dev>",
]
homepage = "https://cornlang.dev/"
documentation = "https://docs.rs/libcorn"
readme = "README.md"

[features]
# WASM support
wasm = [
"dep:wasm-bindgen",
"dep:serde-wasm-bindgen",
"dep:console_error_panic_hook",
"dep:wee_alloc",
]

# Lua version support
# Lua support
lua51 = ["dep:mlua", "mlua/lua51"]
lua52 = ["dep:mlua", "mlua/lua52"]
lua53 = ["dep:mlua", "mlua/lua53"]
lua54 = ["dep:mlua", "mlua/lua54"]
luajit = ["dep:mlua", "mlua/luajit"]
luajit52 = ["dep:mlua", "mlua/luajit52"]

# Internal features
bench = ["dep:criterion"]

[lib]
name = "corn"
crate-type = ["cdylib", "rlib"]

[dependencies]
# Core
pest = "2.7.15"
pest_derive = "2.7.15"
serde = { version = "1.0.218", features = ["derive"] }
indexmap = { version = "2.7.1", features = ["serde"] }

# Error handling
thiserror = "2.0.12"
serde = "1.0.219"
indexmap = { version = "2.8.0", features = ["serde"] }
itoa = "1.0.15"

# Utilities
cfg-if = "1.0.0"

# WASM support (optional)
wasm-bindgen = { version = "0.2.100", optional = true }
serde-wasm-bindgen = { version = "0.6.5", optional = true }
console_error_panic_hook = { version = "0.1.7", optional = true }
wee_alloc = { version = "0.4.5", optional = true }
# # WASM support (optional)
# wasm-bindgen = { version = "0.2.100", optional = true }
# serde-wasm-bindgen = { version = "0.6.5", optional = true }
# console_error_panic_hook = { version = "0.1.7", optional = true }

# Lua support (optional)
mlua = { version = "0.10.3", features = [
"module",
"macros",
"serialize",
], optional = true }

# Benchmarking (optional)
criterion = { version = "0.5.1", features = ["html_reports"], optional = true }
memchr = "2.7.4"

[dev-dependencies]
paste = "1.0.15"
wasm-bindgen-test = { version = "0.3.50" }
serde_json = "1.0.140"
serde_norway = "0.9.42"
serde_bytes = "0.11.16"
serde_bytes = "0.11.17"
toml_edit = { version = "0.22.24", features = ["serde"] }
anyhow = "1.0.97"
criterion = { version = "0.5.1", features = ["html_reports"] }
paste = "1.0.15"

[profile.release]
lto = true
Expand All @@ -84,4 +68,3 @@ strip = true
[[bench]]
name = "serde"
harness = false
required-features = ["bench"]
2 changes: 1 addition & 1 deletion assets/inputs/compact.corn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
seven={foo=[] bar=[]}

eight=["foo""bar"]
nine=[truefalse]
nine=[true false]
ten=[1 2]
eleven=[[][]]
twelve=[{}{}]
Expand Down
2 changes: 1 addition & 1 deletion assets/inputs/complex_keys.corn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
with_underscore = 0
with-dash = 1
with_🌽 = 2
!"£$%^&*()_ = 3
!£$%^&*()_ = 3
j12345 = 4
foo.bar-baz = "hello"
apple-pie.crust = "yum"
Expand Down
2 changes: 1 addition & 1 deletion assets/inputs/very_compact.corn
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{one={foo="bar" bar="foo"} two={foo=1 bar=2} three={foo=1.0 bar=2.0} four={foo=true bar=false} five={foo=null bar=null} six={foo={} bar={}} seven={foo=[] bar=[]} eight=["foo""bar"] nine=[truefalse] ten=[1 2] eleven=[[][]] twelve=[{}{}]}
{one={foo="bar" bar="foo"} two={foo=1 bar=2} three={foo=1.0 bar=2.0} four={foo=true bar=false} five={foo=null bar=null} six={foo={} bar={}} seven={foo=[] bar=[]} eight=["foo""bar"] nine=[true false] ten=[1 2] eleven=[[][]] twelve=[{}{}]}
12 changes: 6 additions & 6 deletions cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use colored::Colorize;
use corn::error::Error as CornError;
use corn::Error as CornError;
use std::fmt::{Display, Formatter};
use std::io;

Expand All @@ -21,11 +21,11 @@ impl ExitCode for CornError {
fn get_exit_code(&self) -> i32 {
match self {
CornError::Io(_) => 3,
CornError::ParserError(_) => 1,
CornError::InputResolveError(_) => 2,
CornError::InvalidPathError(_) => 6,
CornError::InvalidSpreadError(_) => 7,
CornError::InvalidInterpolationError(_) => 8,
// CornError::ParserError(_) => 1,
// CornError::InputResolveError(_) => 2,
// CornError::InvalidPathError(_) => 6,
// CornError::InvalidSpreadError(_) => 7,
// CornError::InvalidInterpolationError(_) => 8,
CornError::DeserializationError(_) => 5,
}
}
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use corn::{parse, Value};
use corn::Value;
use std::io::Read;
use std::process::exit;
use std::{fs, io};
Expand Down Expand Up @@ -47,7 +47,7 @@ fn main() {
Ok(unparsed_file) => {
let output_type = get_output_type(args.output_type);

match parse(&unparsed_file) {
match corn::from_str(&unparsed_file) {
Ok(config) => match serialize(&config, output_type) {
Ok(serialized) => println!("{serialized}"),
Err(err) => handle_err(&err),
Expand Down
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载