-// 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.*;
*/
public class Tib implements Input<Character> {
+ public String showRegion(Region<Character> r) { return null; }
+
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))); }
int _row = 1;
int _col = 0;
- public Input.Location getLocation() { return new CartesianLocation(_row, _col); }
+ 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<Integer> istack = new ArrayList<Integer>();
- public Character next(int numstates, int resets, int waits) throws IOException {
- Character ret = nextc(numstates, resets);
+ 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");
}
Character waitingBrace = null;
- public Character nextc(int numstates, int resets) throws IOException {
+ public Character nextc() throws IOException {
char c;
if (waitingBrace != null) {
Character ret = waitingBrace;
return null;
}
c = (char)i;
+ _scalar++;
if (c=='\n') { _row++; _col=0; }
else _col++;
}
if (indenting) {
if (c==' ') { indentation++; return done(c); }
- if (c=='\n') { indentation = 0; if (blank) return nextc(numstates, resets); blank = true; waiting = true; waitingChar='\n'; return '\n'; }
+ if (c=='\n') { indentation = 0; if (blank) return nextc(); blank = true; waiting = true; waitingChar='\n'; return '\n'; }
int last = istack.size()==0 ? -1 : istack.get(istack.size()-1);
if (indentation==last) {
if (blank) {
// Grammar //////////////////////////////////////////////////////////////////////////////
+ /*
public static class Grammar extends ReflectiveGrammar {
private int anon = 0;
private final Element ws = Sequence.maximal0(getNonTerminal("w"));
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)
}
});
return super.walk(tree);
}
}
+ */
/*
public class Braces extends Union {