Crate basic_dsl

Crate basic_dsl 

Source
Expand description

§BASIC DSL

A procedural macro crate that provides a BASIC interpreter DSL embedded in Rust.

§Usage

use basic_dsl::basic;

basic! {
    10 FOR I = 1 TO 5
    20 PRINT I
    30 NEXT I
    40 PRINT "DONE"
    50 END
}

The macro supports classic BASIC programming constructs:

§Control Flow

  • FOR…NEXT loops: FOR variable = start TO end [STEP increment] and NEXT [variable]
  • Conditional jumps: IF condition THEN GOTO line
  • Unconditional jumps: GOTO line
  • Program termination: END

§Variables and Expressions

  • Variable assignment: LET variable = expression
  • Arithmetic: +, -, *, /
  • Comparisons: <, <=, =, >=, >
  • Numbers and string literals: 42, "Hello World"

§Input/Output

  • Printing: PRINT expression (numbers and strings)

§Advanced Features

  • Nested loops: Full support for nested FOR…NEXT constructs
  • Expression evaluation: Complex arithmetic and string handling
  • Runtime error checking: Proper error handling for invalid operations

Macros§

basic
Main entry point for the BASIC DSL macro.