Skip to content

alias is a developer console that os free to use and has multiple implementations

License

Notifications You must be signed in to change notification settings

home-gihub/alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

alias

alias is a developer console with multiple implementations

The guidelines

The lexer

The lexer is a function that when passed a string it will output an array-like structure of tokens.

When passed a string it should split it with spaces being the separator, however if there are double quotes they sould not be split, insted bbeing considered one token. The output will be stored in an array-like structure. The quotes should not be visable in the output.

Example:

input: 'a b c "a b c"'
output ['a', 'b', 'c', 'abc']

The interpreter

The interpreter is a function that takes in an array-like structure of strings (generated by the lexer) and performs an operation based on those tokens.

The first item is used to tell the interpreter what operation to perform, all of the other items are used as arguments. For example if we make an echo operation that outputs the second argument to the standard output if we pass the interpreter these tokens:

['echo', 'Hello, World!']

in the standard output we will see:

Hello, World!

The interpreter's operations should be extensible.

heap

The heap is simple, just store valuses and get values by string. An example would be a dictonary

aliases

An alias is a group of commands that are stored under one name. They can be executed by simply referencing them like a normal command (e.g. echo). The way they execute is one command at a time, execute one, then go to the next in the alias. They are stored in a second heap called aliascmds, each alias is an array-like structure with each command in it.

included commands

"echo"
"setvar"
"calcvar"
"quit"
"alias"

echo

prints the second argument to the screen

setvar

assigns a variable (2nd argument) in the heap a value (3rd argument)


calcvar

syntax:

setvar [var1] [operation] [var2] [var3]

performs operation on var1 and var2 then puts a value into var3

add

addition

sub

subtraction

mul

multiplication

div

division

is

(returns boolean 1 or 0) is equal

isnot

(returns boolean 1 or 0) is not equal


quit

quit the program

alias

assigns a alias a value

usage

If we make a variable called "usrin" and we set it to contain a command, for example echo "Hello, World!". We would pass the "usrin" variable to the lexer function, after the lexer has completed we would pass the tokens from the lexer function into the interpreter function.

About

alias is a developer console that os free to use and has multiple implementations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published