A scripting language inspired by C, Python and Javascript.
To learn more about the language, read docs/LanguageDocs.md
.
- Dependencies:
make
To buildbison
To generate parser- A C compiler (e.g. GCC or Clang)
git clone https://github.com/AvirukBasak/shsc-lang.git
cd shsc-lang
git submodule update --init
git pull --recurse-submodules
- Build with
install.sh
- Executable path is
target/shsc-rel
On Windows you can use either of the following toolsets with specific benefits or drawbacks:
Tool Set | Recommended | GNU Make | GDB | Clang | Address Sanitizer (General) | Address Sanitizer (Detect Leaks) |
---|---|---|---|---|---|---|
w64devkit |
For Usage | Yes | Yes | No | No | No |
LLVM MinGW |
For Development | No | No | Yes | Yes | No |
- Extract the files and place them in some folder
- Add the necessary paths to the user PATH
- The user PATH is accessible via
Add or modify user environment variables
or something. - Open CMD in project root
- Run
install.sh
Usage:
shsc [options] file... -args args...
Options:
[-v | --version] Show version
[-h | --help ] Show this help message
[-r | --run ] listfile Run scripts listed in the listfile
[-t | --ast ] outfile file... Parse file and save AST as JSON in outfile
[-tf | --astf ] outfile file... Parse file and save formatted AST as JSON in outfile
[-ldbg | --lex-debug] file... Scan file and print lexer debug output
Notes:
> file... - one or more shsc code files
> args... - arguments passed to the main:main shsc method; are optional
> flag -args can be added after file... or after listfile in case of --run
> passing a dash (-) anywhere as filename will read from stdin or write to stdout
Examples at examples/
.
make run ARGS="examples/fibonacci.txt"
or, if properly loaded in PATH
environment variable
shsc examples/fibonacci.txt
NOTE: File extension means nothing to the interpreter as long as the code inside is valid. However, the syntax highlighting plugin will work only for .shsc
files.
- Modules
- Procedure definitions
- Procedure calls
- Function arguments
- Call stack
- Lambda functions
- Interop with C
- Variables
- Destructuring
- Constants
- Weak references
- Local scopes
- Function scopes
- Error stack traces
- Contextual functions (OOP)
- Literals
-
bul
Boolean -
chr
Char -
i64
Int 64-bit -
f64
Float 64-bit -
str
String -
interp_str
Format string -
lst
List -
map
Hash map
-
- Reference counted GC
- Range based for
- Iterable based for
- While
- Break and continue
- If-else
- Arithmetic right shift
- Shift for
f64
LHS - All other operators
-
&&
,||
and ternary operator short-circuiting - Built-in functions
- List file is specified using the
--run
flag - This loads multiple files for execution under a single runtime
- Each line of the list file has a single shsc file path
- Paths are relative to directory of list file
- Spaces in file path is valid and quotes not required
- If shsc fails to read or parse any file, it'll report error and exit
The file paths should be relative to the directory where shsc
will be executed.
file1.txt
file2.shsc
file3.txt
file name with spaces.txt
file4.some_extension
file that has no extension
Run the tests using the list file
# tested using examples/inheritance/listfile list file
shsc -r examples/inheritance/listfile -args abc 123 1 2 3
Output the AST to a file
# tested on examples/factorial.txt
shsc -tf ast.json examples/factorial.txt
- Lexer interface at
docs/LexerInterface.md
- Language docs at
docs/LanguageDocs.md
- Bytecode specs at
ShscIrSpec.md
- Contribution guidelines at
docs/CONTRIBUTING.md
- Memory usage test
docs/memprofile
- Tested on
tests/test.txt
. - Lexer output at
tests/Tokens.md
. - AST output at
tests/SyntaxTree.json
.
- Complete the features todo list above