X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Ftib%2FTib.java;h=c2f3468a627bf552e3fc07340dd240fe5f0c29bf;hp=4805d1e8f543cbf16fcfef674552e391f72e3788;hb=778717ec55a53ceab4847f2a0922478d6c06e4e1;hpb=ac3843911c47a601ffd679d2e075b519d3a18d6a diff --git a/src/edu/berkeley/sbp/tib/Tib.java b/src/edu/berkeley/sbp/tib/Tib.java index 4805d1e..c2f3468 100644 --- a/src/edu/berkeley/sbp/tib/Tib.java +++ b/src/edu/berkeley/sbp/tib/Tib.java @@ -1,6 +1,4 @@ -// Copyright 2005 the Contributors, as shown in the revision logs. -// Licensed under the Apache Public Source License 2.0 ("the License"). -// You may not use this file except in compliance with the License. +// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license package edu.berkeley.sbp.tib; import edu.berkeley.sbp.*; @@ -26,6 +24,8 @@ import java.io.*; */ public class Tib implements Input { + public String showRegion(Region r) { return ""; } + public Tib(String s) throws IOException { this(new StringReader(s)); } public Tib(Reader r) throws IOException { this(new BufferedReader(r)); } public Tib(InputStream is) throws IOException { this(new BufferedReader(new InputStreamReader(is))); } @@ -42,23 +42,27 @@ public class Tib implements Input { int _row = 1; int _col = 0; - public Input.Location getLocation() { return new Input.Location.Cartesian(_col, _row); } + int _scalar = 0; + public Input.Location getLocation() { return new Cartesian.Location(_col, _row, _scalar); } private BufferedReader br; - char left = CharRange.left; - char right = CharRange.right; + char left = CharAtom.left; + char right = CharAtom.right; boolean waiting = false; char waitingChar = ' '; boolean indenting = true; int indentation = 0; private ArrayList istack = new ArrayList(); + private static boolean debug = "true".equals(System.getProperty("tib.debug", "false")); public Character next() throws IOException { Character ret = nextc(); - if (ret==null) return null; - else if (ret==left) System.out.print("\033[31m{\033[0m"); - else if (ret==right) System.out.print("\033[31m}\033[0m"); - else System.out.print(ret); + if (debug) { + if (ret==null) return null; + else if (ret==left) System.out.print("\033[31m{\033[0m"); + else if (ret==right) System.out.print("\033[31m}\033[0m"); + else System.out.print(ret); + } return ret; } @@ -83,6 +87,7 @@ public class Tib implements Input { return null; } c = (char)i; + _scalar++; if (c=='\n') { _row++; _col=0; } else _col++; } @@ -135,6 +140,7 @@ public class Tib implements Input { // Grammar ////////////////////////////////////////////////////////////////////////////// + /* public static class Grammar extends ReflectiveGrammar { private int anon = 0; private final Element ws = Sequence.maximal0(getNonTerminal("w")); @@ -148,11 +154,11 @@ public class Tib implements Input { u2.add(Sequence.singleton(new Element[] { u }, 0)); return anonymousNonTerminal(new Sequence[][] { new Sequence[] { - Sequence.singleton(new Element[] { CharRange.leftBrace, + Sequence.singleton(new Element[] { CharAtom.leftBrace, ws, u2, ws, - CharRange.rightBrace + CharAtom.rightBrace }, 2) } }); @@ -160,6 +166,7 @@ public class Tib implements Input { return super.walk(tree); } } + */ /* public class Braces extends Union {