Syntactik

People-friendly preprocessor for XML and JSON

Use this advanced people-friendly format to supply data for XML and JSON APIs without changing code.

Try it

What makes Syntactik different?

Clarity and conciseness

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

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.

One language - two APIs

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.

Intuitive, clean and concise syntax

Syntactik uses symbols that have obvious meaning

Equaility sign = assigns literals.
Colon : assigns objects.
Single quote ' and double quote " define literals.
Comma , separates statements if needed.
Parentheses ( ) define regions.

Quotes are optional

In most cases, strings can be defined without quotes. Symbols following equality sign define a string.

Indents define document structure

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.

Comments help documenting code

A single line comment begins with triple single quotes ''' .
A multiline comment begins and ends with triple double quotes """ .

Code reuse

Alias

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

Aliases with parameters

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.

Nested aliases

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

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.

Compatibility with XML and JSON

Syntactik supports XML-specific entities like attributes and namespaces as well as JSON-specific entities like arrays. Syntactik has a notion of a module. Files with extension "s4x" or "s4j" physically represent a module. Code in s4x-module define XML data. Similarly, code in s4j-module represents JSON data.

Attributes

In Syntactik, name of XML attributes starts with @.

Namespaces

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.

Array

In Syntactik, the array is defined by a block of name/value pairs, where each pair has an empty name.

Implementation

Currently, Syntactik.NET is the only full implementation of the Syntactik language.
SyntactikJs is the proof of concept implemented in JavaScript. The project destination is to prove that it is possible to convert Syntactik parser (about 1K lines of code) to another language in a matter of days by just converting language instructions one to one. Like, for example, converting if statement in C# into if statement in JavaScript, etc.

Help

Documentation

Syntactik ReadMe has full description of the language syntax and features.

Chat room

Discuss Syntactik language, Syntactik.NET library, or Syntactik Editor online in the Gitter chat room.

Forum

Join Syntactik Google groups forum. Look through the forum topics to find the answer or create the new one.

Try it

Try to create, add, edit and compile Syntactik files with Syntactik Editor. Syntactik Editor is a cross-platform IDE for Syntactik projects of any size and complexity. Currently, the beta-version for Windows is available to download:
  • To download the demo, please register using the form below.
  • If you have already registered, just fill in the name and email address.
  • Your download will start automatically.
  • Syntactik Editor installation instructions.
  • Syntactik Editor guide.
  • Download demo without registration.