Skip to content

Instantly share code, notes, and snippets.

View disarticulate's full-sized avatar

Eric Xanderson disarticulate

View GitHub Profile
@biogeo
biogeo / indentation.pegjs
Created March 23, 2017 17:55
"Offside rule" indentation parsing with PEG.js
// Parse a document using "offside rule" indentation (as in Python) into lines
// grouped by indentation level, using PEG.js.
// Attempts to segregate the "stateful" rules from the other production/parsing
// rules by "disallowing" indentation-level-sensitive rules from consuming any
// text.
{ var margin_stack = [""]; }
Document
= content: Element+
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.