docs

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.

kem --help
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 run hello.jsk
kem cho, Sanket!

Flags

flagdescription
--tracePrint the token stream and AST before running the program - useful for debugging
--helpShow usage information for this command

Running 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.

$kem run hello.jsk --trace
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.

$kem repl
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.

$kem fmt hello.jsk
Formatted hello.jsk
$kem fmt .
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.

$kem fmt --check .
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.

$kem tokens hello.jsk
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

token typewhat it represents
KEM_BHAIkem bhai - program start
AAVJO_BHAIaavjo bhai - program end
BHAI_BOLbhai bol - print keyword
AAaa - variable declaration keyword
CHEche - assignment keyword
JOjo - if keyword
NAHI_TOnahi to - else keyword
FARVUfarvu - loop body keyword
JYA_SUDHIjya sudhi - loop condition keyword
TAME_JAOtame jao - break
AAGAL_VADOaagal vado - continue
BHAI_CHHEbhai chhe / true
BHAI_NATHIbhai nathi / false
STRINGa string literal
INTEGERan integer literal
FLOATa decimal literal
IDENTIFIERa variable name
EOFend of file

kem ast

Pretty-print the Abstract Syntax Tree that the parser builds from your source. Useful for understanding how kemlang-py parsed your program.

jsk
kem bhai aa x che 10 jo x > 5 { bhai bol "big" } aavjo bhai
$kem ast example.jsk
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.

$kem version
KemLang 0.1.3

Exit codes

All kem commands follow standard exit code conventions:

codemeaning
0Success - program ran without errors
1Error - lexer, parser, or runtime error occurred
2Usage error - wrong command or missing argument

Use exit codes in shell scripts to check whether a program succeeded:

bash
kem run my_program.jsk && echo "Success" || echo "Failed"