1) Added missing strings for italic, underline and strike through.
[phpeclipse.git] / net.sourceforge.phpeclipse.smarty.ui / src / net / sourceforge / phpdt / smarty / ui / internal / text / SmartyTagRule.java
1 /*
2  * Copyright (c) 2002-2004 Widespace, OU and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *     Igor Malinin - initial contribution
10  *
11  * $Id: SmartyTagRule.java,v 1.3 2006-10-21 23:19:32 pombredanne Exp $
12  */
13
14 package net.sourceforge.phpdt.smarty.ui.internal.text;
15
16 import org.eclipse.jface.text.rules.ICharacterScanner;
17 import org.eclipse.jface.text.rules.IRule;
18 import org.eclipse.jface.text.rules.IToken;
19 import org.eclipse.jface.text.rules.Token;
20
21 /**
22  * Rule detecting smarty tags
23  */
24 public class SmartyTagRule implements IRule {
25
26         private IToken token;
27
28         public SmartyTagRule(IToken token) {
29                 this.token = token;
30         }
31
32         public IToken evaluate(ICharacterScanner scanner) {
33                 int ch = scanner.read();
34                 if (ch == '}') {
35                         return token;
36                 }
37                 if (ch == '/') {
38                         ch = scanner.read();
39                         if (ch == '}') {
40                                 return token;
41                         }
42
43                         scanner.unread();
44                         scanner.unread();
45                         return Token.UNDEFINED;
46                 }
47                 if (ch == '{') {
48                         ch = scanner.read();
49                         if (ch == '/') {
50                                 ch = scanner.read();
51                         }
52                         loop: while (true) {
53                                 switch (ch) {
54                                 case ICharacterScanner.EOF:
55                                 case 0x09:
56                                 case 0x0A:
57                                 case 0x0D:
58                                 case 0x20:
59                                         scanner.unread();
60                                         break loop;
61                                 case '}':
62                                         break loop;
63                                 }
64
65                                 ch = scanner.read();
66                         }
67                         return token;
68                 }
69                 scanner.unread();
70                 return Token.UNDEFINED;
71         }
72 }