Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LRClosure

Represents the closure given a set of LRItem and CFG.

export
class

LRClosure

Hierarchy

  • LRClosure

Index

Constructors

constructor

  • Creates an instance of LRClosure.

    memberof

    LRClosure

    Parameters

    • item: LRItem[]

      Kernel items.

    • grammer: CFG

      CFG used to generate closure.

    Returns LRClosure

Properties

Private _closure

_closure: LRItem[]

The list of LRItem in the closure.

type

{LRItem[]}

memberof

LRClosure

Private _name

_name: string

The name of the closure.

type

{string}

memberof

LRClosure

Private grammer

grammer: CFG

CFG to produce closures from.

type

{CFG}

memberof

LRClosure

Private kernel

kernel: LRItem[]

The kernel of the closure.

type

{LRItem[]}

memberof

LRClosure

processed

processed: boolean

A flag to check if the closure is processed (i.e. GOTO has been generated for the closure)

Used while generating GotoMap in ParsingTable

type

{boolean}

memberof

LRClosure

Static COUNT

COUNT: number = 0

The number of LRClosure instantiated. Used for naming the closures.

NOTE: Set this to 0 to start name for 0. Else the naming starts continues.

static
type

{number}

memberof

LRClosure

Accessors

closure

  • Get the list of LRItem in the closure

    readonly
    type

    {LRItem[]}

    memberof

    LRClosure

    Returns LRItem[]

name

  • get name(): string
  • Get the name of the closure

    readonly
    type

    {string}

    memberof

    LRClosure

    Returns string

Methods

Private addItem

  • Add the LRItem to closure if not already.

    memberof

    LRClosure

    Parameters

    Returns void

formatProductions

  • formatProductions(): string
  • Gets the string form of the closure.

    memberof

    LRClosure

    Returns string

    A string with closure's name and each item separated with newline(\n)

formatProductionsHtml

  • formatProductionsHtml(): string
  • Gets the HTML form of the closure.

    memberof

    LRClosure

    Returns string

    A ul with the items of closure(formated as string) as list items.

Private genClosure

  • genClosure(): void
  • Generates the closure for the kernel.

    memberof

    LRClosure

    Returns void

getReducingState

  • getReducingState(): LRItem[]
  • Gets all the reducing states(i.e. dot(.) at the end).

    memberof

    LRClosure

    Returns LRItem[]

    List of LRItem

Private hasItem

  • hasItem(item: LRItem): boolean
  • Checks if the closure already has the LRItem.

    memberof

    LRClosure

    Parameters

    Returns boolean

isOfSameKernel

  • isOfSameKernel(kernel: LRItem[]): boolean
  • Checks if the closure has the same kernel as the one provide.

    memberof

    LRClosure

    Parameters

    Returns boolean

    True if same kernel.

toString

  • toString(): string
  • A helper that returns the name of the closure.

    memberof

    LRClosure

    Returns string

Generated using TypeDoc