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 (eg
gcc
)
- Build with
install.sh
- Executable path is
target/shsc-rel
- Download
Git Bash
- Install Git Bash. Now you can run bash on Windows.
- Download
Make
- Download
Bison
- Download
MinGW
- 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 Git Bash in project root
- Run
install.sh
For Windows users, you'll need to use cygwin
or git bash
to get make
working.
Idk if you can compile it on MSVC so give it a shot and maybe contribute an md
on it.
USAGE:
shsc [FILENAMES] execute files listed as args
shsc <flags> [FILENAMES] provide with additional flags
FLAGS:
-r --run [FILENAME] run files listed in file
-t --ast [FILENAME] save AST as JSON to file
-ldbg --lex-debug [FILENAME] produce formatted JSON
-tf --astf [FILENAME] produce formatted JSON
-h --help view this message
-v --version version info
Examples at examples/
.
make run ARGS="examples/helloworld.txt"
or, if properly loaded in PATH
environment variable
shsc examples/helloworld.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
- Variable Shadowing
- 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
- Spaces in file path is valid and quotes not required
- If shsc fails to read one file, it'll skip to next file
- If shsc fails to 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
# tested using tests/build.txt list file
shsc -r tests/build.txt
# 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