-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Splitting Matcher into Graph and GraphMatcher
- Loading branch information
1 parent
44f5808
commit eba7270
Showing
95 changed files
with
1,047 additions
and
846 deletions.
There are no files selected for viewing
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
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
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
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,25 @@ | ||
import { Node } from './Node'; | ||
import { MatchingState } from './matching'; | ||
import { GraphOptions } from './GraphOptions'; | ||
|
||
/** | ||
* Graph that has been built via GraphBuilder. Graphs are a collection of | ||
* outgoing nodes that can parse an expression. | ||
*/ | ||
export interface Graph<DataType> { | ||
/** | ||
* The outgoing nodes of this graph. | ||
*/ | ||
nodes: Node[]; | ||
|
||
/** | ||
* Options to apply during matching of this graph. | ||
*/ | ||
options: GraphOptions; | ||
|
||
/** | ||
* Internal state of this matcher that is accessed if it is used as a | ||
* sub graph. | ||
*/ | ||
matchingState: MatchingState; | ||
} |
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
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,5 @@ | ||
import { EncounterOptions } from './matching'; | ||
|
||
export interface GraphOptions extends EncounterOptions { | ||
name?: string; | ||
} |
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,48 @@ | ||
import { NumberData } from '../numbers/NumberData'; | ||
import { DateTimeData } from '../time/DateTimeData'; | ||
import { OrdinalData } from '../numbers/OrdinalData'; | ||
|
||
/** | ||
* Graphs that are known to be available for a language. This enum used when | ||
* fetching a graph from a language and to lookup the type the graph uses. | ||
* | ||
* This allows for type-safety within the values. | ||
*/ | ||
export enum KnownGraphs { | ||
Boolean = 'boolean', | ||
DateDuration = 'date-duration', | ||
Date = 'date', | ||
DateInterval = 'date-interval', | ||
DateTimeDuration = 'date-time-duration', | ||
DateTime = 'date-time', | ||
Integer = 'integer', | ||
Month = 'month', | ||
Number = 'number', | ||
Ordinal = 'ordinal', | ||
Quarter = 'quarter', | ||
TimeDuration = 'time-duration', | ||
Time = 'time', | ||
Week = 'week', | ||
Year = 'year' | ||
} | ||
|
||
/** | ||
* Types for `KnownGraphs`. | ||
*/ | ||
export interface KnownGraphsDataTypes { | ||
[KnownGraphs.Boolean]: boolean; | ||
[KnownGraphs.DateDuration]: DateTimeData; | ||
[KnownGraphs.Date]: DateTimeData; | ||
[KnownGraphs.DateInterval]: DateTimeData; | ||
[KnownGraphs.DateTimeDuration]: DateTimeData; | ||
[KnownGraphs.DateTime]: DateTimeData; | ||
[KnownGraphs.Integer]: NumberData; | ||
[KnownGraphs.Month]: DateTimeData; | ||
[KnownGraphs.Number]: NumberData; | ||
[KnownGraphs.Ordinal]: OrdinalData; | ||
[KnownGraphs.Quarter]: DateTimeData; | ||
[KnownGraphs.TimeDuration]: DateTimeData; | ||
[KnownGraphs.Time]: DateTimeData; | ||
[KnownGraphs.Week]: DateTimeData; | ||
[KnownGraphs.Year]: DateTimeData; | ||
} |
Oops, something went wrong.