### Type parameters

- #### T

### Hierarchy

- SingleParser<T>
  - Token

## Index

### Methods

- and
- chain
- debug
- drop
- eos
- filter
- flatMap
- map
- match
- occurrence
- opt
- optrep
- or
- parse
- rep
- returns
- then
- val

## Methods

### and

- and<P>(p: P): TupleParser<T>
- and<Y, P>(p: P): TupleParser<T | Y>

- Inherited from IParser.and

  - Defined in masala-parser.d.ts:583

  If all parsers are accepted, the response value will be a Tuple of these values. It's a rare case where a Tuple could contain a Tuple. Warning: still experimental

  #### Type parameters

  - #### P: IParser<T>

  #### Parameters

  - ##### p: P

  #### Returns TupleParser<T>

- Inherited from IParser.and

  - Defined in masala-parser.d.ts:584

  #### Type parameters

  - #### Y

  - #### P: IParser<Y>

  #### Parameters

  - ##### p: P

  #### Returns TupleParser<T | Y>

### chain

- chain<Y, P>(highParser: P): P

- Inherited from IParser.chain

  - Defined in masala-parser.d.ts:628

  Build a new High Leven parser that parses a ParserStream of tokens. Tokens are defined by `this` parser. It's internally used by GenLex which is more easy to work with

  highparser

    high level parser

  #### Type parameters

  - #### Y

  - #### P: IParser<Y>

  #### Parameters

  - ##### highParser: P

  #### Returns P

### debug

- debug(hint: string, showValue?: boolean): this

- Inherited from IParser.debug

  - Defined in masala-parser.d.ts:558

  Will display debug info when the previous parser is accepted.

      // 'found digit' will be displayed only if N.digit() has been accepted
      N.digit().debug('found digit', false);

  #### Parameters

  - ##### hint: string

  - ##### Optional showValue: boolean

  #### Returns this

### drop

- drop(): VoidParser

- Inherited from IParser.drop

  - Defined in masala-parser.d.ts:539

  The parser will return the Neutral element for the Tuple

  #### Returns VoidParser

### eos

- eos(): this

- Inherited from IParser.eos

  - Defined in masala-parser.d.ts:634

  Accept the end of stream. If accepted, it will not change the response

  #### Returns this

### filter

- filter(predicate: function): this

- Inherited from IParser.filter

  - Defined in masala-parser.d.ts:566

  Given an accepted parser and a response value, this parser.filter(predicate) could be rejected depending on the predicate applied on the response value. Filtering a rejected parser will always results in a rejected response.

  #### Parameters

  - ##### predicate: function

    : predicate applied on the response value

    - - (value: T): boolean

      - #### Parameters

        - ##### value: T

        #### Returns boolean

  #### Returns this

### flatMap

- flatMap<Y, P>(builder: parserBuilder<Y, P>): P

- Inherited from IParser.flatMap

  - Defined in masala-parser.d.ts:534

  Create a new parser value knowing the current parsing value

      // Next char must be the double of the previous
        function doubleNumber(param:number){
           return C.string(''+ (param*2) );
        }

       const combinator = N.digit()
           .flatMap(doubleNumber);
       let response = combinator.parse(Streams.ofString('12'));
       assertTrue(response.isAccepted());

  #### Type parameters

  - #### Y

  - #### P: IParser<Y>

  #### Parameters

  - ##### builder: parserBuilder<Y, P>

  #### Returns P

### map

- map<Y>(f: function): SingleParser<Y>

- Inherited from IParser.map

  - Defined in masala-parser.d.ts:515

  Transforms the Response value

      const parser = N.number().map (n => n*2);
      const value = parser.parse(Streams.ofString('1')).value;
      test.equal(value, 2 );

  #### Type parameters

  - #### Y

  #### Parameters

  - ##### f: function

    - - (value: T): Y

      - #### Parameters

        - ##### value: T

        #### Returns Y

  #### Returns SingleParser<Y>

### match

- match(val: T): this

- Inherited from IParser.match

  - Defined in masala-parser.d.ts:619

  Specialized version of filter using `val` equality as predicate

  #### Parameters

  - ##### val: T

    the parser is rejected if it's response value is not `val`

  #### Returns this

### occurrence

- occurrence(n: number): TupleParser<T>

- Inherited from IParser.occurrence

  - Defined in masala-parser.d.ts:613

  Search for next n occurrences. `TupleParser.occurence()` will continue to build one larger Tuple

      let parser = C.char('a').then (C.char('b')).occurrence(3);
      let resp = parser.parse(Streams.ofString('ababab'));
      // ->  Tuple { value: [ 'a', 'b', 'a', 'b', 'a', 'b' ] } }

  #### Parameters

  - ##### n: number

  #### Returns TupleParser<T>

