Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ Defines AST nodes for the parser. Key types:
Parses ABL source code into an AST. Key capabilities:

- **Expression parsing** with proper operator precedence (ternary → or → and → comparison → additive → multiplicative → unary → postfix → primary)
- **Statement parsing**: DEFINE VARIABLE/VAR/PARAMETER/TEMP-TABLE/BUFFER/PROPERTY/STREAM/FRAME, DO blocks (with counting loops), IF/THEN/ELSE, REPEAT, FOR EACH, FIND, CASE, PROCEDURE, FUNCTION, RUN, DISPLAY (with STREAM clause), MESSAGE, ASSIGN, CREATE, DELETE, RELEASE, VALIDATE, BUFFER-COPY, BUFFER-COMPARE, INPUT/OUTPUT/INPUT-OUTPUT stream I/O (FROM/TO/THROUGH/CLOSE), CATCH/FINALLY/THROW, LEAVE, NEXT, RETURN
- **Statement parsing**: DEFINE VARIABLE/VAR/PARAMETER/TEMP-TABLE/BUFFER/PROPERTY/STREAM/FRAME/EVENT, DO blocks (with counting loops), IF/THEN/ELSE, REPEAT, FOR EACH, FIND, CASE, PROCEDURE, FUNCTION, RUN, DISPLAY (with STREAM clause), MESSAGE, ASSIGN, CREATE, DELETE, RELEASE, VALIDATE, BUFFER-COPY, BUFFER-COMPARE, INPUT/OUTPUT/INPUT-OUTPUT stream I/O (FROM/TO/THROUGH/CLOSE), CATCH/FINALLY/THROW, PUBLISH/SUBSCRIBE/UNSUBSCRIBE, LEAVE, NEXT, RETURN
- **OO-ABL**: CLASS (with ABSTRACT/FINAL, INHERITS, IMPLEMENTS), INTERFACE, METHOD (with access modifiers, STATIC/ABSTRACT/OVERRIDE), DEFINE PROPERTY (auto and computed GET/SET), CONSTRUCTOR, DESTRUCTOR, USING
- **Postfix operations**: Method calls (object:method()), member access (object.member), array access (arr[i]), field access (table.field)
- **Function calls** with argument lists
- **Preprocessor**: &IF/&ELSEIF/&ELSE/&ENDIF at statement, expression, and data type levels via generic `PreprocIf<T>`, &SCOPED-DEFINE/&GLOBAL-DEFINE with `PreprocEnd` lexer token, &UNDEFINE, &MESSAGE, `{&variable}` references
- **Error recovery** via `parse_program()` with synchronization on period boundaries

Not yet implemented: DATASET, PUBLISH/SUBSCRIBE, ON triggers.
Not yet implemented: ON triggers.

### Code Generation (`oxabl_codegen`)

Expand Down
62 changes: 62 additions & 0 deletions crates/oxabl_ast/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,55 @@ pub enum Statement {
source_buffers: Vec<DataSourceBuffer>,
},

/// PUBLISH event-name [FROM publisher-handle] [(args...)].
Publish {
/// Event name — string literal or character expression.
event_name: Expression,
/// Optional FROM publisher-handle.
from_handle: Option<Expression>,
/// Arguments passed to subscribers (reuses RunArgument).
arguments: Vec<RunArgument>,
},

/// SUBSCRIBE [PROCEDURE subscriber-handle] [TO] event-name {IN handle | ANYWHERE}
/// [RUN-PROCEDURE handler-name] [NO-ERROR].
Subscribe {
/// Optional PROCEDURE subscriber-handle.
subscriber: Option<Expression>,
/// Event name — string literal or character expression.
event_name: Expression,
/// IN publisher-handle or ANYWHERE (required).
target: SubscribeTarget,
/// Optional RUN-PROCEDURE handler name.
run_procedure: Option<Identifier>,
/// Whether NO-ERROR was specified.
no_error: bool,
},

/// UNSUBSCRIBE [PROCEDURE subscriber-handle] [TO] {event-name | ALL} [IN publisher-handle].
Unsubscribe {
/// Optional PROCEDURE subscriber-handle.
subscriber: Option<Expression>,
/// Event name, or None if ALL was specified.
event_name: Option<Expression>,
/// Optional IN publisher-handle.
in_handle: Option<Expression>,
},

/// DEFINE [access] [STATIC] [ABSTRACT] EVENT event-name SIGNATURE VOID (params...).
DefineEvent {
/// Access modifier (defaults to PUBLIC).
access: AccessModifier,
/// Whether STATIC was specified.
is_static: bool,
/// Whether ABSTRACT was specified.
is_abstract: bool,
/// Event name.
name: Identifier,
/// Signature parameters (reuses DefineParameter via Vec<Statement>).
parameters: Vec<Statement>,
},

