lezer 0.1.0
lezer: ^0.1.0 copied to clipboard
Dart port of Lezer - an incremental GLR parser system for CodeMirror.
Lezer for Dart #
A pure Dart port of Lezer - the incremental GLR parser system that powers CodeMirror 6.
Features #
- Incremental parsing - Only re-parses changed portions of the document
- Error recovery - Produces meaningful parse trees even for invalid input
- Efficient - Optimized for real-time editing scenarios
- Tree structure - Provides a concrete syntax tree for syntax highlighting and code analysis
Usage #
import 'package:lezer/lezer.dart';
// Parse source code using a language parser
final tree = parser.parse('const x = 42;');
// Traverse the tree
tree.iterate(
enter: (node) {
print('${node.name}: ${source.substring(node.from, node.to)}');
return true;
},
);
Language Support #
This package provides the core parsing infrastructure. Language-specific parsers are provided by the codemirror package which includes:
- JavaScript/TypeScript/JSX/TSX
- JSON
- Markdown
- HTML/CSS
- And more...
Related Packages #
- codemirror - Full code editor with syntax highlighting
- lezer-generator - Generate parsers from grammar files (JavaScript)
License #
MIT License - see LICENSE for details.
Based on Lezer by Marijn Haverbeke.