Giter Club home page Giter Club logo

yash.thumus.eu's Introduction

YASH

Yet An other SHell

YASH is a side project of my website thumus.eu. It emulates bash by calling an interface (a sort of bridge)

Extensions

The extensions are .ysh and .yash. It supports .sh and .bash in a strict bash environnement.

Why

I wanted a portable version of bash on the web. There are projects who ports bash into a framework like NextJS but I wanted something usable in a CLI too. Typescript is the best choice for me there. It's more a fun project than a serious project for me.

Read-Eval-Print-Loop (REPL)

You need bun for simplicity or anything that can compile typescript.

$ bun src/repl.ts

Run

Same as REPL but the command is

$ bun src/run.ts [FILE1] [FILE2]...

Replace FILE1, etc... by your files.

Install

For now on, YASH is compiled in two versions, REPL and RUN.

To compile the run version:

$ bun build --compile src/run.ts --outfile ./build/YASH_run

To compile the repl version:

$ bun build --compile src/repl.ts --outfile ./build/YASH_repl

and then to execute a command, it's the same as above but you replace bun src/[NAME].ts by YASH_[NAME]. NAME is repl or run

Grammar

WORK IN PROGRESS

The langage will change that's for sure.

White spaces are ommited

YASH version


text = ('"' .* '"') | ("'" .* "'") | ('`' .* '`');
literal = "null" | number | text | bool | argument | var | regex;
bool = 'true' | 'false';
int = digit+;
float = digit+ ('.' digit+)?;
number = int | float;
digit = '0' | ... | '9';
argument = [a-zA-Z] ([a-zA-Z] | digit)*;
var = "$" ([a-zA-Z] | digit | "*" | "@")+;

list = "[" litteral? | ((literal ",")+ litteral) "]"

endstate = (";" | "\n")+;

leftUnary = "!" | "-";
rightUnary = "&";

unary-expr = (expr rightUnary) | (leftUnary expr);
binary-expr = (expr binary expr) ;

binary = logical | math;
logical = "&&" | "||" | "==" | "!=" | ">=" | "<=" | ">" | "<" | "|" | "|>" | "<|" | "=~";
math = "+" | "-" | "/" | "*" | "%" | "**";

math-block = ('((' expr '))') | ('(' expr ')') ;
string-block = ("[[" expr "]]") | ("[" expr "]") | ("(" expr ")");

condition-block = math-block | string-block;

if-expr = "if" condition-block endstate "then" expr endstate ("fi" | elfi-expr | else-expr);

elif-expr = "elif" condition-block endstate "then" endstate expr  ("fi" | elfi-expr | else-expr);

else-expr = "else" endstate "then" endstate expr "fi";

time-expr = "time" expr;

while-expr = "while" condition-block endstate "do" expr endstate "done";

until-expr = "until" condition-block endstate "do" expr endstate "done";

case-expr = "case" expr "in" endstate ((regex | litteral) ")" endstate expr endstate ";;" endstate  )* "*)" endstate expr endstate ";;" endstate "esac"; 

local-expr = "local" argument

keywords-expr = if-expr | elif-expr | else-expr | time-expr | while-expr | until-expr | case-expr  | select-expr | function-expr | local-expr;

one-expr = unary-expr | binary-expr | ltteral | keywords-expr;

expr = (one-expr) | ((one-expr endstate) one-expr);

BASH version (strict mode)

wip

Contributing & Bugs

You can open an issue at my repository, I don't accept PR (normally).

TODO

Things I need to do:

  • Separate topics: Numbers need to be with Equations, Args with args etc...
    • Statement: Everything is a statement but it's not normal
    • Equations: Numbers, Floats
    • Logical: Logical operators with booleans
    • Args: Contains command and args for the command
    • Flow: Preprocess (|>, <|), link external tools?
    • Bits: Operators with bits (&, |, )
  • Strict mode: The goal is to run normal bash and yash. Useful with equations
  • Impl basic helper functions: We need functions to use it in C for example.
  • Yash to Bash: A converter tool can be useful.
  • Errors: Line, column with a little graphic and a stack trace.
  • Add keywords: Some keywords aren't already implemented.
  • Reorganise: Everything is in the name
  • DOCS: obv
  • Add structs: Arrays, Dicts, Tuples, ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.