4.9.3 • Published 1 month ago

scalameta-parsers v4.9.3

Weekly downloads
83
License
BSD-3-Clause
Repository
github
Last release
1 month ago

scalameta-parsers

A JS API for the parsers module of scalameta.

It exposes two functions:

  • parseSource(code: string): parses the given code as a full-fledged source file

  • parseStat(code: string): parses the given code a statement (useful for parsing single expressions without wrapping them into an object or class)

Example:

const { parseStat, parseSource } = require('scalameta-parsers');

const tree1 = parseStat('val answer = 42');
console.log(tree1);

// Output:

// { type: 'Defn.Val',
//   children:
//    [ { type: 'Pat.Var.Term', children: [Object], pos: [Object] },
//      { type: 'Lit.Int', children: [], pos: [Object], value: 42 } ],
//   pos: { start: 0, end: 15 } }

const tree2 = parseSource(`
object Main {
  def main(args: Array[String]): Unit =
    println("Hello, World!")
}`);
console.log(tree2);

// Output:

// { type: 'Source',
//   children: [ { type: 'Defn.Object', children: [Object], pos: [Object] } ],
//   pos: { start: 0, end: 85 } }
4.9.3

1 month ago

4.9.2

2 months ago

4.9.1

2 months ago

4.9.1-RC1

2 months ago

4.9.0

3 months ago

4.8.15

4 months ago

4.8.12

7 months ago

4.8.14

6 months ago

4.8.13

6 months ago

4.8.11

8 months ago

4.8.9

8 months ago

4.8.8

9 months ago

4.8.5

10 months ago

4.8.4

10 months ago

4.8.7

9 months ago

4.7.8

11 months ago

4.8.6

10 months ago

4.8.1

10 months ago

4.8.0

10 months ago

4.8.3

10 months ago

4.8.2

10 months ago

4.8.10

8 months ago

4.7.6

1 year ago

4.7.5

1 year ago

4.7.7

1 year ago

4.7.2

1 year ago

4.7.4

1 year ago

4.7.3

1 year ago

4.7.1

1 year ago

4.7.0

1 year ago

4.4.1-7.beta0

3 years ago

4.4.17

3 years ago

4.2.1

5 years ago

4.2.0

5 years ago

2.0.1

7 years ago

2.0.0-RC3

7 years ago

1.9.0-beta.3

7 years ago

1.9.0-beta.2

7 years ago

1.9.0-beta.1

7 years ago

1.9.0-beta

7 years ago

1.8.0

7 years ago