| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A C#/.NET implementation of the Forthic stack-based concatenative programming language.
Forthic is a stack-based, concatenative language designed for composable transformations. This is the official .NET runtime implementation, providing full compatibility with other Forthic runtimes while leveraging .NET's rich ecosystem and LINQ.
dotnet add package Forthicusing Forthic;
var interp = new StandardInterpreter();
await interp.RunAsync("[1 2 3] \"2 *\" MAP");
var result = interp.StackPop();
// result is [2, 4, 6]# REPL mode
dotnet forthic repl
# Execute a script
dotnet forthic run script.forthic
# Eval mode (one-liner)
dotnet forthic eval "[1 2 3] LENGTH"# Restore packages
dotnet restore
# Build
dotnet build
# Run tests
dotnet test
# Run specific test
dotnet test --filter "FullyQualifiedName~InterpreterTests"
# Build for release
dotnet build -c Releaseforthic-dotnet/
├── src/
│ ├── Forthic/ # Core library
│ │ ├── Interpreter.cs
│ │ ├── Tokenizer.cs
│ │ ├── Module.cs
│ │ ├── Decorators/ # Attribute system
│ │ └── Modules/Standard/ # Standard library (8 modules)
│ ├── Forthic.Grpc/ # gRPC support
│ └── Forthic.Cli/ # CLI tool
└── tests/
└── Forthic.Tests/ # xUnit tests
Define Forthic words using C# attributes:
public class ArrayModule : DecoratedModule
{
[ForthicWord("( array word -- result )", "Maps a word over an array")]
public async Task<object> MAP(List<object> array, IWord word)
{
var results = new List<object>();
foreach (var item in array)
{
var result = await word.ExecuteAsync(interp);
results.Add(result);
}
return results;
}
}Leverage LINQ for functional operations:
[ForthicWord("( array predicate -- result )", "Filters array")]
public async Task<object> SELECT(List<object> array, IWord predicate)
{
return array.Where(item => {
/* evaluate predicate */
return true;
}).ToList();
}This runtime supports calling words from other Forthic runtimes via gRPC:
// Call a Python word from .NET
var result = await interp.ExecuteRemoteWordAsync(
"python-runtime", "MY-WORD", args
);Robust date/time handling with NodaTime:
var zonedDateTime = ZonedDateTime.FromDateTimeOffset(
DateTimeOffset.Now, DateTimeZone.Utc
);BSD 2-CLAUSE
| Back | FazBrowse Home | New Git URL |