sjfl 0.1.0

Simple language for config files
Documentation

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
      • 0x1234
      • 0b10101
      • 3.1415926535897932384626
        • Most implementations that use floating points cannot represent this value correctly. But this implementation does, thanks to hmath.
      • It also supports arbitrary-precision integers, thanks to hmath.
    • 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.
  • Variables

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 and import. You cannot use them as a variable name.
  • Imports (TODO)
    • A filename must be a valid identifier.
    • It looks for the file inside the same directory. There's no way you can import files from another directory.

Import system

All the SJFL files are pure functions. That means the files are always evaluated to the same value unless you modify the file (or a file it imports).

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.