/// INPUT/OUTPUT/INPUT-OUTPUT stream I/O statement.
StreamIo {
direction: StreamDirection,
Expand Down Expand Up @@ -803,3 +852,16 @@ pub struct HandlePassingOptions {
pub bind: bool,
pub by_value: bool,
}

// =============================================================================
// Event system types
// =============================================================================

/// Target for SUBSCRIBE — where to listen for events.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SubscribeTarget {
/// Subscribe to events from a specific publisher handle.
InHandle(Expression),
/// Subscribe to events from any publisher.
Anywhere,
}
7 changes: 7 additions & 0 deletions crates/oxabl_lexer/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fn main() {
"analyze",
"and",
"any",
"anywhere",
"append",
"apply",
"as",
Expand Down Expand Up @@ -208,6 +209,7 @@ fn main() {
"error status",
"escape",
"etime",
"event",
"event procedure",
"except",
"exclusive-lock",
Expand Down Expand Up @@ -464,6 +466,7 @@ fn main() {
"provers",
"proversion",
"public",
"publish",
"put",
"put-byte",
"put-key-val",
Expand Down Expand Up @@ -502,6 +505,7 @@ fn main() {
"revoke",
"rowid",
"run",
"run-procedure",
"save",
"sax-comple",
"sax-complete",
Expand Down Expand Up @@ -540,6 +544,7 @@ fn main() {
"shared",
"show-stat",
"show-stats",
"signature",
"single-run",
"skip",
"skip-deleted-record",
Expand All @@ -550,6 +555,7 @@ fn main() {
"stream",
"stream-handle",
"stream-io",
"subscribe",
"system-dialog",
"table",
"table-handle",
Expand Down Expand Up @@ -584,6 +590,7 @@ fn main() {
"union",
"unique",
"unix",
"unsubscribe",
"up",
"update",
"use-index",
Expand Down
14 changes: 14 additions & 0 deletions crates/oxabl_lexer/src/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ pub enum Kind {
BufferCompare,
Close,
ParentIdRelation,
Publish,
Subscribe,
Unsubscribe,

// Functions
Accum,
Expand Down Expand Up @@ -316,6 +319,10 @@ pub enum Kind {
TableHandle,
Bind,
ByValue,
Anywhere,
Event,
Signature,
RunProcedure,

// Phrases
Editing,
Expand Down Expand Up @@ -762,6 +769,7 @@ pub fn match_keyword(s: &str) -> Option<Kind> {
"displ" => Some(Kind::Display),
"entry" => Some(Kind::Entry),
"etime" => Some(Kind::Etime),
"event" => Some(Kind::Event),
"false" => Some(Kind::KwFalse),
"fetch" => Some(Kind::Fetch),
"field" => Some(Kind::Field),
Expand Down Expand Up @@ -989,6 +997,7 @@ pub fn match_keyword(s: &str) -> Option<Kind> {
"promsgs" => Some(Kind::Promsgs),
"propath" => Some(Kind::Propath),
"provers" => Some(Kind::Proversion),
"publish" => Some(Kind::Publish),
"putbyte" => Some(Kind::Putbyte),
"r-index" => Some(Kind::RIndex),
"readkey" => Some(Kind::Readkey),
Expand Down Expand Up @@ -1018,6 +1027,7 @@ pub fn match_keyword(s: &str) -> Option<Kind> {
"abstract" => Some(Kind::Abstract),
"accumula" => Some(Kind::Accumulate),
"ambiguou" => Some(Kind::Ambiguous),
"anywhere" => Some(Kind::Anywhere),
"ascendin" => Some(Kind::Ascending),
"attr spa" => Some(Kind::AttrSpace),
"attr-spa" => Some(Kind::AttrSpace),
Expand Down Expand Up @@ -1192,7 +1202,9 @@ pub fn match_keyword(s: &str) -> Option<Kind> {
"screen-io" => Some(Kind::ScreenIo),
"setuserid" => Some(Kind::Setuserid),
"show-stat" => Some(Kind::ShowStats),
"signature" => Some(Kind::Signature),
"stream-io" => Some(Kind::StreamIo),
"subscribe" => Some(Kind::Subscribe),
"underline" => Some(Kind::Underline),
"unformatt" => Some(Kind::Unformatted),
"use-index" => Some(Kind::UseIndex),
Expand Down Expand Up @@ -1349,6 +1361,7 @@ pub fn match_keyword(s: &str) -> Option<Kind> {
"thread-safe" => Some(Kind::ThreadSafe),
"transaction" => Some(Kind::Transaction),
"unformatted" => Some(Kind::Unformatted),
"unsubscribe" => Some(Kind::Unsubscribe),
"widget-pool" => Some(Kind::WidgetPool),
_ => None,
},
Expand Down Expand Up @@ -1432,6 +1445,7 @@ pub fn match_keyword(s: &str) -> Option<Kind> {
"put-key-value" => Some(Kind::PutKeyValue),
"query-off-end" => Some(Kind::QueryOffEnd),
"rcode-informa" => Some(Kind::RcodeInformation),
"run-procedure" => Some(Kind::RunProcedure),
"sax-write-tag" => Some(Kind::SaxWriteTag),
"search-targer" => Some(Kind::SearchTarger),
"stream-handle" => Some(Kind::StreamHandle),
Expand Down
8 changes: 8 additions & 0 deletions crates/oxabl_parser/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ impl<'a> Parser<'a> {
| Kind::ByValue
| Kind::Query
| Kind::Reposition
// Event system keywords (unreserved)
| Kind::Publish
| Kind::Subscribe
| Kind::Unsubscribe
| Kind::Anywhere
| Kind::Event
| Kind::Signature
| Kind::RunProcedure
)
}

Expand Down
Loading