01: /*
02: * Copyright (c) 2001, Jacob Smullyan.
03: *
04: * This is part of SkunkDAV, a WebDAV client. See http://skunkdav.sourceforge.net/
05: * for the latest version.
06: *
07: * SkunkDAV is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License as published
09: * by the Free Software Foundation; either version 2, or (at your option)
10: * any later version.
11: *
12: * SkunkDAV is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with SkunkDAV; see the file COPYING. If not, write to the Free
19: * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20: * 02111-1307, USA.
21: */
22:
23: package org.skunk.swing.text.syntax;
24:
25: import java.io.IOException;
26: import java.io.Reader;
27: import org.skunk.trace.Debug;
28: import org.skunk.util.GappedIntArray;
29:
30: public abstract class FlexScanner {
31: protected int spanStart;
32: protected int offset = 0;
33: protected GappedIntArray styleBuffer;
34:
35: protected void setOffset(int offset) {
36: this .offset = offset;
37: }
38:
39: protected int getOffset() {
40: return this .offset;
41: }
42:
43: public void setStyleBuffer(GappedIntArray styleBuffer) {
44: this .styleBuffer = styleBuffer;
45: }
46:
47: public abstract void scan() throws IOException;
48:
49: /**
50: * resets the scanner to use a new Reader. JFlex implements this for you.
51: */
52: public abstract void yyreset(java.io.Reader reader)
53: throws IOException;
54:
55: public abstract void yybegin(int state);
56:
57: /**
58: * returns the current state of the scanner. JFlex implements this for you.
59: * @return the current state of the scanner.
60: */
61: public abstract int yystate();
62:
63: protected int applyStyle(int style, int charOffset, int length) {
64: return StyleBufferUtilities.applyStyle(styleBuffer, style,
65: yystate(), offset + charOffset, length);
66: }
67: }
68:
69: /* $Log: FlexScanner.java,v $
70: /* Revision 1.8 2001/02/14 19:15:37 smulloni
71: /* modified usage of the style buffer to pack state information into its ints.
72: /* Previously, I had stipulated that a style could only be used in one state
73: /* per mode; that restriction may now be lifted.
74: /*
75: /* Revision 1.7 2001/02/13 22:53:50 smulloni
76: /* adding a syntax highlighting mode for STML (Skunk Template Markup Language);
77: /* fixed a bug in SyntaxStyle in reading default.styles.
78: /*
79: /* Revision 1.6 2001/02/09 20:00:00 smulloni
80: /* fixed particularly nasty bug in GappedIntArray.set(int, int[]), and other
81: /* bugs in the syntax highlighting system.
82: /*
83: /* Revision 1.5 2001/02/02 23:30:33 smulloni
84: /* adding customization features to the text editor.
85: /*
86: /* Revision 1.4 2001/01/30 23:03:19 smulloni
87: /* beginning of integration of syntax highlighting into SimpleTextEditor.
88: /*
89: /* Revision 1.3 2001/01/30 18:01:27 smulloni
90: /* first working beta of syntax highlighting. Nasty bug in
91: /* GappedIntArray.remove() fixed.
92: /*
93: /* Revision 1.2 2001/01/29 22:28:47 smulloni
94: /* syntax highlighting package now uses a custom view for painting the
95: /* highlights. Fixed bug in get(int, int[]) in GappedIntArray.
96: /*
97: /* Revision 1.1 2001/01/25 22:50:48 smulloni
98: /* integrating JFlex into still-broken syntax highlighting package.
99: /* */
|