From f97ab858edae5495f8ebfef46656e86150665888 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 8 Jan 2018 18:53:57 -0800 Subject: Modernized the codebase a bit to include "immediately:" for immediately running code before further parsing takes place. That means that in the default case, whole files can be run at once, which makes all but the weirdest edge cases make a lot more sense and operate smoothly. --- nomsu.peg | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'nomsu.peg') diff --git a/nomsu.peg b/nomsu.peg index 2946891..0bd51df 100644 --- a/nomsu.peg +++ b/nomsu.peg @@ -11,12 +11,12 @@ statement: functioncall / expression noeol_statement: noeol_functioncall / noeol_expression inline_statement: inline_functioncall / inline_expression -inline_thunk (Thunk): {| ":" %ws* inline_statement |} -eol_thunk (Thunk): {| ":" %ws* noeol_statement eol |} -indented_thunk (Thunk): +inline_block (Block): {| ":" %ws* inline_statement |} +eol_block (Block): {| ":" %ws* noeol_statement eol |} +indented_block (Block): {| ":" indent statement (nodent statement)* - (dedent / (("" -> "Error while parsing thunk") => error)) + (dedent / (("" -> "Error while parsing block") => error)) |} inline_nomsu (Nomsu): "\" inline_expression @@ -25,18 +25,18 @@ indented_nomsu (Nomsu): "\" expression inline_expression: number / variable / inline_string / inline_list / inline_dict / inline_nomsu - / ("(" %ws* (inline_thunk / inline_statement) %ws* ")") + / ("(" %ws* (inline_block / inline_statement) %ws* ")") noeol_expression: - indented_string / indented_nomsu / indented_list / indented_dict / indented_thunk + indented_string / indented_nomsu / indented_list / indented_dict / indented_block / ("(..)" indent statement (dedent / (("" -> "Error while parsing indented expression") => error)) ) / inline_expression -expression: eol_thunk / eol_nomsu / noeol_expression +expression: eol_block / eol_nomsu / noeol_expression -- Function calls need at least one word in them inline_functioncall (FunctionCall): - {| (inline_expression %ws*)* word (%ws* (inline_expression / word))* (%ws* inline_thunk)?|} + {| (inline_expression %ws*)* word (%ws* (inline_expression / word))* (%ws* inline_block)?|} noeol_functioncall (FunctionCall): {| (noeol_expression %ws*)* word (%ws* (noeol_expression / word))* |} functioncall (FunctionCall): @@ -57,7 +57,7 @@ indented_string (String): ~} / string_interpolation)* |} ((!.) / (&(%nl+ !%gt_nodented)) / (("" -> "Error while parsing String") => error)) string_interpolation: - "\" (variable / inline_list / inline_dict / inline_string / ("(" %ws* (inline_thunk / inline_statement) %ws* ")")) + "\" (variable / inline_list / inline_dict / inline_string / ("(" %ws* (inline_block / inline_statement) %ws* ")")) number (Number): (("-"? (([0-9]+ "." [0-9]+) / ("." [0-9]+) / ([0-9]+)))-> tonumber) -- cgit v1.2.3