> For the complete documentation index, see [llms.txt](https://php-parser.glayzzle.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://php-parser.glayzzle.com/api/parser.js.md).

# Parser

## Constants

[ignoreStack](/api/parser.js.md#ignoreStack)

outputs some debug information on current token

## parser

**Kind**: global class\
**Properties**

| Name           | Type                  | Description                               |
| -------------- | --------------------- | ----------------------------------------- |
| lexer          | `Lexer`               | current lexer instance                    |
| ast            | `AST`                 | the AST factory instance                  |
| token          | `Integer` \| `String` | current token                             |
| extractDoc     | `Boolean`             | should extract documentation as AST node  |
| extractTokens  | `Boolean`             | should extract each token                 |
| suppressErrors | `Boolean`             | should ignore parsing errors and continue |
| debug          | `Boolean`             | should output debug informations          |

* [parser](/api/parser.js.md#parser)
  * [.getTokenName()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+getTokenName)
  * [.parse()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+parse)
  * [.raiseError()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+raiseError)
  * [.error()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+error)
  * [.node()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+node)
  * [.expectEndOfStatement()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+expectEndOfStatement) ⇒ `boolean`
  * [.expect(token)](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+expect) ⇒ `boolean`
  * [.text()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+text) ⇒ `String`
  * [.next()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+next)
  * [.lex()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+lex)
  * [.is()](https://php-parser.glayzzle.com/api/pages/-L_3rojE0q9u57zp52X5#parser+is)

### parser.getTokenName()

helper : gets a token name

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.parse()

main entry point : converts a source code to AST

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.raiseError()

Raise an error

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.error()

handling errors

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.node()

Creates a new AST node

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.expectEndOfStatement() ⇒ `boolean`

expects an end of statement or end of file

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.expect(token) ⇒ `boolean`

Force the parser to check the current token.

If the current token does not match to expected token, the an error will be raised.

If the suppressError mode is activated, then the error will be added to the program error stack and this function will return `false`.

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)\
**Throws**:

* Error

| Param | Type                 |
| ----- | -------------------- |
| token | `String` \| `Number` |

### parser.text() ⇒ `String`

Returns the current token contents

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.next()

consume the next token

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.lex()

Eating a token

**Kind**: instance method of [`parser`](/api/parser.js.md#parser)<br>

### parser.is()

Check if token is of specified type

## Constants

stance method of [`parser`](/api/parser.js.md#parser)

oreStack">\</a>

[ignoreStack](/api/parser.js.md#ignoreStack)

outputs some debug information on current tokenck debug information on current token \</dl> **Kind**: global constant

## API

* [array.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/array.js.md)
* [class.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/class.js.md)
* [comment.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/comment.js.md)
* [expr.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/expr.js.md)
* [function.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/function.js.md)
* [if.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/if.js.md)
* [loops.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/loops.js.md)
* [main.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/main.js.md)
* [namespace.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/namespace.js.md)
* [scalar.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/scalar.js.md)
* [statement.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/statement.js.md)
* [switch.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/switch.js.md)
* [try.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/try.js.md)
* [utils.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/utils.js.md)
* [variable.js](https://github.com/glayzzle/php-parser.glayzzle.com/tree/392b36f46748fbb049e5901bfce9a78bf1d0e48f/api/docs/api/variable.js.md)
