-
Notifications
You must be signed in to change notification settings - Fork 22
Allow dependencies between pages on the wiki #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
robsimmons
wants to merge
6
commits into
main
Choose a base branch
from
web-of-knowledge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3968742
Allow an 'import' statement in the prelude to import context from oth…
robsimmons 82e98de
Fix regression tests
robsimmons b0c7608
log--
robsimmons 951b5f8
Move the cfg generation to be more closely connected to the wiki
robsimmons f72a0ae
Compliant style and complete proof for type safety for the natural nu…
robsimmons fd2b3c0
Make diff a bit prettier
robsimmons File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 +1,4 @@ | ||
| CM | ||
| .cm | ||
| src/frontend/buildid.sml | ||
| src/frontend/buildid.sml | ||
| TEST/regression-wiki.txt |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,72 @@ | ||
| import { readFileSync } from "fs"; | ||
|
|
||
| /** | ||
| * Read the file's header to get all of the imported elf files | ||
| * (in reverse order) | ||
| * | ||
| * @param {string} contents | ||
| */ | ||
| function getImportedFilenames(contents) { | ||
| /**@type {string[]} */ | ||
| const importStatements = []; | ||
|
|
||
| for (const line of contents.split("\n")) { | ||
| if (!line.startsWith("%%! ")) break; | ||
| if (line.startsWith("%%! import: ")) { | ||
| importStatements.push(line.slice(12).trim()); | ||
| } | ||
| } | ||
|
|
||
| return importStatements; | ||
| } | ||
|
|
||
| /** | ||
| * Uses a DFS traversal | ||
| * | ||
| * @param {string} base | ||
| * Relative path of elf files | ||
| * @param {Set<string>} known | ||
| * Avoids double-importing by tracking all the filenames ever added to `accum` in the process of this traversal | ||
| * @param {{file: string, contents: string}[]} accum | ||
| * Accumulates the files, making sure that files are added after their dependencies | ||
| * @param {string} elfname | ||
| * Name of an ELF file that is a dependency of the file we're trying to load | ||
| */ | ||
| function dfsAccumImportedPrelude(base, known, accum, elfname) { | ||
| if (!elfname.match(/^[a-zA-Z.\-_0-9]*[.]elf*$/)) { | ||
| throw new Error( | ||
| `Imported path ${elfname} invalid: must include only letters, numbers, dashes, and underscores and end in .elf` | ||
| ); | ||
| } | ||
| const contents = readFileSync(`${base}${elfname}`).toString("utf-8"); | ||
| for (const importElf in getImportedFilenames(contents)) { | ||
| if (!known.has(importElf)) { | ||
| known.add(importElf); | ||
| dfsAccumImportedPrelude(base, known, accum, importElf); | ||
| } | ||
| } | ||
| accum.push({ file: elfname, contents }); | ||
| } | ||
|
|
||
| /** | ||
| * | ||
| * @param {string} base | ||
| * Relative path of elf files | ||
| * @param {string} elfname | ||
| */ | ||
| export function getImportedPrelude(base, elfname) { | ||
| /**@type {Set<string>} */ | ||
| const known = new Set(); | ||
|
|
||
| /**@type {{file: string, contents: string}[]} */ | ||
| const dependencies = []; | ||
|
|
||
| for (const file of getImportedFilenames( | ||
| readFileSync(`${base}${elfname}`).toString("utf-8") | ||
| )) { | ||
| known.add(file); | ||
| dfsAccumImportedPrelude(base, known, dependencies, file); | ||
| } | ||
|
|
||
| return dependencies; | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the cfg auto-generation into the wiki project means we can just invoke that auto-generation to run the regression tests.