Skip to content

Commit 098e87d

Browse files
committed
Align parser with V1 language reference; remove non-spec constructs; bump to 0.1.8
Add canonical V1 language reference and patterns reference to docs/. Remove parser support for constructs not in the V1 spec: system blocks, module declarations, module-level guidance, for each (only bare for), double-equals, includes/excludes operators, range literals, suffix predicates. Strip dead AST variants, token kinds and lexer rules. Update test fixtures and spec conformance tests.
1 parent 3267c39 commit 098e87d

13 files changed

Lines changed: 4607 additions & 476 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "2"
33
members = ["crates/allium-parser", "crates/allium"]
44

55
[workspace.package]
6-
version = "0.1.7"
6+
version = "0.1.8"
77
edition = "2021"
88
license = "MIT"
99
repository = "https://github.com/juxt/allium-tools"

crates/allium-parser/src/ast.rs

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,13 @@ pub struct Module {
3030
#[derive(Debug, Clone)]
3131
pub enum Decl {
3232
Use(UseDecl),
33-
ModuleDecl(ModuleDecl),
3433
Block(BlockDecl),
35-
Guidance(GuidanceDecl),
3634
Default(DefaultDecl),
3735
Variant(VariantDecl),
3836
Deferred(DeferredDecl),
3937
OpenQuestion(OpenQuestionDecl),
4038
}
4139

42-
/// `module name`
43-
#[derive(Debug, Clone)]
44-
pub struct ModuleDecl {
45-
pub span: Span,
46-
pub name: Ident,
47-
}
48-
4940
/// `use "path" as alias`
5041
#[derive(Debug, Clone)]
5142
pub struct UseDecl {
@@ -75,7 +66,6 @@ pub enum BlockKind {
7566
Rule,
7667
Surface,
7768
Actor,
78-
System,
7969
}
8070

8171
/// `default [Type] name = value`
@@ -103,13 +93,6 @@ pub struct DeferredDecl {
10393
pub path: Expr,
10494
}
10595

106-
/// `guidance: value` at module level
107-
#[derive(Debug, Clone)]
108-
pub struct GuidanceDecl {
109-
pub span: Span,
110-
pub value: Expr,
111-
}
112-
11396
/// `open question "text"`
11497
#[derive(Debug, Clone)]
11598
pub struct OpenQuestionDecl {
@@ -210,18 +193,6 @@ pub enum Expr {
210193
args: Vec<Expr>,
211194
},
212195

213-
/// `expr includes expr` / `expr excludes expr`
214-
Includes {
215-
span: Span,
216-
collection: Box<Expr>,
217-
element: Box<Expr>,
218-
},
219-
Excludes {
220-
span: Span,
221-
collection: Box<Expr>,
222-
element: Box<Expr>,
223-
},
224-
225196
/// `a.b`
226197
MemberAccess {
227198
span: Span,
@@ -402,21 +373,6 @@ pub enum Expr {
402373
/// A sequence of expressions from a multi-line block.
403374
Block { span: Span, items: Vec<Expr> },
404375

405-
/// `subject word [args...]` — prose-style predicate in clause values.
406-
/// Captures remaining same-line tokens after a primary expression.
407-
/// The `tail` contains the predicate word(s) and argument(s) in order.
408-
Predicate {
409-
span: Span,
410-
subject: Box<Expr>,
411-
tail: Vec<Expr>,
412-
},
413-
414-
/// `start..end` — range expression
415-
Range {
416-
span: Span,
417-
start: Box<Expr>,
418-
end: Box<Expr>,
419-
},
420376
}
421377

422378
impl Expr {
@@ -435,8 +391,6 @@ impl Expr {
435391
| Expr::ListLiteral { span, .. }
436392
| Expr::ObjectLiteral { span, .. }
437393
| Expr::GenericType { span, .. }
438-
| Expr::Includes { span, .. }
439-
| Expr::Excludes { span, .. }
440394
| Expr::MemberAccess { span, .. }
441395
| Expr::OptionalAccess { span, .. }
442396
| Expr::NullCoalesce { span, .. }
@@ -463,9 +417,7 @@ impl Expr {
463417
| Expr::WhenGuard { span, .. }
464418
| Expr::TypeOptional { span, .. }
465419
| Expr::LetExpr { span, .. }
466-
| Expr::Block { span, .. }
467-
| Expr::Predicate { span, .. }
468-
| Expr::Range { span, .. } => *span,
420+
| Expr::Block { span, .. } => *span,
469421
Expr::QualifiedName(q) => q.span,
470422
}
471423
}
@@ -486,7 +438,7 @@ pub struct CondBlockBranch {
486438
pub items: Vec<BlockItem>,
487439
}
488440

489-
/// Binding in a `for each` loop — either a single identifier or a
441+
/// Binding in a `for` loop — either a single identifier or a
490442
/// destructured tuple like `(a, b)`.
491443
#[derive(Debug, Clone)]
492444
pub enum ForBinding {

crates/allium-parser/src/lexer.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ pub enum TokenKind {
3232
Question,
3333
Use,
3434
As,
35-
Module,
36-
System,
3735

3836
// Clause / expression keywords
3937
When,
@@ -51,11 +49,9 @@ pub enum TokenKind {
5149
Or,
5250
Exists,
5351

54-
// Trigger / predicate keywords
52+
// Trigger keywords
5553
TransitionsTo,
5654
Becomes,
57-
Includes,
58-
Excludes,
5955

6056
// Context-sensitive identifiers treated as keywords
6157
Now,
@@ -64,7 +60,6 @@ pub enum TokenKind {
6460

6561
// Operators
6662
Eq, // =
67-
EqEq, // ==
6863
BangEq, // !=
6964
Lt, // <
7065
LtEq, // <=
@@ -80,7 +75,6 @@ pub enum TokenKind {
8075
QuestionQuestion, // ??
8176
QuestionDot, // ?.
8277
Dot, // .
83-
DotDot, // ..
8478

8579
// Delimiters
8680
LBrace,
@@ -126,8 +120,6 @@ impl std::fmt::Display for TokenKind {
126120
TokenKind::Question => write!(f, "'question'"),
127121
TokenKind::Use => write!(f, "'use'"),
128122
TokenKind::As => write!(f, "'as'"),
129-
TokenKind::Module => write!(f, "'module'"),
130-
TokenKind::System => write!(f, "'system'"),
131123
TokenKind::When => write!(f, "'when'"),
132124
TokenKind::Requires => write!(f, "'requires'"),
133125
TokenKind::Ensures => write!(f, "'ensures'"),
@@ -144,13 +136,10 @@ impl std::fmt::Display for TokenKind {
144136
TokenKind::Exists => write!(f, "'exists'"),
145137
TokenKind::TransitionsTo => write!(f, "'transitions_to'"),
146138
TokenKind::Becomes => write!(f, "'becomes'"),
147-
TokenKind::Includes => write!(f, "'includes'"),
148-
TokenKind::Excludes => write!(f, "'excludes'"),
149139
TokenKind::Now => write!(f, "'now'"),
150140
TokenKind::This => write!(f, "'this'"),
151141
TokenKind::Within => write!(f, "'within'"),
152142
TokenKind::Eq => write!(f, "'='"),
153-
TokenKind::EqEq => write!(f, "'=='"),
154143
TokenKind::BangEq => write!(f, "'!='"),
155144
TokenKind::Lt => write!(f, "'<'"),
156145
TokenKind::LtEq => write!(f, "'<='"),
@@ -166,7 +155,6 @@ impl std::fmt::Display for TokenKind {
166155
TokenKind::QuestionQuestion => write!(f, "'??'"),
167156
TokenKind::QuestionDot => write!(f, "'?.'"),
168157
TokenKind::Dot => write!(f, "'.'"),
169-
TokenKind::DotDot => write!(f, "'..'"),
170158
TokenKind::LBrace => write!(f, "'{{'"),
171159
TokenKind::RBrace => write!(f, "'}}'"),
172160
TokenKind::LParen => write!(f, "'('"),
@@ -207,8 +195,6 @@ impl TokenKind {
207195
| TokenKind::Question
208196
| TokenKind::Use
209197
| TokenKind::As
210-
| TokenKind::Module
211-
| TokenKind::System
212198
| TokenKind::When
213199
| TokenKind::Requires
214200
| TokenKind::Ensures
@@ -225,8 +211,6 @@ impl TokenKind {
225211
| TokenKind::Exists
226212
| TokenKind::TransitionsTo
227213
| TokenKind::Becomes
228-
| TokenKind::Includes
229-
| TokenKind::Excludes
230214
| TokenKind::Now
231215
| TokenKind::This
232216
| TokenKind::Within
@@ -499,7 +483,6 @@ impl<'s> Lexer<'s> {
499483

500484
let (kind, len) = match (b, next) {
501485
(b'=', b'>') => (TokenKind::FatArrow, 2),
502-
(b'=', b'=') => (TokenKind::EqEq, 2),
503486
(b'=', _) => (TokenKind::Eq, 1),
504487
(b'!', b'=') => (TokenKind::BangEq, 2),
505488
(b'<', b'=') => (TokenKind::LtEq, 2),
@@ -515,7 +498,6 @@ impl<'s> Lexer<'s> {
515498
(b'?', b'?') => (TokenKind::QuestionQuestion, 2),
516499
(b'?', b'.') => (TokenKind::QuestionDot, 2),
517500
(b'?', _) => (TokenKind::QuestionMark, 1),
518-
(b'.', b'.') => (TokenKind::DotDot, 2),
519501
(b'.', _) => (TokenKind::Dot, 1),
520502
(b'{', _) => (TokenKind::LBrace, 1),
521503
(b'}', _) => (TokenKind::RBrace, 1),
@@ -566,8 +548,6 @@ fn classify_keyword(text: &str) -> TokenKind {
566548
"question" => TokenKind::Question,
567549
"use" => TokenKind::Use,
568550
"as" => TokenKind::As,
569-
"module" => TokenKind::Module,
570-
"system" => TokenKind::System,
571551
"when" => TokenKind::When,
572552
"requires" => TokenKind::Requires,
573553
"ensures" => TokenKind::Ensures,
@@ -584,8 +564,6 @@ fn classify_keyword(text: &str) -> TokenKind {
584564
"exists" => TokenKind::Exists,
585565
"transitions_to" => TokenKind::TransitionsTo,
586566
"becomes" => TokenKind::Becomes,
587-
"includes" => TokenKind::Includes,
588-
"excludes" => TokenKind::Excludes,
589567
"true" => TokenKind::True,
590568
"false" => TokenKind::False,
591569
"null" => TokenKind::Null,

0 commit comments

Comments
 (0)