From 0442c8dd216f16c7371873a8e8fd8bf83d30dad0 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 17 Jul 2018 14:12:11 -0700 Subject: Overhaul of comment handling, plus a few fixes (e.g. a fix for indented text that begins with a nomsu comment) --- nomsu.1.peg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'nomsu.1.peg') diff --git a/nomsu.1.peg b/nomsu.1.peg index 1551b6d..39c0a9a 100644 --- a/nomsu.1.peg +++ b/nomsu.1.peg @@ -1,6 +1,7 @@ -- Nomsu version 2 file (FileChunks): {:curr_indent: ' '* :} + ("#!" (!"nomsu" [^%nl])* "nomsu" %ws+ "-V" %ws* {:version: ([0-9.]+ -> tonumber) :} [^%nl]*)? comment? blank_lines? (chunk (nl_nodent chunk_delimeter nl_nodent chunk)*)? blank_lines? @@ -100,12 +101,12 @@ inline_text_interpolation: ) indented_text (Text): - '".."' eol %nl {:curr_indent: indent :} - (indented_plain_text / text_interpolation / {~ blank_lines (=curr_indent -> "") ~})* + '".."' eol %nl {%nl*} {:curr_indent: indent :} + (indented_plain_text / text_interpolation / {~ %nl+ (=curr_indent -> "") ~})* (!! [^%nl]+ -> "Unexpected character while parsing Text" !!)? indented_plain_text (Text): {~ (("\\" -> "\") / (("\" blank_lines =curr_indent "..") -> "") / (!text_interpolation "\") / [^%nl\]+)+ - (blank_lines (=curr_indent -> ""))* ~} + (%nl+ (=curr_indent -> ""))* ~} text_interpolation: inline_text_interpolation / ("\" indented_expression blank_lines =curr_indent "..") -- cgit v1.2.3