Add builtins to ast and parse them
This commit is contained in:
parent
4fdce864d3
commit
a82b625631
3 changed files with 58 additions and 20 deletions
|
|
@ -1,21 +1,31 @@
|
|||
// Possible future built-ins
|
||||
//
|
||||
// #get - Get table's value at a key/path
|
||||
// #set - Set table's value at a key/path
|
||||
// #raw - Interpret values literally (either recursively or only one layer)
|
||||
// #path - Construct a path from a table
|
||||
// #scope - Execute a command in a new sub-scope
|
||||
// #loop - Repeat a command infinitely
|
||||
// #break - Break out of an infinite loop (with a value?)
|
||||
// #if - Conditionally execute one of two commands
|
||||
// #print - Print a string to stdout
|
||||
// #input - Read a line from stdin
|
||||
// #read - Load the contents of a file as string
|
||||
// #write - Store a string into a file
|
||||
// Arithmetic: #add #sub #neg #shiftr #shiftl
|
||||
// Booleans: #and #or #not #xor #andb #orb #notb #xorb
|
||||
// Comparisons: #eq #neq #lt #le #gt #ge
|
||||
use std::fmt;
|
||||
|
||||
/// Built-in operations
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum Builtin {}
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum Builtin {
|
||||
Get,
|
||||
Set,
|
||||
GetRaw,
|
||||
SetRaw,
|
||||
GetMeta,
|
||||
SetMeta,
|
||||
Scope,
|
||||
Arg,
|
||||
Destructure,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Builtin {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Get => write!(f, "'get"),
|
||||
Self::Set => write!(f, "'set"),
|
||||
Self::GetRaw => write!(f, "'getraw"),
|
||||
Self::SetRaw => write!(f, "'setraw"),
|
||||
Self::GetMeta => write!(f, "'getmeta"),
|
||||
Self::SetMeta => write!(f, "'setmeta"),
|
||||
Self::Scope => write!(f, "'scope"),
|
||||
Self::Arg => write!(f, "'arg"),
|
||||
Self::Destructure => write!(f, "'destructure"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue