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
|
|
16 import dwt.dwthelper.utils;
|
|
17
|
|
18
|
|
19 /**
|
|
20 * A specific configuration of pattern rule whereby
|
|
21 * the pattern begins with a specific sequence and may
|
|
22 * end with a specific sequence, but will not span more
|
|
23 * than a single line.
|
|
24 */
|
|
25 public class SingleLineRule : PatternRule {
|
|
26
|
|
27 /**
|
|
28 * Creates a rule for the given starting and ending sequence
|
|
29 * which, if detected, will return the specified token.
|
|
30 *
|
|
31 * @param startSequence the pattern's start sequence
|
|
32 * @param endSequence the pattern's end sequence
|
|
33 * @param token the token to be returned on success
|
|
34 */
|
|
35 public SingleLineRule(String startSequence, String endSequence, IToken token) {
|
|
36 this(startSequence, endSequence, token, (char) 0);
|
|
37 }
|
|
38
|
|
39 /**
|
|
40 * Creates a rule for the given starting and ending sequence
|
|
41 * which, if detected, will return the specified token.
|
|
42 * Any character which follows the given escape character
|
|
43 * will be ignored.
|
|
44 *
|
|
45 * @param startSequence the pattern's start sequence
|
|
46 * @param endSequence the pattern's end sequence
|
|
47 * @param token the token to be returned on success
|
|
48 * @param escapeCharacter the escape character
|
|
49 */
|
|
50 public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter) {
|
|
51 this(startSequence, endSequence, token, escapeCharacter, false);
|
|
52 }
|
|
53
|
|
54 /**
|
|
55 * Creates a rule for the given starting and ending sequence
|
|
56 * which, if detected, will return the specified token. Alternatively, the
|
|
57 * line can also be ended with the end of the file.
|
|
58 * Any character which follows the given escape character
|
|
59 * will be ignored.
|
|
60 *
|
|
61 * @param startSequence the pattern's start sequence
|
|
62 * @param endSequence the pattern's end sequence
|
|
63 * @param token the token to be returned on success
|
|
64 * @param escapeCharacter the escape character
|
|
65 * @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
|
|
66 * @since 2.1
|
|
67 */
|
|
68 public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, bool breaksOnEOF) {
|
|
69 super(startSequence, endSequence, token, escapeCharacter, true, breaksOnEOF);
|
|
70 }
|
|
71
|
|
72 /**
|
|
73 * Creates a rule for the given starting and ending sequence
|
|
74 * which, if detected, will return the specified token. Alternatively, the
|
|
75 * line can also be ended with the end of the file.
|
|
76 * Any character which follows the given escape character
|
|
77 * will be ignored. In addition, an escape character immediately before an
|
|
78 * end of line can be set to continue the line.
|
|
79 *
|
|
80 * @param startSequence the pattern's start sequence
|
|
81 * @param endSequence the pattern's end sequence
|
|
82 * @param token the token to be returned on success
|
|
83 * @param escapeCharacter the escape character
|
|
84 * @param breaksOnEOF indicates whether the end of the file successfully terminates this rule
|
|
85 * @param escapeContinuesLine indicates whether the specified escape character is used for line
|
|
86 * continuation, so that an end of line immediately after the escape character does not
|
|
87 * terminate the line, even if <code>breakOnEOL</code> is true
|
|
88 * @since 3.0
|
|
89 */
|
|
90 public SingleLineRule(String startSequence, String endSequence, IToken token, char escapeCharacter, bool breaksOnEOF, bool escapeContinuesLine) {
|
|
91 super(startSequence, endSequence, token, escapeCharacter, true, breaksOnEOF, escapeContinuesLine);
|
|
92 }
|
|
93 }
|