-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NodeDefinition
should not have rules
- `Mod` should have `rules` - `defineRule` - `modLookupRule`
- Loading branch information
Showing
8 changed files
with
43 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { Definition } from "../definition" | ||
import { Rule } from "../rule" | ||
|
||
export type Mod = { | ||
url: URL | ||
definitions: Map<string, Definition> | ||
rules: Map<string, Rule> | ||
} |
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,21 @@ | ||
import { Rule } from "../rule" | ||
import { Word } from "../word" | ||
import { Mod } from "./Mod" | ||
import { modLookupNodeDefinitionOrFail } from "./modLookupNodeDefinitionOrFail" | ||
|
||
export function defineRule( | ||
mod: Mod, | ||
start: string, | ||
end: string, | ||
words: Array<Word>, | ||
): void { | ||
mod.rules.set( | ||
`${start} ${end}`, | ||
new Rule( | ||
mod, | ||
modLookupNodeDefinitionOrFail(mod, start), | ||
modLookupNodeDefinitionOrFail(mod, end), | ||
words, | ||
), | ||
) | ||
} |
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,10 @@ | ||
import { Rule } from "../rule" | ||
import { Mod } from "./Mod" | ||
|
||
export function modLookupRule( | ||
mod: Mod, | ||
start: string, | ||
end: string, | ||
): Rule | undefined { | ||
return mod.rules.get(`${start} ${end}`) | ||
} |
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import { Port } from "../graph" | ||
import { Rule } from "../rule" | ||
import { Mod } from "./Mod" | ||
import { modLookupRule } from "./modLookupRule" | ||
|
||
export function modLookupRuleByPorts( | ||
mod: Mod, | ||
start: Port, | ||
end: Port, | ||
): Rule | undefined { | ||
if (start.isPrincipal && end.isPrincipal) { | ||
return start.node.definition.lookupRule(end.node.definition) | ||
return modLookupRule(mod, start.node.name, end.node.name) | ||
} | ||
} |
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