@gobstones/gobstones-lang-def - v0.1.0

gobstones-lang-def

The definition of the Gobstones Language

Licence Version API Docs

GitHub Workflow Tests GitHub Workflow Build

This component has the definition of the Gobstones Language, its syntactical structure and the means to define concrete strings to use for each of its elements. The component contains the tools needed to produce Gobstones Language valid Abstract Syntax Trees (ASTs), taking as input the definition of the concrete strings for each of the language syntactical elements, and a program using those strings. In this way, Gobstones programs in different languages (like Spanish or English) can be converted to a valid AST. Additionally, different specific domains can be designed without the need to modify the base language.

The process from a Gobstones program to a valid AST includes:

  • a lexical analysis producing 'tokens',
  • a parsing process converting the tokens to an non checked AST, and
  • a final process of linting validation for the AST. For each of these processes, a module is provided: Lexer, Parser, and Linter. The lexer, Lexer, takes a source input with the Gobstones program to process, and depending on which class in the hierarchy is used, also a definition of the concrete words of the language, and returns a list of tokens. The parser, Parser, takes a list of tokens, and returns a non-validated AST. The linter, Linter, takes a non-validated AST, and returns a valid AST. Any of these phases can fail if some error is encountered.

It is usual to name the process involving the three phases also as 'parsing', abusing the naming. However, we will distinguish them, and define a module GLanguage capturing the process of receiving a source input an invoking one, two, or all the three phases in sequence. This can be controlled from the CLI using configuration parameters, or called from another module.

The component also contains definitions of the interfaces and classes needed to provide an association between language syntactical elements and concrete strings. The module is WordsDef, and has classes for defining the the concrete strings of the base language, versions in English, Spanish, and Portuguese, each one using the Standard Domain (the board and stones). Additionally, there are several other modules that intervene during the process, such as the CLI, the definition of specialized errors, translations for error messages and CLI, etc.

Install

Install with your favorite package manager by running one of the following commands:

npm:

npm install --save @gobstones/gobstones-lang-def

Usage

< COMPLETE - Explain how to use your library. >

< COMPLETE - Explain how to import the library and use it as a module.>

CLI

< COMPLETE - If your library supports CLI, explain how to use it. Else, you may delete this section. >

Contributing

See the Gobstones Platform Contribution Guidelines to contribute.