From 50ff66e926f981a5b3716f218ad24603c2a12e3f Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 21 Dec 2005 22:19:29 -0500 Subject: [PATCH] checkpoint darcs-hash:20051222031929-5007d-ac419b3914cc5cff18bc27fc9ff5a1ac22c2716d.gz --- TODO | 1 - src/edu/berkeley/sbp/tib/Tib.java | 11 ++++++++--- tests/regression.tc | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 27e9694..0ec9353 100644 --- a/TODO +++ b/TODO @@ -9,7 +9,6 @@ Immediately => mydrop => mylift - - whitespace-in-braces? - Deal with the problem of zero-rep productions and whitespace insertion - switch maximal to not-followed-by (~/~) diff --git a/src/edu/berkeley/sbp/tib/Tib.java b/src/edu/berkeley/sbp/tib/Tib.java index eabc9ee..9b4b974 100644 --- a/src/edu/berkeley/sbp/tib/Tib.java +++ b/src/edu/berkeley/sbp/tib/Tib.java @@ -296,13 +296,17 @@ public class Tib implements Token.Stream { public Object walk(Tree tree) { String head = tree.head(); if (tree.numChildren()==0) return super.walk(tree); - if ("{".equals(head)) - return nonTerminal("braced"+(anon++), + if ("{".equals(head)) { + String s = "braced"+(anon++); + Union u = nonTerminal(s); + Union u2 = ((PreSequence)walk(tree, 0)).sparse(ws).buildUnion(); + u2.add(Sequence.singleton(new Element[] { u }, 0, null, null)); + return nonTerminal(s, new PreSequence[][] { new PreSequence[] { new PreSequence(new Element[] { CharToken.leftBrace, ws, - ((PreSequence)walk(tree, 0)).sparse(ws).buildUnion(), + u2, ws, CharToken.rightBrace }) @@ -310,6 +314,7 @@ public class Tib implements Token.Stream { }, false, false); + } return super.walk(tree); } } diff --git a/tests/regression.tc b/tests/regression.tc index ce43a84..0d4b8d4 100644 --- a/tests/regression.tc +++ b/tests/regression.tc @@ -25,14 +25,14 @@ tibcase { hello there how - { are } + { are } "; output "yep"; s ::= { Hello } => "yep" w ::= " " | "\n" ws !::= w** - Hello ::= "hello" ws { "there" "how" { { "are" } } } + Hello ::= "hello" ws { "there" "how" { "are" } } } testcase { -- 1.7.10.4