01: /***** BEGIN LICENSE BLOCK *****
02: * Version: CPL 1.0/GPL 2.0/LGPL 2.1
03: *
04: * The contents of this file are subject to the Common Public
05: * License Version 1.0 (the "License"); you may not use this file
06: * except in compliance with the License. You may obtain a copy of
07: * the License at http://www.eclipse.org/legal/cpl-v10.html
08: *
09: * Software distributed under the License is distributed on an "AS
10: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
11: * implied. See the License for the specific language governing
12: * rights and limitations under the License.
13: *
14: * Copyright (C) 2004 Jan Arne Petersen <jpetersen@uni-bonn.de>
15: *
16: * Alternatively, the contents of this file may be used under the terms of
17: * either of the GNU General Public License Version 2 or later (the "GPL"),
18: * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
19: * in which case the provisions of the GPL or the LGPL are applicable instead
20: * of those above. If you wish to allow use of your version of this file only
21: * under the terms of either the GPL or the LGPL, and not to allow others to
22: * use your version of this file under the terms of the CPL, indicate your
23: * decision by deleting the provisions above and replace them with the notice
24: * and other provisions required by the GPL or the LGPL. If you do not delete
25: * the provisions above, a recipient may use your version of this file under
26: * the terms of any one of the CPL, the GPL or the LGPL.
27: ***** END LICENSE BLOCK *****/package org.jruby.lexer.yacc;
28:
29: public abstract class StrTerm {
30: public abstract int parseString(RubyYaccLexer lexer, LexerSource src)
31: throws java.io.IOException;
32:
33: // BEGIN NETBEANS MODIFICATIONS
34: /** Tell this string term to return separate tokens for embedded ruby code (#$foo, #@foo, #{foo}) */
35: public abstract void splitEmbeddedTokens();
36:
37: /**
38: * Report whether this string should be substituting things like \n into newlines (double
39: * quoting rules).
40: * E.g. are we dealing with a "" string or a '' string (or their alternate representations)
41: */
42: public abstract boolean isSubstituting();
43:
44: // When StringTerm processes a string with an embedded code fragment (or variable),
45: // such as #{thiscode()}, it splits the string up at the beginning of the boundary
46: // and returns Tokens.tSTRING_DBEG or Tokens.tSTRING_DVAR. However, it doesn't
47: // split the string up where the embedded code ends, it just processes to the end.
48: // For my lexing purposes that's not good enough; I want to know where the embedded
49: // fragment ends (so I can lex that String as real Ruby code rather than just
50: // a String literal).
51: // However,
52: /** Default; ignore embedded fragments */
53: final static int IGNORE_EMBEDDED = 0;
54: /** Flag set in embeddedCode when we are processing an embedded code expression: #{foo} */
55: final static int LOOKING_FOR_EMBEDDED = 1;
56: /** Flag set in embeddedCode when we are processing an embedded code expression: #{foo} */
57: final static int EMBEDDED_DEXPR = 2;
58: /** Flag set in embeddedCode when we are processing an embedded variable: #@foo */
59: final static int EMBEDDED_DVAR = 3;
60: /** Flag set while we're processing embedded Ruby expressions. It will be 0 when we are not,
61: * or otherwise set to the the relevant embedded type (EMBEDDED_DVAR or EMBEDDED_DEXPR) */
62: protected int processingEmbedded;
63:
64: /**
65: * Record any mutable state from this StrTerm such that it can
66: * be set back to this exact state through a call to {@link #setMutableState}
67: * later on. Necessary for incremental lexing where we may restart
68: * lexing parts of a string (since they can be split up due to
69: * Ruby embedding like "Evaluated by Ruby: #{foo}".
70: */
71: public abstract Object getMutableState();
72:
73: /** Support for incremental lexing: set current state of the term. See {@link #getMutableState} */
74: public abstract void setMutableState(Object o);
75: // END NETBEANS MODIFICATIONS
76: }
|