# @photon-terminal/parser

> The syntax analysis tool for Photon Terminal

Latest version **0.1.0-alpha.1** (published 2023-07-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @photon-terminal/parser
pnpm add @photon-terminal/parser
yarn add @photon-terminal/parser
bun add @photon-terminal/parser
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0-alpha.1 |
| Published | 2023-07-25 |
| First published | 2023-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Casper Tollefsen |
| Maintainers | caspersocio |
| Keywords | photon, terminal, syntax, anlysis, tool, parser |

## Links

- npm: https://www.npmjs.com/package/@photon-terminal/parser
- Repository: https://github.com/CasperSocio/photon-terminal
- Homepage: https://github.com/CasperSocio/photon-terminal/tree/main/lib/parser#readme
- Issues: https://github.com/CasperSocio/photon-terminal/issues
- npm.io page: https://npm.io/package/@photon-terminal/parser

## Dependencies (2)

- [@photon-terminal/lexer](https://npm.io/package/@photon-terminal/lexer.md) ^0.1.0-alpha.1
- [@photon-terminal/shared](https://npm.io/package/@photon-terminal/shared.md) ^0.1.0-alpha.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.0-alpha.1 (latest) — 2023-07-25
- 0.1.0-alpha.0 — 2023-07-24

## README

# Photon Terminal Parser

The syntax analysis tool made for Photon Terminal.

## Install

```bash
npm i @photon-terminal/parser
```

## Usage

```typescript
import { parse } from '@photon-terminal/parser'

const ast = parse(`
  const age = 42;
  let isOld;

  if (age <= 69) {
    isOld = false;
  } else {
    isOld = true;
  }
`)

console.log(JSON.stringify(ast, null, 2))
```

Will print

```json
{
  "type": "Program",
  "body": [
    {
      "type": "VariableStatement",
      "kind": "const",
      "declarations": [
        {
          "type": "VaraiableDeclaration",
          "id": {
            "type": "Identifier",
            "name": "age"
          },
          "init": {
            "type": "NumericLiteral",
            "value": 42
          }
        }
      ]
    },
    {
      "type": "VariableStatement",
      "kind": "let",
      "declarations": [
        {
          "type": "VaraiableDeclaration",
          "id": {
            "type": "Identifier",
            "name": "isOld"
          },
          "init": null
        }
      ]
    },
    {
      "type": "IfStatement",
      "test": {
        "type": "ExpressionStatement",
        "expression": {
          "type": "BinaryExpression",
          "operator": "<=",
          "left": {
            "type": "Identifier",
            "name": "age"
          },
          "right": {
            "type": "NumericLiteral",
            "value": 69
          }
        }
      },
      "consequent": {
        "type": "BlockStatement",
        "body": [
          {
            "type": "ExpressionStatement",
            "expression": {
              "type": "AssignmentExpression",
              "operator": "=",
              "left": {
                "type": "Identifier",
                "name": "isOld"
              },
              "right": {
                "type": "BooleanLiteral",
                "value": false
              }
            }
          }
        ]
      },
      "alternate": [
        {
          "type": "ExpressionStatement",
          "expression": {
            "type": "AssignmentExpression",
            "operator": "=",
            "left": {
              "type": "Identifier",
              "name": "isOld"
            },
            "right": {
              "type": "BooleanLiteral",
              "value": true
            }
          }
        }
      ]
    }
  ]
}
```

---
_Source: https://npm.io/package/@photon-terminal/parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
