15.0.0 • Published 9 months ago

@maniascript/parser v15.0.0

Weekly downloads
16
License
LGPL-3.0-or-later
Repository
gitlab
Last release
9 months ago

Maniascript parser

Parse a Maniascript string and generate an ANTLR parse tree and an AST.

Installation

Install with npm: npm install @maniascript/parser.

Import

parse

import { parse } from '@maniascript/parser' or const { parse } = require('@maniascript/parser')

parse is a function that takes a Maniascript string as input, parses it and returns the result.

import { parse } from '@maniascript/parser'

const result = parse(`
main() {
  declare Integer Test = 0;
}
`)

result will have the following properties after a successful parsing

{
  success: true,
  errors: [],
  tree: { ... },
  ast: { ... }
}

result will have the following properties after a failed parsing

{
  success: false,
  errors: [{ line: 1, column: 1, message: 'There is an error' }],
  tree: { ... },
  ast: { ... }
}

ManiaScriptLexer

import { ManiaScriptLexer } from '@maniascript/parser' or const { ManiaScriptLexer } = require('@maniascript/parser')

ManiaScriptLexer is the ANTLR lexer class.

ManiaScriptParser

import { ManiaScriptParser } from '@maniascript/parser' or const { ManiaScriptParser } = require('@maniascript/parser')

ManiaScriptParser is the ANTLR parser class.

ManiaScriptListener

import { ManiaScriptListener } from '@maniascript/parser' or const { ManiaScriptListener } = require('@maniascript/parser')

ManiaScriptListener is the listenener generated by ANTLR to walk through the parse tree.

ManiaScriptVisitor

import { ManiaScriptVisitor } from '@maniascript/parser' or const { ManiaScriptVisitor } = require('@maniascript/parser')

ManiaScriptVisitor is the visitor generated by ANTLR to walk through the parse tree.

AST

The documentation for the abstract syntax tree generated by the parser is available here.

15.0.0

9 months ago

14.0.0

12 months ago

14.1.0

10 months ago

13.0.0

12 months ago

14.2.0

10 months ago

14.3.0

10 months ago

12.0.0

2 years ago

12.1.0

2 years ago

12.2.0

2 years ago

11.0.0

3 years ago

10.5.1

3 years ago

10.4.0

3 years ago

10.0.0

3 years ago

10.1.0

3 years ago

10.2.0

3 years ago

10.1.1

3 years ago

10.3.0

3 years ago

9.1.0

3 years ago

9.0.0

3 years ago

7.2.1

3 years ago

8.1.0

3 years ago

8.0.1

3 years ago

8.0.0

3 years ago

8.0.2

3 years ago

7.2.0

3 years ago

7.1.0

3 years ago

7.0.1

3 years ago

6.0.0

3 years ago

5.4.0

4 years ago

5.3.0

4 years ago

5.2.0

4 years ago

5.1.0

4 years ago

5.0.0

4 years ago

4.0.0

4 years ago

3.0.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago