Commit graph

52 commits

Author SHA1 Message Date
9a086e35f0 Updated version for nuget packing 2025-08-29 21:24:24 -05:00
codex
6ed3ded0ed Interpreter: fix implicit multiplication LL(1) conflict and recursion handling
- Rewrite Term loop in Interpreter.atg to avoid deletable alternative causing '+'/'-' to be treated as '%'.
- Support implicit multiplication by explicit adjacency checks without affecting additive parsing.
- Add cycle-safe expression evaluation: track evaluation stack and collapse self/mutual recursion to zero via shared recursion scope.
- Update StandardLibrary project reference casing to 'CSMic.Core.csproj'.

All tests pass: 85/85.
2025-08-29 20:01:51 -05:00
codex
135af2cc49 Interpreter: support implicit multiplication (adjacency) and allow whitespace; update Coco/R frames path casing; add tests for implicit multiplication and function calls; fix project reference casing in tests. 2025-08-29 17:43:07 -05:00
04a175223d Updating to latest version of CS-MIC with recursion protection 2025-08-27 02:36:13 -05:00
b6dee57aa1 Merge branch 'v2' of https://git.jordanwages.com/wagesj45/cs-mic into v2 2025-08-26 23:24:12 -05:00
62ea3efe16 Added Variable array 2025-08-26 23:24:08 -05:00
codex
ad78611f9c fix: prevent infinite recursion in expression evaluation
Add evaluation stack and recursion detection in InputInterpreter to short-circuit self/cyclic expression references. Return zero when recursion is detected during evaluation and unwind stack state after parse. Add unit tests covering self-recursion and mutual recursion cases.
2025-08-26 17:16:13 -05:00
ead706e38b Update InputInterpreter.cs 2025-08-26 02:28:22 -05:00
codex
5f7b862d5e Fix .NET Standard compatibility:
- Replace double.DegreesToRadians/RadiansToDegrees with Math-based conversions
- Replace Random.Shared with thread-local Random for thread safety
2025-08-26 00:39:43 -05:00
8dd20b2cb8 Downgrading to 2.1, fixing language versions 2025-08-26 00:36:29 -05:00
7521fb0f2a Fixed goof lol 2025-08-26 00:17:04 -05:00
codex
d725e9e357 chore: migrate libraries to netstandard2.1; set tests to net8.0
- Core/StandardLibrary: TargetFramework -> netstandard2.1
- Tests: TargetFramework -> net8.0 (runnable for test host)
- Fix project reference casing for Linux/CI
2025-08-25 23:42:00 -05:00
f1cf26ad98 Fixed spelling error. 2025-08-21 04:11:03 -05:00
106efbc86e tests(stdlib): reorganize and expand StandardLibrary tests
- Switch tests to use Initializer.InitializeAll for setup
- Split stdlib tests by category: Angle, Rounding, Trig (incl. hyperbolic), NumberTheory, Random
- Add comprehensive tests invoking functions via InputInterpreter.Interpret()
- Register Bernoulli in Initializer so random tests cover
2025-08-21 04:04:46 -05:00
1d86b2bc19 Readding Tests
Missed from nomenclature standardization.
2025-08-21 03:53:39 -05:00
736f05a023 Fix stdlib typos and logic bugs: Round precision arg; rename Trancate->Truncate; correct degrees/radians conversion; wrapangle shift into range; Random rands add lower; correct gcd/lcm names/logic; fix 13! constant; clarify atan2 args; update initializer registrations 2025-08-21 03:52:26 -05:00
47e6ea91d7 StandardLibrary: implement and wire Initialize[Type]Functions in Initializer (Angle, Rounding, Trigonometry incl. Hyperbolic, NumberTheory, Random) and call them from InitializeAllFunctions 2025-08-21 03:48:48 -05:00
4a21ff3d46 Adding functions to Standard Library 2025-08-21 03:44:04 -05:00
808d4ca420 Surface ICodedFunction exceptions: set interpreter message via ProduceOutput in ExecuteFunction 2025-08-21 03:24:13 -05:00
9b74c03a9d Cleaning up naming 2025-08-20 20:32:13 -05:00
0a67e6e2cc Adopt .NET naming and structure: CsMic.* namespaces, PascalCase projects and solution; update Coco namespace; update package id and NuGet publish target; adjust project refs and tests. 2025-08-20 20:10:34 -05:00
e84cce9fef tests(stdlib): avoid decimal attribute arguments; use string TestCase values and parse to decimal for high-precision cases 2025-08-20 06:06:42 -05:00
a19a092b93 Fixed test case declaration 2025-08-20 06:04:04 -05:00
7c54bcd1e6 fix(stdlib): correct max() to use Math.Max 2025-08-20 05:53:55 -05:00
ced7fbd7c3 tests(stdlib): add tests for abs, sign, min, max, constants 2025-08-20 05:53:37 -05:00
afb7a65a66 Function registry fix. 2025-08-20 05:45:22 -05:00
e51068a27e Adding Min and Max 2025-08-20 05:28:05 -05:00
82ceb7e5cd Refactored ValueType to FunctionValueType
It was causing issues.
2025-08-20 05:21:57 -05:00
1e9d9233f8 Added tests for stdlib 2025-08-20 05:05:34 -05:00
fcbdaa1f9d Added two base functions 2025-08-20 04:55:04 -05:00
e458cdd910 periodic checkpoint 2025-08-20 03:48:58 -05:00
b1e9e58783 Untracking autogenerated 2025-08-20 02:43:06 -05:00
e1eb12476b fixing declarations 2025-08-20 01:45:11 -05:00
fb2c62399c function value issue 2025-08-20 01:07:45 -05:00
64a12a353c Implement AbsoluteValue function in stdlib 2025-08-19 23:50:19 -05:00
49902cda2a Initial function project commit 2025-08-19 23:45:55 -05:00
0e230f7a49 Ignoring autogenerated .old files 2025-08-19 18:48:57 -05:00
362af6f7bf Fixed number to decimal parsing, additional tests 2025-08-19 05:15:13 -05:00
648bd3bad0 tests: Add NUnit suite for InputInterpreter.Interpret covering arithmetic, comparisons, variables, := binding, arrays, soft errors, and timing
Adds InputInterpreterTests with:

- Arithmetic cases including precedence, hex/binary, exponent.
- Comparisons yielding numeric booleans.
- Variable assignment (::) and persistence across calls; unknown variable soft error.
- Expression binding (:=) re-evaluated at use-time; invalid expression soft error.
- Array assignment (->) and indexing; out-of-range and index-expression scenarios.
- String literal used as expression soft error.
- Divide-by-zero soft error (no thrown exception).
- LastExecutionTime measured across calls.

Each test asserts both the return value and NumericValue/StringValue for consistency.
2025-08-19 04:52:37 -05:00
2cfd01f06f Naming Convention fix 2025-08-19 04:50:05 -05:00
f0670b081c Added reference to core project 2025-08-19 04:47:43 -05:00
3efc97e9d0 Stub test project 2025-08-19 04:42:37 -05:00
53a904e0b0 v2: Add public Interpret(string) with soft-error semantics and elapsed time
Implements developer-facing Interpret API that:

- Parses and executes input via generated Scanner/Parser and current interpreter state.
- Returns the numeric result (decimal) and updates NumericValue/StringValue.
- Emits soft errors: never throws; on error sets NumericValue=0 and StringValue to parser error format or exception message.
- Restores LastExecutionTime measurement for the previous interpretation.

This preserves the original nomenclature while aligning to v2’s FunctionValue model.
2025-08-19 04:31:53 -05:00
b2213663d1 Fixed minor gramar issue. 2025-08-19 04:00:31 -05:00
c5f35b9d34 v2: Wire InputInterpreter runtime APIs for v2 grammar
Add in-memory stores and APIs required by the v2 Coco/R grammar:

- Variables: AssignNumeric, AssignExpression, AssignNumericArray; TryGetNumeric, TryGetExpression, TryGetNumericArray.
- Mixed-arg function dispatch: ExecuteFunction(name, FunctionArgument[]), plus RegisterFunction.
- Expression evaluation for :=: EvaluateExpression(expressionText) via generated Scanner/Parser with a child interpreter sharing stores.
- Output handling preserved: ProduceOutput(FunctionValue) updates NumericValue/StringValue.

These changes allow the generated parser to compile and run against the v2 runtime, enforcing the numeric-first, strings-as-arguments-only model.
2025-08-19 03:51:05 -05:00
f532d13d8c v2: Implement Interpreter.atg with typed FunctionValue, mixed-arg functions, and expression-binding (:=); fix Coco/R csproj command
This completes the v2 grammar based on master’s capabilities while aligning with the v2 design philosophy (numeric-first, strings as function-args only):

- Implement full arithmetic grammar ( +, -, *, /, %, ^, parentheses, unary sign ), with support for number/hex/binary literals.
- Add variables and arrays:
  - Numeric variables via :: (evaluate RHS now and store numeric)
  - Expression-bound variables via := (capture RHS text; re-parse and evaluate at use-time)
  - Numeric arrays via -> and array literals + indexing (with bounds/type checks)
- Add comparisons (==, <, >, <=, >=) producing FunctionValue TRUE/FALSE.
- Add function calls with mixed arguments: numeric expressions and quoted string literals.
  - In numeric contexts, enforce numeric results; emit clear type errors if a function returns a string.
- Root production always produces a FunctionValue through InputInterpreter.ProduceOutput(FunctionValue).

Runtime integration (expected APIs on InputInterpreter):
- Variable APIs: AssignNumeric, AssignExpression, AssignNumericArray; TryGetNumeric, TryGetExpression, TryGetNumericArray
- Function dispatch: ExecuteFunction(name, FunctionArgument[])
- Expression evaluation for :=: EvaluateExpression(expressionText)

Coco/R build fix:
- Correct the PreBuild command in src/core/core.csproj:
  - Use -frames (without the stray space) and point to cocor
  - Use the correct case and path for the grammar: cocor/Interpreter.atg

Notes:
- Strings are valid only as function arguments and not as standalone values or variables.
- Grammar emits concise, actionable error messages for type mismatches, missing variables, and array bounds.
2025-08-19 03:45:57 -05:00
66ec23a420 Update README.md 2025-08-19 03:09:41 -05:00
841a10cb97 Update README.md 2025-08-19 03:06:57 -05:00
87bec68e1f docs: add Design Philosophy and Args-Only Strings guidance for v2 2025-08-19 03:06:13 -05:00
eb3bbcb69e Check in 2025-06-12 04:32:18 -05:00