UNPKG

@nasp/icons

Version:

Universal design and icon system for NASP Asset Studio, with NaspScript language support.

40 lines (30 loc) 1.11 kB
# NaspScript API The NaspScript DSL parser and utilities. ## Methods ### parse(script, { renderIcon }) Returns HTML for a NaspScript script. ### parseWithDiagnostics(script, { renderIcon }) Returns `{ html, diagnostics }`. - `diagnostics`: Array of `{ code, message, severity, line, col }` - Error codes: - `E001`: Unmatched closing brace - `E002`: Error in custom command - `E003`: Unclosed block(s) at end of script - Warning codes: - `W001`: Unknown icon - `W002`: Unknown or invalid syntax ### suggest(partial, { icons, commands, variables }) Returns array of suggestions for autocomplete. ### highlight(script) Returns HTML with syntax coloring for keywords, numbers, colors, strings, comments. --- ## Usage Examples ```js const { html, diagnostics } = NaspScript.parseWithDiagnostics(script, { renderIcon }); diagnostics.forEach(d => { if (d.severity === 'error') console.error(d); else console.warn(d); }); const suggestions = NaspScript.suggest('sea', { icons: NASPIcon.listIcons() }); const highlighted = NaspScript.highlight(script); ```