XML and JSON documents are verbose. Closing tags, brackets, and quotes slow down editing and make documents harder to read. Syntactik has indent based syntax and a minimal set of intuitive rules. Syntactik is easy to read, edit and has a low learning curve.
Code reuse features of Syntactik are unique. It accelerates editing of documents and improves readability. Most data formats don't have code reuse at all. Some formats have basic code reuse features, but Syntactik takes it to another level.
Syntactik can define both XML and JSON documents. So you can use the same language to supply data for apps with XML and JSON APIs.
Equaility sign = assigns literals.
Colon : assigns objects.
Single quote ' and double quote " define literals.
Comma , separates statements if needed.
Parentheses ( ) define regions.
In most cases, strings can be defined without quotes. Symbols following equality sign define a string.
In Syntactik, indents define blocks of code like in popular programming language Python. Blocks start with a colon : . Usage of colon improves readability and prevents mistakes caused by typos. The parser enforces usage of the same indentation style in the whole file.
A single line comment begins with triple single quotes ''' .
A multiline comment begins and ends with triple double quotes """ .
Alias is a powerful code reuse feature.
An alias represents a fragment of code, like literal value, a name/value pair or block of code.
Same alias can be used in multiple places in one or many documents.
Alias definition starts with !$ . Alias starts with $.
An alias definition can have one or more parameters. Paremeters start with !% .
Parameters represent a fragment of code: literal value or block.
Literal parameters have to be assigned with := to distinguish it from a simple literal.
Parameters get real values from the corresponding arguments of aliases. Arguments start with % .
A parameter can have a default value. An argument is optional if the corresponding
parameter has a default value.
An alias can be passed as a value for an argument of another alias. Nested aliases are used to create a template for a code fragment or a whole document.
Alias overloading is the ability to use the same alias with a different set of arguments.
A special kind of block called choice adds overloading to the alias definition.
A choice-block starts with a double colon ::. Each array item in this block represents a case.
A case is a block with or without parameters. When Syntactik compiler is processing an alias, and there is a choice
in the corresponding alias definition, then the compiler tries to resolve cases in the choice one by one.
The first case that is successfully resolved represents the value of choice and the processing of choice stops.
A case is considered to be resolved if all parameters (without a default value) in the case have corresponding arguments
in the alias. If a case has no parameters, then it will always be resolved unless any sibling cases are resolved before.
In Syntactik, name of XML attributes starts with @.
Namespaces must be declared in the module or document. Definition of a namespace starts with !# followed by the XML namespace prefix, equality sign, and a uniform resource identifier (URI). Then the declared prefix can be used in names of elements or attributes. In the name, the namespace prefix is separated by a dot from the rest of the name.
In Syntactik, the array is defined by a block of name/value pairs, where each pair has an empty name.