Conversation
Co-authored-by: theQuarky <22050991+theQuarky@users.noreply.github.com>
Co-authored-by: theQuarky <22050991+theQuarky@users.noreply.github.com>
Co-authored-by: theQuarky <22050991+theQuarky@users.noreply.github.com>
|
@copilot can you write simple lib for print utils in tspp using this system call functionility makesure sysntex should be similar to nodejs for mostly all utils |
Co-authored-by: theQuarky <22050991+theQuarky@users.noreply.github.com>
I've created a comprehensive Node.js-style print utilities library in TSPP using the syscall functionality! The library provides familiar console functions with syntax similar to Node.js. Key Features Added: 🎯 Node.js-Compatible Console Functions:
🌈 Styled Output:
⚡ Zero-Overhead Implementation:
Files Created:
Usage Example: console_log("Hello World!");
console_info("Application started");
console_warn("This is a warning");
console_error("Something went wrong");
console_time("operation");
// ... some work ...
console_timeEnd("operation");The implementation demonstrates how TSPP's FFI system enables creating familiar, high-level APIs while maintaining direct system access. All utilities work with the existing syscall infrastructure from commit da70358. |
|
@copilot can you please recheck |
Co-authored-by: theQuarky <22050991+theQuarky@users.noreply.github.com>
Fixed the grammar and Node.js-style syntax issues in both example files! The files now follow proper TSPP grammar and use Node.js-style console functions. Changes Made: 🔧 Grammar Fixes:
🎯 Node.js-Style Console:
Files Updated:
Verified: Changes committed in d538e0c. |
This PR implements a comprehensive Foreign Function Interface (FFI) and syscall support system that enables writing TSPP standard libraries in TSPP itself rather than requiring C++ implementations. This addresses the need for more flexible and maintainable standard library development.
Key Features
External Function Declarations
Added support for declaring and calling external functions using the
externkeyword:Comprehensive Syscall Interface
Implemented a complete syscall wrapper system that provides direct access to operating system functions:
Self-Hosted Standard Libraries
Standard library modules can now be written entirely in TSPP using syscalls:
Node.js-Style Console Utilities
Implemented a comprehensive console library with familiar Node.js-style syntax:
Implementation Details
Language Extensions
EXTERNtoken type and lexer supportbuildExternFunction()method for parsing external declarationsisExternalandexternalNamefields inFunctionDeclCode Generation
Syscall Infrastructure
syscall.h/cppmodule with platform-specific implementationsConsole Library Features
console_time()andconsole_timeEnd()utilitiesExample Files Corrections
examples/hello_world.tsppandexamples/functions.tsppto use proper TSPP grammar (functioninstead offunc,intinstead ofnumber)println()with Node.js-styleconsole_log()functionsBenefits
Examples and Documentation
The PR includes comprehensive examples demonstrating:
Complete documentation is provided in
docs/FFI_SYSCALLS.mdandexamples/stdlib/README.mdcovering syntax, usage patterns, and implementation details.Testing
Added integration tests for external function parsing and syscall functionality. The implementation successfully compiles and generates correct LLVM IR for external function calls. All example files now compile correctly with proper TSPP grammar.
This implementation provides the foundation for a self-hosted standard library ecosystem, enabling developers to write system-level code in TSPP itself with familiar Node.js-style APIs rather than requiring C++ implementations.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.