Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
d9ee317
for the sake of local develepment
s-ylide Apr 9, 2025
d872647
move to v0
s-ylide Apr 9, 2025
17d0d31
versioning within code
s-ylide Apr 9, 2025
b290c0d
add v1 syntax
s-ylide Apr 10, 2025
8c60d78
use 2024 edition
s-ylide Apr 10, 2025
6ab61a9
update alias
s-ylide Apr 15, 2025
24c9d03
add build script for parol
s-ylide Apr 17, 2025
626b2a8
update `Parse` interface
s-ylide Apr 17, 2025
b1faee1
create new package
s-ylide Apr 17, 2025
ec6bf22
update v1 syntax
s-ylide Apr 17, 2025
70f5aa6
add v1 grammar file
s-ylide Apr 24, 2025
0507cab
add primitive diag framework
s-ylide May 1, 2025
d4e86b5
update
s-ylide May 19, 2025
2d10703
update
s-ylide May 26, 2025
d24dca6
wip: testing
s-ylide May 28, 2025
a6d76ca
fix datetime regex
s-ylide May 30, 2025
460fbd2
fill todo!
s-ylide May 30, 2025
2b4e88d
fix suffix handling
s-ylide May 31, 2025
a8824a8
split decimal integer from float
s-ylide May 31, 2025
6b162b6
remove prefix from literals
s-ylide May 31, 2025
e94144c
remove feature flag
s-ylide Jun 5, 2025
d84df09
introduce new precedence group and move `&` to it
s-ylide Jun 5, 2025
8cbd6b4
ignore illustrative code
s-ylide Jul 1, 2025
bd766d4
rename
s-ylide Jul 1, 2025
72d9587
version assumption
s-ylide Jul 1, 2025
ac5e882
rename
s-ylide Jul 7, 2025
ecc7c04
add default
s-ylide Jul 8, 2025
9a9e534
add printer
s-ylide Jul 8, 2025
f2774b7
add trailing newline
s-ylide Jul 9, 2025
de01b4c
fix newline
s-ylide Jul 9, 2025
565e1cf
fix comment printing
s-ylide Jul 9, 2025
df17165
move `Context` (formerly `ParseContext`) to ast crate
s-ylide Jul 14, 2025
3ddb41c
export `VersionMarker`
s-ylide Jul 14, 2025
9f28e06
wrap &ExprKind as Expr
s-ylide Jul 14, 2025
7da0da5
assign span and position globally
s-ylide Jul 14, 2025
671fddd
generalize printability as PrintableFamily
s-ylide Jul 15, 2025
b8141e1
implement migration from v0 to v1
s-ylide Jul 15, 2025
d9d7a3c
remove unused items
s-ylide Jul 15, 2025
a88a469
fix fold order
s-ylide Jul 15, 2025
b2d5b9a
parentheses
s-ylide Jul 15, 2025
53403a1
remove unused option
s-ylide Jul 15, 2025
d2ed799
add deref
s-ylide Jul 15, 2025
b2c0657
fix comment spacing logic
s-ylide Jul 15, 2025
480178d
add formatter
s-ylide Jul 15, 2025
0108bb3
format test
s-ylide Jul 15, 2025
3eae611
formatter: support dir input
s-ylide Jul 15, 2025
c82d025
update CLI options
s-ylide Jul 15, 2025
823b10e
update migration metadata message
s-ylide Jul 15, 2025
04ab3c6
support reserving space for break token
s-ylide Jul 15, 2025
b8f2cb9
ignore migrated files
s-ylide Jul 15, 2025
c21c4e6
remove unused items, suppress trailing spaces
s-ylide Jul 15, 2025
181a741
fix migration logic
s-ylide Jul 15, 2025
920caa7
preserve space between `#` and non-space in v0 files
s-ylide Jul 15, 2025
f7960dd
fix call arguments
s-ylide Jul 15, 2025
0dfc8a6
allow empty comment
s-ylide Jul 15, 2025
c98ce6d
migration: fix trailing newline
s-ylide Jul 17, 2025
3a4a0b8
migration: fix TlmRef conversion
s-ylide Jul 17, 2025
d0ba199
formatter: update CommentAligned strategy
s-ylide Jul 17, 2025
131b02f
migration: use meta comment
s-ylide Jul 17, 2025
f083f3b
update v1 grammar around command sending
s-ylide Jul 22, 2025
5d8c8cc
update v1 grammar: tlmid! conversion
s-ylide Jul 22, 2025
cce755d
update tests
s-ylide Jul 22, 2025
2285a69
ast, parser: add infix import
s-ylide Aug 1, 2025
cf0d698
printer, migration: add infix import
s-ylide Aug 1, 2025
2fbe8f9
ast, parser: add if expr
s-ylide Aug 1, 2025
780dcac
printer, migration: add if expr
s-ylide Aug 1, 2025
b9df245
move to `prec` mod
s-ylide Aug 1, 2025
e1b9be8
move to `strat_helper` mod
s-ylide Aug 1, 2025
f3a68ca
add function
s-ylide Aug 1, 2025
65b8fdb
introduce token function with the same name
s-ylide Aug 1, 2025
c3c21a3
basic typing
s-ylide Aug 7, 2025
e067898
reduce duplication via `default_type_subst` macro
s-ylide Aug 7, 2025
3019d87
add `Expr` to `TypeFamily`
s-ylide Aug 7, 2025
02bbbf1
follow what clippy says
s-ylide Aug 7, 2025
f738dc4
improve family
s-ylide Aug 7, 2025
61eabe0
add types to family, update BinOp
s-ylide Aug 7, 2025
861dd95
move to opslang-ty crate
s-ylide Aug 7, 2025
d12f521
update typeck
s-ylide Aug 7, 2025
1796666
update family
s-ylide Aug 7, 2025
63924d8
update Qualif
s-ylide Aug 7, 2025
946f899
ir types
s-ylide Aug 7, 2025
2a4e050
fix inconsistency
s-ylide Aug 7, 2025
d7fd57c
alloc in arena
s-ylide Aug 14, 2025
d8b4ec0
add `IntoToken`
s-ylide Aug 14, 2025
98092a3
wip: rewrite typing
s-ylide Aug 14, 2025
be6b0d9
rename Row, Statement
s-ylide Aug 14, 2025
ac35fe9
misc refactor
s-ylide Aug 14, 2025
69293af
fix: comment, indent
s-ylide Aug 15, 2025
212bdb9
function return
s-ylide Aug 15, 2025
29d6a69
add proc macros
s-ylide Aug 19, 2025
4023e3d
fix kw name
s-ylide Aug 19, 2025
91a275d
move v1 impl to dedicated module
s-ylide Aug 21, 2025
6eb37c5
add visitor template, ast visitor
s-ylide Aug 26, 2025
872d7af
rename macro crate
s-ylide Aug 26, 2025
0dc8225
add semi at the end of constdef
s-ylide Aug 26, 2025
fa3c2fd
generate proper visit_method_name
s-ylide Aug 26, 2025
65ae7e9
call site hygiene
s-ylide Aug 26, 2025
1ff651f
remove first impl
s-ylide Aug 26, 2025
5756e67
fix precedence of reserved word
s-ylide Aug 26, 2025
0b54a9f
add visitor tests
s-ylide Aug 26, 2025
268c6b1
support attrs on member
s-ylide Aug 26, 2025
929ba7e
update comment, test
s-ylide Aug 26, 2025
145c231
split context of AstType
s-ylide Aug 26, 2025
d1891d1
move mod
s-ylide Aug 26, 2025
fba1994
add ir visitor
s-ylide Aug 27, 2025
5fe827c
add #[skip_all_visit]
s-ylide Aug 27, 2025
1a6ee65
update structure, collect qualifs
s-ylide Aug 29, 2025
55eb460
update comment, visit
s-ylide Aug 29, 2025
f200f38
update macro i/f
s-ylide Aug 30, 2025
aa60b07
fix visitor function name
s-ylide Aug 30, 2025
372ac9b
add IrVisitors
s-ylide Aug 30, 2025
6224add
update ir structure: change &expr to &mut expr
s-ylide Aug 30, 2025
52a97a6
fix lifetime handling
s-ylide Aug 30, 2025
b1389b2
add consistency check
s-ylide Aug 30, 2025
880d55c
change definition -> toplevelitem
s-ylide Aug 30, 2025
a394f25
move into modules
s-ylide Aug 30, 2025
d1c01bd
fix error msgs
s-ylide Aug 30, 2025
96f3bf7
update path resolving
s-ylide Sep 1, 2025
05c669d
make ir structure mutable
s-ylide Sep 1, 2025
f003f49
aggregate into visitor_type_registry.rs
s-ylide Sep 2, 2025
e4620e3
move constructors
s-ylide Sep 4, 2025
c4c6ef5
improve guidance for updating type registry
s-ylide Sep 4, 2025
217c4ac
fix numeric suffix parsing
s-ylide Sep 5, 2025
1acca70
support numeric literal
s-ylide Sep 5, 2025
57f221a
re-export ast items in ir
s-ylide Sep 8, 2025
0c066ef
separate module
s-ylide Sep 8, 2025
6a23559
rename to tcx
s-ylide Sep 8, 2025
99b20db
remove infix `in`
s-ylide Sep 8, 2025
6c4d60f
implement select
s-ylide Sep 8, 2025
74a90ad
use Display to display Ty
s-ylide Sep 8, 2025
bf57755
add eagerly_resolve
s-ylide Sep 8, 2025
b54bfa4
remove dbg!
s-ylide Sep 8, 2025
9861847
update default int type
s-ylide Sep 8, 2025
c4a5985
fix byte types
s-ylide Sep 8, 2025
e016913
remove weird function
s-ylide Sep 8, 2025
608f9c8
impl typeck_binary
s-ylide Sep 16, 2025
2b921b6
add external resolver
s-ylide Sep 16, 2025
5af2f73
impl IdRef and Deref for extern vars
s-ylide Sep 16, 2025
749c00d
remove confusing substitution
s-ylide Sep 16, 2025
3a1aeda
opt-in callsite hygiene to visitor methods
s-ylide Sep 16, 2025
05228a7
visitor trait doc
s-ylide Sep 16, 2025
2617b9d
add primitive cast
s-ylide Sep 16, 2025
c443ae6
fix `if` parsing, enforce parsing after migration
s-ylide Sep 17, 2025
6349aed
impl wait syntax, fix compare immut
s-ylide Sep 19, 2025
baf5e25
add tf, assert
s-ylide Sep 19, 2025
a4fccdd
fix infiximport: always resolve as main
s-ylide Sep 26, 2025
1e32877
move to typeck_path
s-ylide Sep 26, 2025
a969c54
move subst to ty crate, support polymorphic fn
s-ylide Sep 26, 2025
95db39f
support call in v1
s-ylide Sep 26, 2025
75d75ab
separate modules
s-ylide Oct 2, 2025
f632ebd
encapsulate Module
s-ylide Oct 2, 2025
1802625
forbid implicit re-define
s-ylide Oct 2, 2025
05b047e
separate modules
s-ylide Oct 2, 2025
91b3456
cleanup
s-ylide Oct 3, 2025
efecb29
remove confusing impl
s-ylide Oct 3, 2025
41a57d3
update whole fs
s-ylide Oct 9, 2025
4fbd304
move visitor_type_registry.rs to `type-registry`
s-ylide Oct 9, 2025
b94b128
extract `module` from ty
s-ylide Oct 9, 2025
a0e6eb4
rename typeck -> typeck_single_program
s-ylide Oct 9, 2025
54dbdb8
fix comment merging
s-ylide Oct 17, 2025
668b714
split typeck_single_program
s-ylide Oct 17, 2025
e6c6ee2
add typeck_programs
s-ylide Oct 17, 2025
9e8562b
add Error to v1 parse result
s-ylide Oct 17, 2025
c3db19c
add example
s-ylide Oct 17, 2025
f9b633b
add session
s-ylide Oct 18, 2025
3f9cc71
fix recursive
s-ylide Oct 18, 2025
9df7a1b
remove redundant lt
s-ylide Oct 18, 2025
0a928b4
wip env
s-ylide Oct 26, 2025
07e48a2
remove useless incorrect elision
s-ylide Oct 26, 2025
d72d48e
relay
s-ylide Oct 26, 2025
e0099f3
fix infiximport
s-ylide Oct 26, 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
57 changes: 54 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,64 @@
[workspace]
resolver = "2"
members = [
"opslang-ast",
"structure/type-registry",
"structure/opslang-ast",
"structure/opslang-ast/macro",
"opslang-diag",
"structure/opslang-ir",
"structure/opslang-ir/macro",
"opslang-parser",
"opslang-printer",
"ty/opslang-ty",
"ty/opslang-typeck",
"ty/opslang-module",
"opslang-visitor",
"opslang-visitor/macro",
"opslang-visitor-macro-helper",
"tools/opslang-migration",
"tools/opslang-formatter",
]

