10 unstable releases (3 breaking)
0.4.0 | Jan 21, 2024 |
---|---|
0.3.0 | Jan 11, 2024 |
0.2.3 | Jun 22, 2023 |
0.1.3 | Jun 21, 2023 |
#547 in Configuration
54 downloads per month
93KB
2.5K
SLoC
SJFL
SJFL is a simple language for configuration files. SJFL is a (syntactically and semantically) superset of JSON and a (syntactically) subset of Python. That means you can parse JSON files using a SJFL parser, and use Python syntax highlighters for SJFL files.
It's not a general-purpose script language. It's intended for config files. That means it's not turing complete.
Syntax
- JSON
- A valid JSON document is a valid SJFL document.
- A few extensions on JSON
- Trailing commas
- Single quoted strings
- Comments with
#
s - More ways of representing numbers
- Any valid SJFL value can be a key of a table.
- For example,
{{[] : []} : {[] : []}}
is valid in SJFL. - There're tradeoffs, though. It cannot check whether a table has multiple same keys.
- For example,
- Variables
- See this section to see how to declare variables.
- Datetime
datetime(2024, 1, 20)
is 1st, January, 2024.- It takes at most 7 arguments:
datetime(2022, 7, 16, 18, 30, 31, 0)
where the arguments are year, month, day, hour, minute, second and microsecond. The last 4 arguments are optional. When the optional arguments are missing, the default value 0 is given.
Statements
For now, statements are not implemented... at all!
Unlike Python, all the SJFL statements must be followed by a semi-colon.
- Assignments (TODO)
- You'll find it useful if you're using SJFL for config files. See the examples below to see what I mean.
- Rules for a name of a variable is the same as that of most other languages. (
[a-zA-Z_] [0-9a-zA-Z]*
)- There are 7 keywords:
true
,false
,null
,True
,False
,None
andimport
. You cannot use them as a variable name.
- There are 7 keywords:
Examples
TODO
BSJFL
Everytime the engine parses a .sjfl
file, it generates a binary version in the same directory, with .bsjfl
extension. It reads .bsjfl
next time if the raw text file has not been modified. It also re-parse the raw-text version if one of its dependency is modified.
Everything is done under the hood, and you don't have to care about it. You just modify .sjfl
files, and do not touch .bsjfl
files.
(TODO) All the binary conversions are done automatically. All you have to do is call execute_file
function.
Dependencies
~310KB