-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mike Lischke <[email protected]>
- Loading branch information
1 parent
7f0be3b
commit 2dc5efa
Showing
3 changed files
with
46 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |