Skip to content

Commit

Permalink
EmptyPredictionContext done
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Lischke <[email protected]>
  • Loading branch information
mike-lischke committed Oct 14, 2023
1 parent 7f0be3b commit 2dc5efa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 61 deletions.
23 changes: 0 additions & 23 deletions src/atn/EmptyPredictionContext.d.ts

This file was deleted.

38 changes: 0 additions & 38 deletions src/atn/EmptyPredictionContext.js

This file was deleted.

46 changes: 46 additions & 0 deletions src/atn/EmptyPredictionContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/

import { PredictionContext } from "./PredictionContext.js";
import { SingletonPredictionContext } from "./SingletonPredictionContext.js";

export class EmptyPredictionContext extends SingletonPredictionContext {
/**
* Represents {@code $} in local context prediction, which means wildcard.
* {@code *+x = *}.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
public static readonly Instance = new EmptyPredictionContext();

public constructor() {
super(null, PredictionContext.EMPTY_RETURN_STATE);
}

public override isEmpty(): boolean {
return true;
}

public override getParent(_index: number): PredictionContext | null {
return null;
}

public override getReturnState(_index: number): number {
return this.returnState;
}

public override equals(other: unknown): boolean {

return this === other;
}

public override toString(): string {
return "$";
}

static {
PredictionContext.EMPTY = new EmptyPredictionContext();
}
}

0 comments on commit 2dc5efa

Please sign in to comment.