129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Christopher Lenz (cmlenz@gmx.de) - support for line continuation
|
|
11 * Port to the D programming language:
|
|
12 * Frank Benoit <benoit@tionex.de>
|
|
13 *******************************************************************************/
|
|
14 module dwtx.jface.text.rules.SingleLineRule;
|
|
15
|
131
|
16 import dwtx.jface.text.rules.FastPartitioner; // packageimport
|
|
17 import dwtx.jface.text.rules.ITokenScanner; // packageimport
|
|
18 import dwtx.jface.text.rules.Token; // packageimport
|
|
19 import dwtx.jface.text.rules.RuleBasedScanner; // packageimport
|
|
20 import dwtx.jface.text.rules.EndOfLineRule; // packageimport
|
|
21 import dwtx.jface.text.rules.WordRule; // packageimport
|
|
22 import dwtx.jface.text.rules.WhitespaceRule; // packageimport
|
|
23 import dwtx.jface.text.rules.WordPatternRule; // packageimport
|
|
24 import dwtx.jface.text.rules.IPredicateRule; // packageimport
|
|
25 import dwtx.jface.text.rules.DefaultPartitioner; // packageimport
|
|
26 import dwtx.jface.text.rules.NumberRule; // packageimport
|
|
27 import dwtx.jface.text.rules.PatternRule; // packageimport
|
|
28 import dwtx.jface.text.rules.IWordDetector; // packageimport
|
|
29 import dwtx.jface.text.rules.RuleBasedDamagerRepairer; // packageimport
|
|
30 import dwtx.jface.text.rules.ICharacterScanner; // packageimport
|
|
31 import dwtx.jface.text.rules.IRule; // packageimport
|
|
32 import dwtx.jface.text.rules.DefaultDamagerRepairer; // packageimport
|
|
33 import dwtx.jface.text.rules.IToken; // packageimport
|
|
34 import dwtx.jface.text.rules.IPartitionTokenScanner; // packageimport
|
|
35 import dwtx.jface.text.rules.MultiLineRule; // packageimport
|
|
36 import dwtx.jface.text.rules.RuleBasedPartitioner; // packageimport
|
|
37 import dwtx.jface.text.rules.RuleBasedPartitionScanner; // packageimport
|
|
38 import dwtx.jface.text.rules.BufferedRuleBasedScanner; // packageimport
|
|
39 import dwtx.jface.text.rules.IWhitespaceDetector; // packageimport
|
|
40
|
|
41
|
129
|
42 import dwt.dwthelper.utils;
|
|
43
|
|
44
|
|
45 /**
|
|
46 * A specific configuration of pattern rule whereby
|
|
47 * the pattern begins with a specific sequence and may
|
|
48 * end with a specific sequence, but will not span more
|
|
49 * than a single line.
|
|
50 */
|
|
51 public class SingleLineRule : PatternRule {
|
|
52
|
|
53 /**
|
|
54 * Creates a rule for the given starting and ending sequence
|
|
55 * which, if detected, will return the specified token.
|
|
56 *
|
|
57 * @param startSequence the pattern's start sequence
|
|
58 * @param endSequence the pattern's end sequence
|
|
59 * @param token the token to be returned on success
|
|
60 */
|
|
61 public SingleLineRule(String startSequence, String endSequence, IToken token) {
|
|
62 this(startSequence, endSequence, token, (char) 0);
|
|
63 }
|
|
64
|
|
65 /**
|
|
66 * Creates a rule for the given starting and ending sequence
|
|
67 * which, if detected, will return the specified token.
|
|
68 * Any character which follows the given escape character
|
|
69 * will be ignored.
|
|
70 *
|
|
71 * @param startSequence the pattern's start sequence
|
|
72 * @param endSequence the pattern's end sequence
|
|
73 * @param token the token to be returned on success
|
|
74 * @param escapeCharacter the escape character
|
|
75 */
|
|
76 public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) {
|
|
77 this(startSequence, endSequence, token, escapeCharacter, false);
|
|
78 }
|
|
79
|
|
80 /**
|
|
81 * Creates a rule for the given starting and ending sequence
|
|
82 * which, if detected, will return the specified token. Alternatively, the
|
|
83 * line can also be ended with the end of the file.
|
|
84 * Any character which follows the given escape character
|
|
85 * will be ignored.
|
|
86 *
|
|
87 * @param startSequence the pattern's start sequence
|
|
88 * @param endSequence the pattern's end sequence
|
|
89 * @param token the token to be returned on success
|
|
90 * @param escapeCharacter the escape character
|
|
91 * @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
|
|
92 * @since 2.1
|
|
93 */
|
|
94 public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, bool breaksOnEOF) {
|
|
95 super(startSequence, endSequence, token, escapeCharacter, true, breaksOnEOF);
|
|
96 }
|
|
97
|
|
98 /**
|
|
99 * Creates a rule for the given starting and ending sequence
|
|
100 * which, if detected, will return the specified token. Alternatively, the
|
|
101 * line can also be ended with the end of the file.
|
|
102 * Any character which follows the given escape character
|
|
103 * will be ignored. In addition, an escape character immediately before an
|
|
104 * end of line can be set to continue the line.
|
|
105 *
|
|
106 * @param startSequence the pattern's start sequence
|
|
107 * @param endSequence the pattern's end sequence
|
|
108 * @param token the token to be returned on success
|
|
109 * @param escapeCharacter the escape character
|
|
110 * @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
|
|
111 * @param escapeContinuesLine indicates whether the specified escape character is used for line
|
|
112 * continuation, so that an end of line immediately after the escape character does not
|
|
113 * terminate the line, even if <code>breakOnEOL</code> is true
|
|
114 * @since 3.0
|
|
115 */
|
|
116 public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, bool breaksOnEOF, bool escapeContinuesLine) {
|
|
117 super(startSequence, endSequence, token, escapeCharacter, true, breaksOnEOF, escapeContinuesLine);
|
|
118 }
|
|
119 }
|