A beginner-friendly, event-driven F# parsing library for language design and implementation.
dotnet add package SharpParser.Coreopen SharpParser.Core
// Create your first parser
let parser =
Parser.create()
|> Parser.onSequence "hello" (fun ctx ->
printfn "Hello found!"
ctx)
Parser.runString "hello world" parser- 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
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 contextMIT License - see LICENSE file for details.