From 1ca6f7e9caa998b43eb236da2a7618c79c4e76e8 Mon Sep 17 00:00:00 2001 From: s-ol Date: Sat, 5 Apr 2025 20:11:06 +0200 Subject: line comments --- alv/parsing.moon | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'alv') diff --git a/alv/parsing.moon b/alv/parsing.moon index 0ae2586..f8247a4 100644 --- a/alv/parsing.moon +++ b/alv/parsing.moon @@ -7,11 +7,13 @@ import R, S, P, V, C, Ct from require 'lpeg' -- whitespace wc = S ' \t\r\n' -comment = P { - 'comment', - expr: (P '(') * ((V 'expr') + (1 - P ')'))^0 * (P ')') - comment: (P '#(') * ((V 'expr') + (1 - P ')'))^0 * (P ')') +cexpr = (P '(') * ((V 'cexpr') + (1 - P ')'))^0 * (P ')') +ccell = P { + (P '#') * (V 'cexpr') + :cexpr } +cline = (P '##') * (1 - (P '\n'))^0 +comment = cline + ccell mspace = (comment + wc)^0 / 1 -- optional whitespace space = (wc^1 * (comment^0 * wc)^0) / 1 -- required whitespace @@ -32,7 +34,7 @@ num = ((P '-')^-1 * (float + fract + int)) / Constant\parse 'num' tag = (P '[') * (digit^1 / Tag.parse) * (P ']') tpltext = ((P '\\"') + (P '\\\\') + (P '\\$') + (1 - (P '"') - (P '$')))^1 / 1 -tplcont = Ct ((P '$$') / 1 + ('$' * (V 'expr')) + tpltext)^0 +tplcont = Ct (('$' * (V 'expr')) + tpltext)^0 tplstr = (P '$') * tag^-1 * sym * '"' * tplcont * '"' / TemplateString\parse expitem = tplstr + (V 'expr') -- cgit v1.2.3