CLI Reference
The kem CLI
The kem command-line tool is the only binary you need. It runs files, starts a REPL, formats code, and lets you inspect the token stream and AST.
KemLang - A Gujarati-flavored programming language Usage: kem [COMMAND] Commands: run Run a KemLang file repl Start an interactive REPL fmt Format KemLang files tokens Show the token stream for a file ast Show the Abstract Syntax Tree for a file version Show version information Options: --help Show this message and exit
kem run
Execute a .jsk file. This is the main command you'll use.
kem cho, Sanket!
Flags
--tracePrint the token stream and AST before running the program - useful for debugging--helpShow usage information for this commandRunning with trace
The --trace flag is invaluable when a program isn't behaving as expected - it shows you exactly how the interpreter sees your code.
Tokens:
KEM_BHAI 'kem bhai' 1:0
BHAI_BOL 'bhai bol' 2:2
STRING '"kem cho!"' 2:10
AAVJO_BHAI 'aavjo bhai' 3:0
AST:
Program
└── Print
└── Literal: "kem cho!"
kem cho!File extensions
kemlang-py files use the .jsk extension. If you pass a file with a different extension,kem run will print a warning but still execute it.
kem repl
Start an interactive Read-Eval-Print Loop. Type kemlang-py code and press Ctrl+D (Unix) or Ctrl+Z (Windows) to execute.
KemLang REPL v0.1.3
Type your code and press Ctrl+D (Unix) or Ctrl+Z (Windows) to execute.
>>> aa x che 10
bhai bol x * 2
[Ctrl+D]
20
>>> The REPL automatically wraps your input in kem bhai / aavjo bhai if you don't include them - so you can skip the boilerplate when experimenting.
kem fmt
Format a .jsk file in-place, or check whether files are already formatted.
Formatted hello.jsk
Formatted examples/hello.jsk Formatted examples/loop_and_if.jsk Already formatted examples/errors.jsk
Check mode
Use --check to verify formatting without modifying files - useful in CI or pre-commit hooks.
Would format examples/hello.jsk 1 file(s) need formatting Exit code: 1
What the formatter does
- ›Normalises indentation to 2 spaces inside blocks
- ›Adds spaces around binary operators (a+b → a + b)
- ›Adds spaces around comparison operators
- ›Removes trailing whitespace
- ›Ensures a single newline at end of file
kem tokens
Print the token stream produced by the lexer. Useful for understanding how kemlang-py reads your source code, and for debugging lexer issues.
Tokens for hello.jsk: KEM_BHAI 'kem bhai' 1:0 BHAI_BOL 'bhai bol' 2:2 STRING '"kem cho!"' 2:10 AAVJO_BHAI 'aavjo bhai' 3:0 EOF '' 4:0
Each token shows: type, literal value, and line:column position in the source file.
Token types
KEM_BHAIkem bhai - program startAAVJO_BHAIaavjo bhai - program endBHAI_BOLbhai bol - print keywordAAaa - variable declaration keywordCHEche - assignment keywordJOjo - if keywordNAHI_TOnahi to - else keywordFARVUfarvu - loop body keywordJYA_SUDHIjya sudhi - loop condition keywordTAME_JAOtame jao - breakAAGAL_VADOaagal vado - continueBHAI_CHHEbhai chhe / trueBHAI_NATHIbhai nathi / falseSTRINGa string literalINTEGERan integer literalFLOATa decimal literalIDENTIFIERa variable nameEOFend of filekem ast
Pretty-print the Abstract Syntax Tree that the parser builds from your source. Useful for understanding how kemlang-py parsed your program.
jskkem bhai aa x che 10 jo x > 5 { bhai bol "big" } aavjo bhai
AST for example.jsk:
Program
├── Declaration (x)
│ └── Literal: 10
└── If
├── Condition: Binary (>)
│ ├── Left: Variable (x)
│ └── Right: Literal: 5
└── Then:
└── Print
└── Literal: "big"kem version
Print the installed version of kemlang-py.
KemLang 0.1.3
Exit codes
All kem commands follow standard exit code conventions:
0Success - program ran without errors1Error - lexer, parser, or runtime error occurred2Usage error - wrong command or missing argumentUse exit codes in shell scripts to check whether a program succeeded:
bashkem run my_program.jsk && echo "Success" || echo "Failed"