[workspace.package]
version = "0.4.0"
edition = "2024"
license = "MPL-2.0"

[workspace.dependencies]
opslang-ast = { path = "opslang-ast" }
opslang-parser = { path = "opslang-parser" }
anyhow = "1.0.100"
chrono = "0.4.42"
typed-arena = "2.0.2"
thiserror = "2.0.17"

clap = { version = "4.5.48", features = ["derive"] }
walkdir = "2.5.0"
toml = "0.9.7"

serde = { version = "1.0.228", features = ["derive"] }

syn = { version = "2.0.106", features = ["visit-mut", "full", "derive"] }
proc-macro2 = "1.0.101"
quote = "1.0.41"
synstructure = "0.13.2"
convert_case = "0.8.0"

peg = "0.8.1"
parol = "3.0.1"
parol_runtime = "3.0.0"

opslang-type-registry = { path = "./structure/type-registry", version = "=0.4.0" }
opslang-ast = { path = "./structure/opslang-ast", version = "=0.4.0" }
opslang-ast-macro = { path = "./structure/opslang-ast/macro", version = "=0.4.0" }
opslang-ir = { path = "./structure/opslang-ir", version = "=0.4.0" }
opslang-ir-macro = { path = "./structure/opslang-ir/macro", version = "=0.4.0" }
opslang-diag = { path = "./opslang-diag", version = "=0.4.0" }
opslang-parser = { path = "./opslang-parser", version = "=0.4.0" }
opslang-printer = { path = "./opslang-printer", version = "=0.4.0" }
opslang-ty = { path = "./ty/opslang-ty", version = "=0.4.0" }
opslang-typeck = { path = "./ty/opslang-typeck", version = "=0.4.0" }
opslang-module = { path = "./ty/opslang-module", version = "=0.4.0" }
opslang-visitor = { path = "./opslang-visitor", version = "=0.4.0" }
opslang-visitor-macro = { path = "./opslang-visitor/macro", version = "=0.4.0" }
opslang-visitor-macro-helper = { path = "./opslang-visitor-macro-helper", version = "=0.4.0" }
opslang-migration = { path = "./tools/opslang-migration", version = "=0.4.0" }
opslang-formatter = { path = "./tools/opslang-formatter", version = "=0.4.0" }
9 changes: 0 additions & 9 deletions opslang-ast/Cargo.toml

