Skip to content

Instantly share code, notes, and snippets.

View disarticulate's full-sized avatar

Eric Xanderson disarticulate

View GitHub Profile
@disarticulate
disarticulate / indentation.pegjs
Created April 23, 2017 21:28 — forked from biogeo/indentation.pegjs
"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+