Syntax
There are two styles of coding syntax: chili and pepper.
chiliis a modern syntax, more amiable to other developers using other languages, especiallyjavascript.pepperis a vintage syntax, similar toq.
Syntax Configuration for Vim
Vim configuration files are located in vim-config.
Just copy the files to the ~/.vim directory.
Evaluation Order
Tip
There is no precedence for operators in chili, which means +, * have the same precedence.
Statements are evaluated from left to right . .e.g 2+3*4+5 is evaluated as ((2+3)*4)+5.
Statements are evaluated from right to left. .e.g 2+3*4+5 is evaluated as 2+(3*(4+5)).
Import
To import source files, use import function. Using CHILI_PKG_PATH environment variable(Pending), it is used to resolve the import path. CHILI_PKG_PATH uses ~/chili by default.
- relative path has to be started with
./or../ - absolute path has to be started with
/ - path starts from
CHILI_PKG_PATHhas to be started with@or alphabetical characters
Package Path(Pending)
A typical source file from package path looks like $CHILI_PKG_PATH/pkg/v0.0.0/src/code.chi, and the import code is import("pkg/code.chi").
Comments
Same for both syntaxes.
Variables
Starts with a letter, followed by letters, digits, or underscores. Global variables are prefixed with a dot. Same for both syntaxes.
Assignment
Assign a value to a variable, unlike other languages, this also returns the assigned value.
Control Flow
If
If Else Short-hand
This is an expression, not a statement, which requires a semicolon to separate with next statement.
While
Try
Functions
Function Definition
For chili syntax, function, return, raise are keywords.