Skip to content
Ron Buckton edited this page Jun 23, 2015 · 3 revisions

Syntax

export declare class Scanner {
  constructor(filename: string, text: string, diagnostics: DiagnosticMessages);

  public getPos(): number;
  public getLen(): number;
  public getStartPos(): number;
  public getTokenPos(): number;
  public getToken(): SyntaxKind;
  public getTokenValue(): string;
  public getDiagnostics(): DiagnosticMessages;
  public scan(): SyntaxKind;
  public speculate<T>(callback: () => T, isLookahead: boolean): T;  
}

Usage

import { Scanner } from "grammarkdown";

let scanner = new Scanner(filename, source, diagnostics);

Constructor

new Scanner(String, String, DiagnosticMessages)
Creates a new instance of the Scanner class

Methods

getPos()
Gets the current position in the source text.
getLen()
Gets the length of the source text.
getStartPos()
Gets the starting position of the current scan.
getTokenPos()
Gets the starting position of the current token.
getToken()
Gets the current token.
getTokenValue()
Gets the current token value.
getDiagnostics()
Gets the diagnostics for the scanner.
scan()
Scans the next token.
speculate(Function, Boolean)
Speculatively scans one or more tokens.

Requirements

  • Supported Platforms: nodejs, iojs
  • Module: grammarkdown
Clone this wiki locally