This file was deleted.

7 changes: 7 additions & 0 deletions opslang-diag/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "opslang-diag"
version.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
105 changes: 105 additions & 0 deletions opslang-diag/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
use std::cell::RefCell;

pub struct DiagContext {
emitter: RefCell<Box<dyn DiagEmitter>>,
}

impl DiagContext {
pub fn new(emitter: Box<dyn DiagEmitter>) -> Self {
Self {
emitter: RefCell::new(emitter),
}
}

fn emit_diagnostic(&self, diag: DiagInner) {
self.emitter.borrow_mut().emit_diagnostic(diag);
}

#[track_caller]
pub fn create_err(&self, err: impl Diagnostic) -> Diag<'_> {
err.into_diag(self, Level::Error)
}

#[track_caller]
pub fn emit_err(&self, err: impl Diagnostic) {
self.create_err(err).emit()
}
}

pub trait DiagEmitter {
fn emit_diagnostic(&mut self, diag: DiagInner);
}

pub trait Diagnostic {
fn into_diag(self, dcx: &DiagContext, level: Level) -> Diag<'_>;
}

pub struct DiagInner {
pub(crate) level: Level,
pub message: String,
}

impl DiagInner {
pub fn level(&self) -> &Level {
&self.level
}
}

pub enum Level {
Bug,
Error,
Warning,
Info,
Lint,
}

