-
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
2dc5efa
commit 057e86c
Showing
3 changed files
with
50 additions
and
103 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,50 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/* eslint-disable @typescript-eslint/naming-convention, jsdoc/require-returns, jsdoc/require-param */ | ||
|
||
import { HashCode } from "../misc/HashCode.js"; | ||
|
||
export abstract class PredictionContext { | ||
/** | ||
* Represents {@code $} in an array in full context mode, when {@code $} | ||
* doesn't mean wildcard: {@code $ + x = [$,x]}. Here, | ||
* {@code $} = {@link //EMPTY_RETURN_STATE}. | ||
*/ | ||
public static readonly EMPTY_RETURN_STATE = 0x7FFFFFFF; | ||
|
||
// Temporarily here. Should be moved to EmptyPredictionContext. It's initialized in that context class. | ||
public static EMPTY: PredictionContext; | ||
|
||
public static trace_atn_sim = false; | ||
|
||
private cachedHashCode: number; | ||
|
||
public constructor(cachedHashCode: number) { | ||
this.cachedHashCode = cachedHashCode; | ||
} | ||
|
||
public isEmpty(): boolean { | ||
return false; | ||
} | ||
|
||
public hasEmptyPath(): boolean { | ||
return this.getReturnState(this.length - 1) === PredictionContext.EMPTY_RETURN_STATE; | ||
} | ||
|
||
public hashCode(): number { | ||
return this.cachedHashCode; | ||
} | ||
|
||
public updateHashCode(hash: HashCode): void { | ||
hash.update(this.cachedHashCode); | ||
} | ||
|
||
public abstract getParent(index: number): PredictionContext | null; | ||
public abstract getReturnState(index: number): number; | ||
public abstract get length(): number; | ||
public abstract equals(obj: unknown): boolean; | ||
} |