From d3497b9f6b145702c509ce86023a524e131ba48d Mon Sep 17 00:00:00 2001
From: Doug Coleman <doug.coleman@gmail.com>
Date: Mon, 4 Sep 2017 11:04:55 -0500
Subject: [PATCH] modern: working on compound tokens

---
 extra/modern/modern-tests.factor | 25 +++++++++++++++++++++++++
 extra/modern/modern.factor       |  9 +++++++--
 extra/modern/out/out.factor      | 12 ++++++++----
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/extra/modern/modern-tests.factor b/extra/modern/modern-tests.factor
index 4e598eb783..abca72deb4 100644
--- a/extra/modern/modern-tests.factor
+++ b/extra/modern/modern-tests.factor
@@ -139,3 +139,28 @@ IN: modern.tests
 {
     { { "\"" "google.com" "\"" } }
 } [ [[ "google.com" ]] string>literals >strings ] unit-test
+
+! Concatenated syntax
+{
+    {
+        { "(" { "a" "b" } ")" }
+        { "[" { "a" "b" "+" } "]" }
+        { "(" { "c" } ")" }
+    }
+} [ "( a b )[ a b + ]( c )" string>literals >strings ] unit-test
+
+{
+    {
+        { "(" { "a" "b" } ")" }
+        { "[" { "a" "b" "+" } "]" }
+        { "(" { "c" } ")" }
+    }
+} [ "( a b ) [ a b + ] ( c )" string>literals >strings ] unit-test
+
+
+{
+    {
+        { "\"" "abc" "\"" }
+        { "[" { "0" } "]" }
+    }
+} [ "\"abc\"[ 0 ]" string>literals >strings ] unit-test
diff --git a/extra/modern/modern.factor b/extra/modern/modern.factor
index e8252f2a14..dc6ce08162 100644
--- a/extra/modern/modern.factor
+++ b/extra/modern/modern.factor
@@ -267,6 +267,9 @@ ERROR: mismatched-terminator n string slice ;
         { char: \[ [ read-bracket ] }
         { char: \{ [ read-brace ] }
         { char: \( [ read-paren ] }
+        { char: \] [  ] }
+        { char: \} [  ] }
+        { char: \) [  ] }
         { char: \s [ read-token-or-whitespace ] }
         { char: \r [ read-token-or-whitespace ] }
         { char: \n [ read-token-or-whitespace ] }
@@ -275,9 +278,11 @@ ERROR: mismatched-terminator n string slice ;
 
 : lex-factor ( n/f string -- n'/f string literal )
     over [
-        skip-whitespace "\"\\!:[{(<>\s\r\n" slice-til-either
+        ! skip-whitespace
+        "\"\\!:[{(]})<>\s\r\n" slice-til-either
+
         ! \foo foo\bar \foo{
-        dup char: \\ = [
+        dup char: \\ =  [
             drop
             ! foo\ so far, could be foo\bar{
             ! remove the \ and continue til delimiter/eof
diff --git a/extra/modern/out/out.factor b/extra/modern/out/out.factor
index 64d9f129d6..7f19eb669a 100644
--- a/extra/modern/out/out.factor
+++ b/extra/modern/out/out.factor
@@ -1,11 +1,15 @@
 ! Copyright (C) 2017 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs constructors continuations fry io
-io.encodings.utf8 io.files io.streams.string kernel modern
-modern.paths modern.slices multiline namespaces prettyprint
-sequences sequences.extras splitting strings ;
+USING: accessors arrays assocs combinators.short-circuit
+constructors continuations fry io io.encodings.utf8 io.files
+io.streams.string kernel modern modern.paths modern.slices
+multiline namespaces prettyprint sequences sequences.extras
+splitting strings ;
 IN: modern.out
 
+: token? ( obj -- ? )
+    { [ slice? ] [ seq>> string? ] } 1&& ;
+
 TUPLE: renamed slice string ;
 CONSTRUCTOR: <renamed> renamed ( slice string -- obj ) ;