Skip to content

Latest commit

 

History

History
66 lines (47 loc) · 1.84 KB

File metadata and controls

66 lines (47 loc) · 1.84 KB

SharpParser.Core

NuGet License: MIT

A beginner-friendly, event-driven F# parsing library for language design and implementation.

Installation

dotnet add package SharpParser.Core

Quick Start

open SharpParser.Core

// Create your first parser
let parser =
    Parser.create()
    |> Parser.onSequence "hello" (fun ctx ->
        printfn "Hello found!"
        ctx)

Parser.runString "hello world" parser

Features

  • Event-driven parsing with intuitive handler functions
  • Context-sensitive modes for nested parsing contexts
  • Automatic tokenization and AST construction
  • Performance optimized with trie-based matching
  • Comprehensive error handling and debugging support

Documentation

📖 Full Documentation

🔧 API Reference

🚀 Quick Start Guide

Example

let parser =
    Parser.create()
    |> Parser.enableTokens()
    |> Parser.enableAST()
    |> Parser.onSequence "function" (fun ctx ->
        ParserContext.enterMode "functionBody" ctx)
    |> Parser.inMode "functionBody" (fun config ->
        config
        |> Parser.onChar '{' (fun ctx -> ctx)
        |> Parser.onChar '}' (fun ctx -> ParserContext.exitMode ctx))

let context = Parser.runString "function test() { return 42 }" parser
let tokens = Parser.getTokens context
let ast = Parser.getAST context

License

MIT License - see LICENSE file for details.