### opt

- opt(): SingleParser<Option<T>>

- Inherited from SingleParser.opt

  Overrides IParser.opt

  - Defined in masala-parser.d.ts:464

  #### Returns SingleParser<Option<T>>

### optrep

- optrep(): TupleParser<T>

- Inherited from IParser.optrep

  - Defined in masala-parser.d.ts:601

  Accepted with zero or more occurrences. Will produce a Tuple of zero or more T

  #### Returns TupleParser<T>

### or

- or(other: SingleParser<T>): SingleParser<T>
- or<Y>(other: SingleParser<Y>): SingleParser<T | Y>
- or(other: TupleParser<T>): TupleParser<T>
- or<Y>(other: TupleParser<Y>): TupleParser<Y> | TupleParser<T>
- or<Y, P>(other: P): SingleParser<T> | P

- Inherited from SingleParser.or

  Overrides IParser.or

  - Defined in masala-parser.d.ts:457

  #### Parameters

  - ##### other: SingleParser<T>

  #### Returns SingleParser<T>

- Inherited from SingleParser.or

  Overrides IParser.or

  - Defined in masala-parser.d.ts:458

  #### Type parameters

  - #### Y

  #### Parameters

  - ##### other: SingleParser<Y>

  #### Returns SingleParser<T | Y>

- Inherited from SingleParser.or

  Overrides IParser.or

  - Defined in masala-parser.d.ts:459

  #### Parameters

  - ##### other: TupleParser<T>

  #### Returns TupleParser<T>

- Inherited from SingleParser.or

  Overrides IParser.or

  - Defined in masala-parser.d.ts:460

  #### Type parameters

  - #### Y

  #### Parameters

  - ##### other: TupleParser<Y>

  #### Returns TupleParser<Y> | TupleParser<T>

- Inherited from SingleParser.or

  Overrides IParser.or

  - Defined in masala-parser.d.ts:461

  #### Type parameters

  - #### Y

  - #### P: IParser<Y>

  #### Parameters

  - ##### other: P

  #### Returns SingleParser<T> | P

### parse

- parse<D>(stream: Stream<D>, index?: number): Response<T>

- Inherited from IParser.parse

  - Defined in masala-parser.d.ts:481

  Parses a stream of items (usually characters or tokens) and returns a Response

  #### Type parameters

  - #### D

  #### Parameters

  - ##### stream: Stream<D>

  - ##### Optional index: number

    optional, index start in the stream

  #### Returns Response<T>

### rep

- rep(): TupleParser<T>

- Inherited from IParser.rep

  - Defined in masala-parser.d.ts:596

  Accepted with one or more occurrences.Will produce an Tuple of at least one T

  #### Returns TupleParser<T>

### returns

- returns<Y>(value: Y): SingleParser<Y>

- Inherited from IParser.returns

  - Defined in masala-parser.d.ts:545

  If accepted, the parser will return the given value

  #### Type parameters

  - #### Y

  #### Parameters

  - ##### value: Y

  #### Returns SingleParser<Y>

### then

- then(p: VoidParser): TupleParser<T>
- then(p: IParser<T>): TupleParser<T>
- then<Y>(p: IParser<Y>): TupleParser<T | Y>

- Inherited from SingleParser.then

  Overrides IParser.then

  - Defined in masala-parser.d.ts:452

  Combine two parsers for reading the stream

      const parser = C.char('a')
        .then(C.char('b'));
        const value = parser.parse(Streams.ofString('ab')).value;
        test.equal(value.size(), 2 );

  #### Parameters

  - ##### p: VoidParser

    next parser

  #### Returns TupleParser<T>

- Inherited from SingleParser.then

  Overrides IParser.then

  - Defined in masala-parser.d.ts:453

  #### Parameters

  - ##### p: IParser<T>

  #### Returns TupleParser<T>

- Inherited from SingleParser.then

  Overrides IParser.then

  - Defined in masala-parser.d.ts:454

  #### Type parameters

  - #### Y

  #### Parameters

  - ##### p: IParser<Y>

  #### Returns TupleParser<T | Y>

### val

- val(text: string): T

- Inherited from IParser.val

  - Defined in masala-parser.d.ts:488

  Mainly designed for quick debugging or unit tests Parses the text and returns the value, or undefined if parsing has failed.

  #### Parameters

  - ##### text: string

    text to parse

  #### Returns T

Generated using TypeDoc