-
Couldn't load subscription status.
- Fork 1
Independent scheme #165
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
Open
TRK95
wants to merge
40
commits into
main
Choose a base branch
from
SRI-NA
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.
Open
Independent scheme #165
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
6a2e041
feat: Complete CSE machine and Conductor integration
TRK95 09ed1d1
rm remnant code
TRK95 1343254
chore: add dist/index.js to repository for CDN and browser use
TRK95 c5e3a83
Add GitHub Pages deployment workflow
TRK95 4198709
Add GitHub Pages landing page
TRK95 7a60363
Fix: Add HelloServiceMessage protocol handshake in RunnerPlugin const…
TRK95 d94c4af
Fix scm-slang integration: UMD format, conductor initialization, and …
TRK95 a12f62b
Remove package-lock.json to fix CI/CD - project uses Yarn
TRK95 b277f97
Fix GitHub Actions: Use yarn instead of npm for deploy-pages workflow
TRK95 1aaf9a8
Temporarily disable deploy-pages workflow - need to setup GitHub Page…
TRK95 2efa27b
Remove deploy-pages workflow to follow py-slang pattern - only keep N…
TRK95 b9cb59a
Add dist/ to .gitignore and remove dist folder - follow py-slang pattern
TRK95 7f305b5
Fix environment restoration and implement compound functions - Add RE…
TRK95 7394fea
Fix list operations and add comprehensive list support - Fix parser t…
TRK95 7ce0ea1
Fix code formatting with Prettier - Ensure all files conform to proje…
TRK95 f205f30
Bump jest from 30.0.4 to 30.0.5 (#161)
dependabot[bot] 3cd7cbc
Bump ts-jest from 29.4.0 to 29.4.1 (#167)
dependabot[bot] a4485eb
Add stepper functionality with lambda and user-defined function support
TRK95 9870318
chore(SRI-NA): pin jest/ts-jest/typescript; relax service handler typ…
TRK95 6984801
feat: Complete CSE machine and Conductor integration
TRK95 5604c76
rm remnant code
TRK95 95d7467
chore: add dist/index.js to repository for CDN and browser use
TRK95 9e58002
Add GitHub Pages deployment workflow
TRK95 e2ef903
Add GitHub Pages landing page
TRK95 c0f3c5b
Fix: Add HelloServiceMessage protocol handshake in RunnerPlugin const…
TRK95 75bf14f
Fix scm-slang integration: UMD format, conductor initialization, and …
TRK95 25fbb7a
Remove package-lock.json to fix CI/CD - project uses Yarn
TRK95 4b8fb47
Fix GitHub Actions: Use yarn instead of npm for deploy-pages workflow
TRK95 9215ecd
Temporarily disable deploy-pages workflow - need to setup GitHub Page…
TRK95 4e2a319
Remove deploy-pages workflow to follow py-slang pattern - only keep N…
TRK95 7ba244c
Add dist/ to .gitignore and remove dist folder - follow py-slang pattern
TRK95 a9e7991
Fix environment restoration and implement compound functions - Add RE…
TRK95 79db289
Fix list operations and add comprehensive list support - Fix parser t…
TRK95 cea33f7
Fix code formatting with Prettier - Ensure all files conform to proje…
TRK95 d0b70d7
Add stepper functionality with lambda and user-defined function support
TRK95 8d37b19
chore(SRI-NA): pin jest/ts-jest/typescript; relax service handler typ…
TRK95 3ad4131
chore(SRI-NA): prepare rebase by committing lockfile+pkg resolution
TRK95 25be399
chore(SRI-NA): include yarn install state
TRK95 1aa5abb
chore(SRI-NA): resolve package.json/yarn.lock conflicts; pin jest 29.…
TRK95 b17e15f
chore: format code with prettier
TRK95 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
Binary file not shown.
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 @@ | ||
| nodeLinker: node-modules |
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,33 @@ | ||
| import resolve from "@rollup/plugin-node-resolve"; | ||
| import commonjs from "@rollup/plugin-commonjs"; | ||
| import typescript from "@rollup/plugin-typescript"; | ||
|
|
||
| /** | ||
| * @type {import('rollup').RollupOptions} | ||
| */ | ||
| const config = { | ||
| input: "src/index.ts", | ||
| output: { | ||
| file: "dist/index.js", | ||
| format: "umd", | ||
| name: "ScmSlangRunner", | ||
| sourcemap: false, | ||
| globals: {}, | ||
| }, | ||
| plugins: [ | ||
| resolve({ | ||
| preferBuiltins: false, | ||
| browser: true, | ||
| }), | ||
| commonjs({ | ||
| include: "node_modules/**", | ||
| transformMixedEsModules: true, | ||
| requireReturnsDefault: "auto", | ||
| }), | ||
| typescript({ | ||
| tsconfig: "./tsconfig.json", | ||
| }), | ||
| ], | ||
| }; | ||
|
|
||
| export default config; |
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,39 @@ | ||
| import { ControlItem } from "./control"; | ||
| import { | ||
| Expression, | ||
| Atomic, | ||
| Extended, | ||
| } from "../transpiler/types/nodes/scheme-node-types"; | ||
|
|
||
| export function astToControl(expr: Expression): ControlItem[] { | ||
| if ( | ||
| expr instanceof Atomic.NumericLiteral || | ||
| expr instanceof Atomic.BooleanLiteral || | ||
| expr instanceof Atomic.StringLiteral || | ||
| expr instanceof Atomic.Symbol || | ||
| expr instanceof Atomic.Identifier || | ||
| expr instanceof Atomic.Lambda || | ||
| expr instanceof Atomic.Application || | ||
| expr instanceof Atomic.Definition || | ||
| expr instanceof Atomic.Reassignment || | ||
| expr instanceof Atomic.Conditional || | ||
| expr instanceof Atomic.Sequence || | ||
| expr instanceof Atomic.Pair || | ||
| expr instanceof Atomic.Nil || | ||
| expr instanceof Atomic.Import || | ||
| expr instanceof Atomic.Export || | ||
| expr instanceof Atomic.Vector || | ||
| expr instanceof Atomic.DefineSyntax || | ||
| expr instanceof Atomic.SyntaxRules || | ||
| expr instanceof Extended.FunctionDefinition || | ||
| expr instanceof Extended.Let || | ||
| expr instanceof Extended.Cond || | ||
| expr instanceof Extended.List || | ||
| expr instanceof Extended.Begin || | ||
| expr instanceof Extended.Delay | ||
| ) { | ||
| return [expr]; | ||
| } | ||
| console.log("DEBUG expr:", expr); | ||
| throw new Error(`Unhandled expr type: ${expr.constructor.name}`); | ||
| } |
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,26 @@ | ||
| // closure.ts | ||
| import { Expression } from "../transpiler/types/nodes/scheme-node-types"; | ||
| import { Environment } from "./environment"; | ||
|
|
||
| export class Closure { | ||
| readonly type = "Closure"; | ||
| readonly params: string[]; | ||
| readonly body: Expression[]; | ||
| readonly env: Environment; | ||
| readonly declaredName?: string; | ||
| readonly srcNode?: Expression; // AST node for debugging | ||
|
|
||
| constructor( | ||
| params: string[], | ||
| body: Expression[], | ||
| env: Environment, | ||
| declaredName?: string, | ||
| srcNode?: Expression | ||
| ) { | ||
| this.params = params; | ||
| this.body = body; | ||
| this.env = env; | ||
| this.declaredName = declaredName; | ||
| this.srcNode = srcNode; | ||
| } | ||
| } |
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,151 @@ | ||
| // Complex number implementation for Scheme | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'm curious as to why complex number logic is separated into its own file. will this affect the scheme numeric tower? |
||
| // Based on py-slang PyComplexNumber | ||
|
|
||
| export class SchemeComplexNumber { | ||
| public real: number; | ||
| public imag: number; | ||
|
|
||
| constructor(real: number, imag: number) { | ||
| this.real = real; | ||
| this.imag = imag; | ||
| } | ||
|
|
||
| public static fromNumber(value: number): SchemeComplexNumber { | ||
| return new SchemeComplexNumber(value, 0); | ||
| } | ||
|
|
||
| public static fromString(str: string): SchemeComplexNumber { | ||
| // Handle Scheme complex number syntax: 3+4i, 1-2i, 5i | ||
| if (!/[iI]/.test(str)) { | ||
| const realVal = Number(str); | ||
| if (isNaN(realVal)) { | ||
| throw new Error(`Invalid complex string: ${str}`); | ||
| } | ||
| return new SchemeComplexNumber(realVal, 0); | ||
| } | ||
|
|
||
| const lower = str.toLowerCase(); | ||
| if (lower.endsWith("i")) { | ||
| const numericPart = str.substring(0, str.length - 1); | ||
|
|
||
| // Handle purely imaginary: i, +i, -i | ||
| if (numericPart === "" || numericPart === "+") { | ||
| return new SchemeComplexNumber(0, 1); | ||
| } else if (numericPart === "-") { | ||
| return new SchemeComplexNumber(0, -1); | ||
| } | ||
|
|
||
| // Check if it's purely imaginary: 5i | ||
| const imagVal = Number(numericPart); | ||
| if (!isNaN(imagVal)) { | ||
| return new SchemeComplexNumber(0, imagVal); | ||
| } | ||
|
|
||
| // Handle complex with both real and imaginary parts: 3+4i, 1-2i | ||
| const match = numericPart.match( | ||
| /^([\+\-]?\d+(?:\.\d+)?(?:[eE][+\-]?\d+)?)([\+\-]\d+(?:\.\d+)?(?:[eE][+\-]?\d+)?)$/ | ||
| ); | ||
| if (match) { | ||
| const realPart = Number(match[1]); | ||
| const imagPart = Number(match[2]); | ||
| return new SchemeComplexNumber(realPart, imagPart); | ||
| } | ||
| } | ||
|
|
||
| throw new Error(`Invalid complex string: ${str}`); | ||
| } | ||
|
|
||
| public static fromValue( | ||
| value: number | string | SchemeComplexNumber | ||
| ): SchemeComplexNumber { | ||
| if (value instanceof SchemeComplexNumber) { | ||
| return value; | ||
| } else if (typeof value === "number") { | ||
| return SchemeComplexNumber.fromNumber(value); | ||
| } else if (typeof value === "string") { | ||
| return SchemeComplexNumber.fromString(value); | ||
| } else { | ||
| throw new Error(`Cannot convert ${typeof value} to complex number`); | ||
| } | ||
| } | ||
|
|
||
| // Arithmetic operations | ||
| public add(other: SchemeComplexNumber): SchemeComplexNumber { | ||
| return new SchemeComplexNumber( | ||
| this.real + other.real, | ||
| this.imag + other.imag | ||
| ); | ||
| } | ||
|
|
||
| public sub(other: SchemeComplexNumber): SchemeComplexNumber { | ||
| return new SchemeComplexNumber( | ||
| this.real - other.real, | ||
| this.imag - other.imag | ||
| ); | ||
| } | ||
|
|
||
| public mul(other: SchemeComplexNumber): SchemeComplexNumber { | ||
| // (a + bi) * (c + di) = (ac - bd) + (ad + bc)i | ||
| const real = this.real * other.real - this.imag * other.imag; | ||
| const imag = this.real * other.imag + this.imag * other.real; | ||
| return new SchemeComplexNumber(real, imag); | ||
| } | ||
|
|
||
| public div(other: SchemeComplexNumber): SchemeComplexNumber { | ||
| // (a + bi) / (c + di) = ((ac + bd) + (bc - ad)i) / (c² + d²) | ||
| const denominator = other.real * other.real + other.imag * other.imag; | ||
| if (denominator === 0) { | ||
| throw new Error("Division by zero"); | ||
| } | ||
| const real = | ||
| (this.real * other.real + this.imag * other.imag) / denominator; | ||
| const imag = | ||
| (this.imag * other.real - this.real * other.imag) / denominator; | ||
| return new SchemeComplexNumber(real, imag); | ||
| } | ||
|
|
||
| public negate(): SchemeComplexNumber { | ||
| return new SchemeComplexNumber(-this.real, -this.imag); | ||
| } | ||
|
|
||
| // Comparison (only for equality) | ||
| public equals(other: SchemeComplexNumber): boolean { | ||
| return this.real === other.real && this.imag === other.imag; | ||
| } | ||
|
|
||
| // Magnitude | ||
| public abs(): number { | ||
| return Math.sqrt(this.real * this.real + this.imag * this.imag); | ||
| } | ||
|
|
||
| // String representation | ||
| public toString(): string { | ||
| if (this.imag === 0) { | ||
| return this.real.toString(); | ||
| } else if (this.real === 0) { | ||
| if (this.imag === 1) return "i"; | ||
| if (this.imag === -1) return "-i"; | ||
| return `${this.imag}i`; | ||
| } else { | ||
| const imagPart = | ||
| this.imag === 1 | ||
| ? "i" | ||
| : this.imag === -1 | ||
| ? "-i" | ||
| : this.imag > 0 | ||
| ? `+${this.imag}i` | ||
| : `${this.imag}i`; | ||
| return `${this.real}${imagPart}`; | ||
| } | ||
| } | ||
|
|
||
| // Convert to JavaScript number (only if purely real) | ||
| public toNumber(): number { | ||
| if (this.imag !== 0) { | ||
| throw new Error( | ||
| "Cannot convert complex number with imaginary part to real number" | ||
| ); | ||
| } | ||
| return this.real; | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
a downgrade?
nit - please merge the latest set of packages, unless this is necessary