parser

@motioneffector/parser

A natural language command parser for text adventures and interactive fiction.

npm version license TypeScript

Features

Read the full manual →

Quick Start

import { createParser } from '@motioneffector/parser'

// Create parser with entity resolver
const parser = createParser({
  resolver: (noun, adjectives, scope) => {
    // Look up entities from your game state
    return [{ id: 'lamp-1', name: 'brass lamp' }]
  }
})

// Parse player input
const result = parser.parse('get lamp')

if (result.type === 'command') {
  console.log(`Verb: ${result.command.verb}`) // "GET"
  console.log(`Subject: ${result.command.subject?.id}`) // "lamp-1"
}

Testing & Validation

License

MIT © motioneffector