pub struct Diag<'dcx> {
pub dcx: &'dcx DiagContext,
inner: Option<Box<DiagInner>>,
}

impl Drop for Diag<'_> {
fn drop(&mut self) {
if let Some(diag) = self.inner.take() {
self.dcx.emit_diagnostic(DiagInner::new(
Level::Bug,
String::from("the following error was constructed but not emitted"),
));
self.dcx.emit_diagnostic(*diag);
panic!("error was constructed but not emitted");
}
}
}

impl Diag<'_> {
pub fn emit(mut self) {
self.dcx.emit_diagnostic(*self.inner.take().unwrap());
}

pub fn cancel(mut self) {
self.inner.take();
}
}

// constructors

impl DiagInner {
fn new(level: Level, message: String) -> Self {
Self { level, message }
}
}

impl<'dcx> Diag<'dcx> {
#[track_caller]
pub fn new(dcx: &'dcx DiagContext, level: Level, message: String) -> Self {
Self::new_diagnostic(dcx, DiagInner::new(level, message))
}

#[track_caller]
pub(crate) fn new_diagnostic(dcx: &'dcx DiagContext, diag: DiagInner) -> Self {
Self {
dcx,
inner: Some(Box::new(diag)),
}
}
}
36 changes: 29 additions & 7 deletions opslang-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
[package]
name = "opslang-parser"
version.workspace = true
edition = "2021"
license = "MPL-2.0"
edition.workspace = true
license.workspace = true
description = "ops file language parser"

[features]
v0 = ["dep:peg"]
v1 = ["build-parol", "dep:typed-arena"]
build-parol = ["dep:parol", "dep:parol_runtime"]
default = ["v0", "v1"]

