summaryrefslogtreecommitdiff
path: root/src/colm.lm
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2016-10-01 09:34:21 -0700
committerAdrian Thurston <thurston@colm.net>2016-10-01 09:34:21 -0700
commit84f764672525cd475114b76b104fc1bc0e6ce5b2 (patch)
treeff409ee3f52e08447b90af014f3ff5b8284c389c /src/colm.lm
parentfb9e7b3b77657a7e2db63d7cd2d9cd4706715d21 (diff)
downloadcolm-84f764672525cd475114b76b104fc1bc0e6ce5b2.tar.gz
auto-trim in print, send and construct, disable with @
Now automatically trimming when building trees and printing. This is consistent with the $ operator. Rationale is to standardize on the most commonly desired behaviour and provide options for the less-needed. Also much less likely to result in surprising output. There are many cases where test inputs won't have any surrounding ignores, making it easy to forget a trim is required. Then the occasional tree with surrounding ignores will give an undesired result. Better to standardize on trim, making the default behaviour more consistent. The trim can be turned off with the @ operator in front of an expression.
Diffstat (limited to 'src/colm.lm')
-rw-r--r--src/colm.lm11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/colm.lm b/src/colm.lm
index b87bad4f..cc0a6260 100644
--- a/src/colm.lm
+++ b/src/colm.lm
@@ -114,6 +114,7 @@ lex
token BANG /'!'/
token DOLLAR /'$'/
token CARET /'^'/
+ token AT /'@'/
token PERCENT /'%'/
token PLUS /'+'/
token MINUS /'-'/
@@ -722,6 +723,10 @@ def pattern
# Constructor List
#
+def opt_no_trim
+ [AT] :At
+| [] :Trim
+
def E1 []
def E2 []
def E3 []
@@ -732,7 +737,7 @@ def cons_el
| [E1 DQ LitConsElList: lit_cons_el* dq_lit_term] :Dq
| [E1 SQ SqConsDataList: sq_cons_data* sq_lit_term] :Sq
| [E1 TILDE opt_tilde_data TILDE_NL] :Tilde
-| [E2 code_expr] :CodeExpr
+| [E2 opt_no_trim code_expr] :CodeExpr
def lit_cons_el
[dq_cons_data] :ConsData
@@ -759,7 +764,7 @@ def accum_el
[E1 DQ LitAccumElList: lit_accum_el* dq_lit_term] :Dq
| [E1 SQ SqConsDataList: sq_cons_data* sq_lit_term] :Sq
| [E1 TILDE opt_tilde_data TILDE_NL] :Tilde
-| [E2 code_expr] :CodeExpr
+| [E2 opt_no_trim code_expr] :CodeExpr
def lit_accum_el
[dq_cons_data] :ConsData
@@ -786,7 +791,7 @@ def string_el
[E1 DQ LitStringElList: lit_string_el* dq_lit_term] :Dq
| [E1 SQ SqConsDataList: sq_cons_data* sq_lit_term] :Sq
| [E1 TILDE opt_tilde_data TILDE_NL] :Tilde
-| [E2 code_expr] :CodeExpr
+| [E2 opt_no_trim code_expr] :CodeExpr
def lit_string_el
[dq_cons_data] :ConsData