Parser and AST for the Nit language

The parser and the AST are mostly used by all tools.

The parser is the tool that transform source-files into abstract syntax trees (AST) (see parser_nodes) While the AST is a higher abstraction than blob of text, the AST is still limited and represents only What the programmer says.

Classes of nodes of the AST starts with the letter A (for most things, eg. AClassdef) or T (for token eg. TId), there is no real reason except historical that might be solved with a new parser.

Variable names of the AST usually starts with n (for node). This is also historical but some names with a a (to mimic the class name) remains.

SableCC

Most files in this directory are generated from a grammar for sablecc3 ( http://www.sablecc.org ). In order to generate nit parser, you need the alternate SableCC3 generator ( http://www.mare.ee/indrek/sablecc/ ).

Moreover, the Nit language description file extends the standard SableCC3 syntax and includes parametric productions to factorize the description of the language.

In order to simplify the development of the Nit tools, files produced by the parser generator are committed in the repository; therefore Java and SableCC3 is only required to alter the Nit syntax.

Contents

  • fact_parser.pl: Script used to factorize parser.nit
  • Makefile: Update grammar and generate .nit files
  • nit.sablecc3xx: Extended sablecc3 grammar (see prescc.pl)
  • prescc.pl: Program to transform an extended sablecc3 to a standard one
  • parser_nodes.nit: token and nodes classes hierarchy used by the parser and the lexer
  • tables.nit, tables_nit.h: Interfaces to access the tables needed by the parser and the lexer
  • xss/*.xss: alternate SableCC3 template files for the Nit language
  • org/nitlanguage/gen: A Nit parser in Java, used for tests. use the make java rule to build it.

The following are generated but present to avoid the need of sablecc3:

  • lexer.nit: generated lexer
  • parser.nit: generated parser
  • parser_prod.nit: All production with generated visit methods
  • tables_nit.c: The tables needed by the parser and the lexer
  • parser_abs.nit: Raw generated token and nodes classes used to maintain coherence of parser_nodes.nit

Other temp files produced by the Makefile:

  • .nit.sablecc3: Sablecc3 grammar after processing
  • .nit.sablecc3.dump: Dump of the grammar to improve sablecc3 multiple runs
  • .parser-nofact.nit: The parser generated by SableCC3 before factorization by fact_parser.pl

All subgroups and modules

module lexer

nitc :: lexer

Lexer and its tokens.
module lexer_work

nitc :: lexer_work

Internal algorithm and data structures for the Nit lexer
group org

nitc > parser > org

module parser

nitc :: parser

Parser.
module parser_nodes

nitc :: parser_nodes

AST nodes of the Nit language
module parser_prod

nitc :: parser_prod

Production AST nodes full definition.
module parser_work

nitc :: parser_work

Internal algorithm and data structures for the Nit parser
module tables

nitc :: tables

Module that interfaces the parsing tables.
group xss

nitc > parser > xss

package_diagram nitc\>parser\> parser nitc nitc nitc\>parser\>->nitc ordered_tree ordered_tree nitc\>parser\>->ordered_tree console console nitc\>parser\>->console core core nitc\>parser\>->core nitc\>frontend\> frontend nitc->nitc\>frontend\> ordered_tree->core console->core ...nitc ... ...nitc->nitc ...core ... ...core->core nitc\>frontend\>->nitc\>parser\> nitc\>compiler\> compiler nitc\>compiler\>->nitc\>frontend\> nitc\>interpreter\> interpreter nitc\>interpreter\>->nitc\>frontend\> nitc\>metrics\> metrics nitc\>metrics\>->nitc\>frontend\> nitc\>model\> model nitc\>model\>->nitc\>frontend\> nitc\>testing\> testing nitc\>testing\>->nitc\>frontend\> nitc\>compiler\>... ... nitc\>compiler\>...->nitc\>compiler\> nitc\>interpreter\>... ... nitc\>interpreter\>...->nitc\>interpreter\> nitc\>metrics\>... ... nitc\>metrics\>...->nitc\>metrics\> nitc\>model\>... ... nitc\>model\>...->nitc\>model\> nitc\>testing\>... ... nitc\>testing\>...->nitc\>testing\>

Ancestors

group api

nitc > doc > api

Components required to build a web server about the nit model.
group base64

base64

Offers the base 64 encoding and decoding algorithms
group c

c

Structures and services for compatibility with the C language
group catalog

nitc > catalog

Basic catalog generator for Nit packages
group codecs

core > codecs

Group module for all codec-related manipulations
group collection

core > collection

This module define several collection classes.
group commands

nitc > doc > commands

group compiler

nitc > compiler

Compilation to C
group compiler_ffi

nitc > compiler > compiler_ffi

Full FFI support for the compiler
group config

config

Configuration options for nit tools and apps
group counter

counter

Simple numerical statistical analysis and presentation
group csv

csv

CSV document handling.
group curl

curl

Data transfer powered by the native curl library
group doc

nitc > doc

group dot

dot

Dot rendering library
group dynamic_loading_ffi

nitc > interpreter > dynamic_loading_ffi

This group implement a partial support for the Nit FFI in the interpreter.
group ffi

nitc > ffi

Full FFI support, independent of the compiler
group frontend

nitc > frontend

Collect and orchestration of main frontend phases
group gen_nit

gen_nit

Support to generate and otherwise manipulate Nit code
group github

github

Nit wrapper for Github API
group graph

graph

group html

html

HTML output facilities
group ini

ini

ini - Read and write INI configuration files
group interpreter

nitc > interpreter

Interpretation of Nit programs
group json

json

read and write JSON formatted text
group libevent

libevent

Low-level wrapper around the libevent library to manage events on file descriptors
group logger

logger

A simple logger for Nit
group markdown

markdown

A markdown parser for Nit.
group md5

md5

Native MD5 digest implementation as Text::md5
group meta

meta

Simple user-defined meta-level to manipulate types of instances as object.
group metrics

nitc > metrics

Various statistics about Nit models and programs
group model

nitc > model

The meta model of Nit programs
group modelize

nitc > modelize

Create a model from nit source files
group mongodb

mongodb

MongoDB Nit Driver.
group more_collections

more_collections

Highly specific, but useful, collections-related classes.
group neo4j

neo4j

Neo4j connector through its JSON REST API using curl.
group nitcorn

nitcorn

Lightweight framework for Web applications development
group nitni

nitc > nitni

Native interface related services (used underneath the FFI)
group opts

opts

Management of options on the command line
group parser_base

parser_base

Simple base for hand-made parsers of all kinds
group perfect_hashing

perfect_hashing

Perfect hashing and perfect numbering
group performance_analysis

performance_analysis

Services to gather information on the performance of events by categories
group pipeline

pipeline

Pipelined filters and operations on iterators.
group platform

nitc > platform

Platform system, used to customize the behavior of the compiler.
group popcorn

popcorn

Popcorn
group poset

poset

Pre order sets and partial order set (ie hierarchies)
group prompt

prompt

Basic services to display a prompt
group pthreads

pthreads

POSIX Threads support
group realtime

realtime

Services to keep time of the wall clock time
group saf

nitc > saf

Nit Static Analysis Framework.
group semantize

nitc > semantize

Process bodies of methods in regard with the model.
group serialization

serialization

Abstract serialization services
group static

nitc > doc > static

Nitdoc generation framework
group template

template

Basic template system
group term

nitc > doc > term

group testing

nitc > testing

Test unit generation and execution for Nit.
group text

core > text

All the classes and methods related to the manipulation of text entities
group trees

trees

General module for tree data structures
group uml

nitc > uml

Group head module for UML generation services
group vm

nitc > vm

Entry point of all vm components

Parents

group console

console

Defines some ANSI Terminal Control Escape Sequences.
group core

core

Nit common library of core classes and methods
group nitc

nitc

Nit compiler and tools
group ordered_tree

ordered_tree

Manipulation and presentation of ordered trees.

Children

group frontend

nitc > frontend

Collect and orchestration of main frontend phases
group nitc

nitc

Nit compiler and tools

Descendants

group api

nitc > doc > api

Components required to build a web server about the nit model.
group catalog

nitc > catalog

Basic catalog generator for Nit packages
group commands

nitc > doc > commands

group compiler

nitc > compiler

Compilation to C
group compiler_ffi

nitc > compiler > compiler_ffi

Full FFI support for the compiler
group doc

nitc > doc

group dynamic_loading_ffi

nitc > interpreter > dynamic_loading_ffi

This group implement a partial support for the Nit FFI in the interpreter.
group ffi

nitc > ffi

Full FFI support, independent of the compiler
group interpreter

nitc > interpreter

Interpretation of Nit programs
group metrics

nitc > metrics

Various statistics about Nit models and programs
group model

nitc > model

The meta model of Nit programs
group modelize

nitc > modelize

Create a model from nit source files
group nitni

nitc > nitni

Native interface related services (used underneath the FFI)
group platform

nitc > platform

Platform system, used to customize the behavior of the compiler.
group saf

nitc > saf

Nit Static Analysis Framework.
group semantize

nitc > semantize

Process bodies of methods in regard with the model.
group static

nitc > doc > static

Nitdoc generation framework
group term

nitc > doc > term

group testing

nitc > testing

Test unit generation and execution for Nit.
group uml

nitc > uml

Group head module for UML generation services
group vm

nitc > vm

Entry point of all vm components