1 | /** |
2 | * |
3 | */ |
4 | package de.uka.ipd.sdq.pcm.dialogs.stoex; |
5 | |
6 | import org.antlr.runtime.Token; |
7 | import org.eclipse.jface.text.TextAttribute; |
8 | import org.eclipse.swt.SWT; |
9 | import org.eclipse.swt.graphics.Color; |
10 | import org.eclipse.swt.graphics.RGB; |
11 | |
12 | import de.uka.ipd.sdq.pcm.stochasticexpressions.parser.PCMStoExLexer; |
13 | |
14 | /** |
15 | * @author Steffen Becker |
16 | * |
17 | */ |
18 | public class StoExTokenMapper implements ITokenMapper { |
19 | |
20 | /** |
21 | * |
22 | */ |
23 | public StoExTokenMapper() { |
24 | // TODO Auto-generated constructor stub |
25 | } |
26 | |
27 | /* (non-Javadoc) |
28 | * @see de.uka.ipd.sdq.dialogs.selection.IColorMapper#mapColor(antlr.Token) |
29 | */ |
30 | public Object mapColor(Token t) { |
31 | switch (t.getType()) { |
32 | case PCMStoExLexer.EQUAL: |
33 | case PCMStoExLexer.PLUS: |
34 | case PCMStoExLexer.MINUS: |
35 | case PCMStoExLexer.MUL: |
36 | case PCMStoExLexer.DIV: |
37 | case PCMStoExLexer.POW: |
38 | case PCMStoExLexer.LPAREN: |
39 | case PCMStoExLexer.RPAREN: |
40 | case PCMStoExLexer.AND: |
41 | case PCMStoExLexer.OR: |
42 | case PCMStoExLexer.XOR: |
43 | case PCMStoExLexer.NOT: |
44 | return new TextAttribute (new Color( null, new RGB(0,0,0) ), null, SWT.BOLD); |
45 | case PCMStoExLexer.DOUBLEPDF: |
46 | case PCMStoExLexer.INTPMF: |
47 | case PCMStoExLexer.ENUMPMF: |
48 | case PCMStoExLexer.BOOLPMF: |
49 | case PCMStoExLexer.DOUBLEPMF: |
50 | return new TextAttribute (new Color( null, new RGB(255,0,0) ), null, SWT.BOLD); |
51 | case PCMStoExLexer.NUMBER: |
52 | case PCMStoExLexer.STRING_LITERAL: |
53 | return new TextAttribute (new Color( null, new RGB(0,0,255) ), null, SWT.BOLD); |
54 | case PCMStoExLexer.BYTESIZE: |
55 | case PCMStoExLexer.NUMBER_OF_ELEMENTS: |
56 | case PCMStoExLexer.STRUCTURE: |
57 | case PCMStoExLexer.VALUE: |
58 | case PCMStoExLexer.TYPE: |
59 | case PCMStoExLexer.INNER: |
60 | case PCMStoExLexer.FALSE: |
61 | case PCMStoExLexer.TRUE: |
62 | return new TextAttribute (new Color( null, new RGB(255,0,255) ), null, SWT.ITALIC); |
63 | case PCMStoExLexer.ID: |
64 | return new TextAttribute (new Color( null, new RGB(255,0,255) ), null, SWT.NONE); |
65 | case PCMStoExLexer.LINE_COMMENT: |
66 | case PCMStoExLexer.COMMENT: |
67 | return new TextAttribute (new Color( null, new RGB(190,190,190) ), null, SWT.NONE); |
68 | default: |
69 | return null; |
70 | } |
71 | } |
72 | |
73 | } |
74 | |