[dependencies]
peg = "0.8.1"
thiserror = "1.0.48"
anyhow = "1.0.75"
opslang-ast = "0.4.0"
chrono = "0.4.33"
opslang-ast.workspace = true
opslang-diag.workspace = true

peg.workspace = true
peg.optional = true
parol.workspace = true
parol.optional = true
parol_runtime.workspace = true
parol_runtime.optional = true
typed-arena.workspace = true
typed-arena.optional = true

thiserror.workspace = true
anyhow.workspace = true
chrono.workspace = true

[build-dependencies]
parol.workspace = true
parol.optional = true
parol_runtime.workspace = true
parol_runtime.optional = true
141 changes: 141 additions & 0 deletions opslang-parser/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#[cfg(feature = "build-parol")]
fn build_parol() {
use std::path::PathBuf;
use std::process;

use parol::{ParolErrorReporter, build::Builder};
use parol_runtime::Report;

#[allow(unused_mut, unused_variables)]
let mut versions = Vec::new();

{
#[cfg(feature = "v1")]
versions.push("v1");
}

let mut has_error = false;

mod name {
pub struct Path {
pub path: &'static str,
}
impl AsRef<std::path::Path> for Path {
fn as_ref(&self) -> &std::path::Path {
self.path.as_ref()
}
}
#[derive(PartialEq)]
pub struct RustFile {
pub path: &'static str,
pub module: &'static str,
}
impl AsRef<std::path::Path> for RustFile {
fn as_ref(&self) -> &std::path::Path {
self.path.as_ref()
}
}

pub const ACTION_MOD: &str = "parse";
pub const USER_TYPE: &str = "Action";
pub const GENERATED: &str = "generated";
pub const GRAMMAR: Path = Path {
path: "grammar.par",
};
pub const EXPANDED_GRAMMAR: Path = Path {
path: "grammar-exp.par",
};
pub const PARSER: RustFile = RustFile {
path: "parser.rs",
module: "parser",
};
pub const TRAIT: RustFile = RustFile {
path: "grammar_trait.rs",
module: "grammar_trait",
};
}

for v in versions {
let input = {
let mut path = PathBuf::from("src");
path.push("version");
path.push(v);
path
};
let generated = {
let mut path = PathBuf::from("src");
path.push("version");
path.push(v);
path.push(name::GENERATED);
path
};
std::fs::create_dir_all(&generated).unwrap();

let grammar_file = input.join(name::GRAMMAR.path);
if let Err(err) = Builder::with_explicit_output_dir(".")
.grammar_file(&grammar_file)
.expanded_grammar_output_file(generated.join(name::EXPANDED_GRAMMAR))
.parser_output_file(generated.join(name::PARSER))
.actions_output_file(generated.join(name::TRAIT))
.user_trait_module_name(&format!("version::{v}::{path}", path = name::ACTION_MOD))
.user_type_name(name::USER_TYPE)
.trim_parse_tree()
.generate_parser()
{
ParolErrorReporter::report_error(&err, &grammar_file).unwrap_or_default();
has_error = true;
}

// Generate `generated.rs`
let mut f = std::fs::File::create(generated.join("../generated.rs")).unwrap();
{
use name::*;
use std::io::Write;
writeln!(f, "// This file is generated by `build.rs`.").unwrap();
writeln!(f, "// Do not edit it manually.").unwrap();
writeln!(f).unwrap();
for file in [TRAIT, PARSER] {
if file == TRAIT {
writeln!(f, "#[allow(clippy::all)]").unwrap();
}
let module_name = file.module;
writeln!(f, "pub mod {module_name};").unwrap();
}
}
}

if has_error {
process::exit(1);
}

// Generate `src/parol_macro.rs`
let mut f = std::fs::File::create("src/parol_macro.rs").unwrap();
{
use name::*;
use std::io::Write;
writeln!(f, "// This file is generated by `build.rs`.").unwrap();
writeln!(f, "// Do not edit it manually.").unwrap();
writeln!(f).unwrap();
let action = TRAIT.module;
writeln!(
f,
r#"#[macro_export]
/// Redirect due to `actions_output_file` depending on `user_trait_module_name` in fact.
///
/// This macro is generated by `build.rs`.
macro_rules! redirect_parol {{
() => {{
mod {ACTION_MOD}_trait {{
pub use super::{GENERATED}::{action}::{USER_TYPE}Auto;
}}
}};
}}"#
)
.unwrap();
}
}

fn main() {
#[cfg(feature = "build-parol")]
build_parol();
}
Loading