Skip to content

TODO & Roadmap

Jakub T. Jankiewicz edited this page May 22, 2024 · 26 revisions

TODO

  • Parser
    • variables
      • strings
      • regexes
      • arrays
      • dictionaries
      • booleans
      • integers
      • floats
    • property access
      • nested property access
    • Here docs - for figlet ASCII art
    • array indexing
    • dicts/structs for data
    • if/else statements
    • globals
      • cookie
        • set cookie
      • argv (process.argv) or null
      • location or null
        • access nested properties
        • set location and redirect
    • loops
      • for..in
      • while
    • try..catch..end
    • do..end blocks
    • comments with #
    • Functions
      • Functions return keyword
      • *args -> rest and spread
      • Lambda
      • Functions return functions
      • Implementation of map/reduce/filter using gaiman
    • Commands (restricted names)
      • ask - set prompt
      • echo - print message
        • explicit "\n" (user can change using config)
      • clear - clear terminal
      • mask - mask the input for secrets
      • get - send HTTP GET request
      • post - send HTTP POST request
      • exit - to end the program
      • let - save expression or command into variable
      • exists ... in - check if item is in array there is [].includes.
      • parse - parse string to number, boolean or regex
      • sleep - pause the terminal using setTimeout
        • sleep* - keep prompt visible
      • split - to create array with string or regex separator string method exists
      • join - return string from array array method exists
      • push - item into array array method exists
      • pop - remote item from array method exists
      • Optional parenthesis for echo* (get "https://jcubic.pl"), 100
      • style commands (some ingored in Node)
        • color
        • background
        • size
        • font
        • cursor
      • Animation commands
        • prompt*
        • input*
        • echo*
        • ask*
    • Not operator inside if statements
    • Expressions
      • regex match ~=
      • $1 variables
      • comparators ==/<=/>=/</>
      • parentheses for grouping
      • -=, +=, /=, *= operators
      • -, +, /, * and % operators
  • compiler functions to JavaScript code escodegen.
  • Compile everything to JavaScript
  • Unit tests
  • jQuery Terminal integration
  • Async Adapters for Web
  • Async Adapters for Terminal
  • XML like syntax for colors <bold><red>hello</red></bold> (added xml formatting)
  • STD
    • Date object
    • URL parser
    • Modules from URL
    • Parse string to int
    • isNaN
    • Array methods join/push/pop (maybe allow all JS methods)
    • String methods split/replace
    • ord/chr
  • Hooks to embed JS code
@pragma inject
function $_sum(...args) {
   return args.reduce((a, b) => a + b);
}
@end

echo sum(1, 2, 3);

TODO: syntax example

echo <<GREET
   ____       _
  / ___| __ _(_)_ __ ___   __ _ _ __
 | |  _ / _` | | '_ ` _ \ / _` | '_ \
 | |_| | (_| | | | | | | | (_| | | | |
  \____|\__,_|_|_| |_| |_|\__,_|_| |_|

Gaiman Engine
Copyright (C) 2021 Jakub Jankiewicz <https://jcubic.pl/me>
Released under GPLv3 license
GREET

if location then
    echo "Wellcome on this website"
else
    echo "Wellcome to this CLI app"
end

let env = []

let items = ["bottle", "flower"]

let command = ask "? "
if command ~= /pick (.+)/ then
   if $1 then
      if exists $1 in items then
          env.push($1)
          pop items
       else
          echo "invalid item"
       end
    else
       echo "What do you want topick"
    end
end


let stop = false
let count = 0
while not stop do
    let command = ask "? "
    if command ~= /exit/
        stop = true
        echo "goodby"
    else if command ~= /add ([0-9]+)/ then
        count += parse $1
        echo "corrent count $count"
    else
        echo "your command $command"
    end
end

def once(fn)
    let result = null
    return lambda(...args)
        if result == null then
           result = fn(...args)
        end
        return result
    end
end

def map(fn, array)
    let result = []
    for item in array do
        result.push(fn(item))
    end
    return result
end

To consider

  • do we need set maybe foo = ?? is enough
  • scope for variales (php with global is not good idea)
  • methods (JS Array/String)
  • standard library (e.g.: push/pop/split/join)
  • functions should be compiled to JavaScript, use
command = ask "? "

should be compile to:

var command = await term.read('? ')

NOTE: should there be implicit var? Maybe force using let to declare variables.

Compile:

do
    let x = 10
    echo x + x
end
x # throw exception x is not defined

to

{
    let $_x = 10
    term.echo($_x + $_x);
}
$_x

All names prefixed with $_ to solve conflicts

Adapter API

class Adapter {
    constructor() { }
    async ask(message) { }
    echo(string) { }
    async get(url) { }
    async post(url, data) { }
    start() { }
}

functon is_node() {
    return typeof process !== 'undefined' &&
        process.release.name === 'node';
}

var term, $_location, $_argv
if (is_node()) {
  term = new NodeAdapter();
  $_argv = process.argv;
} else {
  term = new WebAdapter();
  $_location = location;
}

term.start();
Clone this wiki locally