| /******************************************************************************* |
| * Copyright (c) 2004-2008 Istvan Rath and Daniel Varro |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.editor.text.light.vtml;
|
|
|
| import java.util.ArrayList; |
| import java.util.List; |
| |
| import org.eclipse.jface.text.rules.EndOfLineRule; |
| import org.eclipse.jface.text.rules.IRule; |
| import org.eclipse.jface.text.rules.IToken; |
| import org.eclipse.jface.text.rules.MultiLineRule; |
| import org.eclipse.jface.text.rules.RuleBasedScanner; |
| import org.eclipse.jface.text.rules.SingleLineRule; |
| import org.eclipse.jface.text.rules.WhitespaceRule; |
| import org.eclipse.jface.text.rules.WordRule; |
| import org.eclipse.viatra2.editor.text.light.IVTEConstants; |
| import org.eclipse.viatra2.editor.text.light.VTEColorProvider; |
| import org.eclipse.viatra2.editor.text.light.VTEColorToken; |
|
|
|
|
| public class VTMLCodeScanner extends RuleBasedScanner {
|
| public VTMLCodeScanner(VTEColorProvider provider,VTEColorToken vct)
|
| {
|
|
|
| IToken keyword = vct.KEYWORD;
|
| IToken string = vct.STRING;
|
| IToken comment = vct.COMMENT;
|
| IToken other = vct.OTHER;
|
|
|
| String[] keywords = IVTEConstants.vtmlKeywords;
|
| List<IRule> rules= new ArrayList<IRule>();
|
| rules.add(new MultiLineRule("/*","*/",comment));
|
| rules.add(new EndOfLineRule("//", comment));
|
| rules.add(new SingleLineRule("\"", "\"", string, '\\'));
|
| rules.add(new SingleLineRule("'", "'", string, '\\'));
|
| rules.add(new WhitespaceRule(new VTMLWhitespaceDetector()));
|
| WordRule wordRule= new WordRule(new VTMLWordDetector(), other);
|
| for (int i= 0; i < keywords.length; i++)
|
| wordRule.addWord(keywords[i], keyword);
|
| rules.add(wordRule);
|
| IRule[] result= new IRule[rules.size()];
|
| rules.toArray(result);
|
| setRules(result);
|
|
|
| }
|
| }
|