it.grypho.scala.leonardo.cli

Members list

Type members

Classlikes

case class ColorScheme(command: AttributedStyle, function: AttributedStyle, constant: AttributedStyle, number: AttributedStyle, operator: AttributedStyle, equation: AttributedStyle, paren: AttributedStyle, variable: AttributedStyle)

Colour mapping for one syntactic role in the Leonardo prompt.

Colour mapping for one syntactic role in the Leonardo prompt.

Each field is an AttributedStyle applied to a matching token class during highlighting. Plain sets every field to AttributedStyle.DEFAULT, disabling all colouring.

Value parameters

command

REPL command keywords (simplify, derive, colors, ...)

constant

named constants (pi, e, i) and the truth literals (true, false, unknown)

equation

bare = (equation relation)

function

mathematical function names (sin, cos, exp, ...)

number

numeric literals

operator

arithmetic operators, :=, and the word connectives (and, or, not, implies, xor)

paren

parentheses and square brackets

variable

user identifiers and everything else

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ColorScheme

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
class LeonardoHighlighter(schemeName: () => String) extends Highlighter

JLine Highlighter that token-colours the Leonardo prompt as the user types.

JLine Highlighter that token-colours the Leonardo prompt as the user types.

A single left-to-right scan classifies each character run as one of: := / :load / :save (operators / pseudo-commands), numeric literals, word tokens (command keyword, function, constant, or variable), and single-character operators and brackets. The active scheme is fetched via schemeName on every keystroke, so colors dark / colors light / colors none takes effect immediately.

reader is never used; call highlightBuffer directly in tests and tooling.

Attributes

Supertypes
trait Highlighter
class Object
trait Matchable
class Any
final class Session

Interactive command-line session over the Leonardo library.

Interactive command-line session over the Leonardo library.

Session state lives outside the library's Environment because the two kinds of assignment differ: a constant right-hand side becomes a numeric binding (a _Value the Environment can hold), while a right-hand side with free variables becomes a named definition (a symbolic _Expression, which the Environment deliberately cannot hold). Definitions are late-bound: they are substituted into input at use time, so redefining f also changes any g defined in terms of f.

Assignment uses := (CAS convention): bare = always parses as an _Equation, so x = 2*x + 1 is a relation to evaluate, never a binding. Session scripts (:save) emit := and old =-style scripts are not accepted.

Commands:

x := 3.001           bind a value (constant right-hand side)
f := sin(x) + x      define a function (right-hand side with free variables)
h := lhs = rhs       bind a named equation (can be passed to solve(h, x))
g := consolidate(e)  freeze the simplified+evaluated result of e into g (not late-bound)
lhs = rhs            equation: true/false when concrete; solvable via solve()
lhs == rhs           equality check: evaluates to bool but not solvable
<expression>         evaluate, e.g.  f + 1  or  derive(f, x)
simplify <expr>      structural simplification, no numeric evaluation
expand <expr>        distribute products over sums
precision <n>        set decimal precision
exact on | off       exact rational arithmetic (default: off); see "help exact"
exact precision <n>  digits an irrational is approximated to (default: 30)
pretty on | off      multi-line, column-aligned matrix display (default: off)
logic symmetric on|off  spell truth values as -1 / 0 / 1 (default: off)
logic minmax|product|lukasiewicz   fuzzy t-norm family (default: minmax)
env                  list precision, bindings, and definitions
unset <name>         remove a binding or definition
:load <file>         run a session script (file IO handled by the read loop)
:save <file>         write current state to a replayable script (read loop)
help                 this summary
quit | exit          leave (handled by the read loop)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Session

Companion object: constants and IO helpers shared across the REPL entry point.

Companion object: constants and IO helpers shared across the REPL entry point.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Session.type
final class repl

Attributes

Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def repl(): Unit

Entry point for the interactive Leonardo REPL.

Entry point for the interactive Leonardo REPL.

Attributes