1 19 package org.netbeans.modules.css.text.syntax; 20 21 import org.netbeans.editor.*; 22 import org.netbeans.modules.css.text.syntax.javacc.lib.*; 23 import org.netbeans.modules.css.text.syntax.javacc.CSSSyntaxConstants; 24 25 31 public class CSSEditorSyntaxMapper implements JJMapperInterface, JJConstants, CSSSyntaxConstants { 32 33 34 35 public JJTokenID createToken(int id) { 36 37 switch(id) { 38 39 case JJ_EOL: 40 return CSSTokenContext.EOL; 41 42 case JJ_EOF: 43 throw new Error ("guessToken() must be called for such case."); 45 case JJ_ERR: 46 case ERR_IN_COMMENT: 47 48 return CSSTokenContext.ERROR; 49 50 51 case MEDIA_DECL: 52 case ATKW: 53 54 return CSSTokenContext.ATKW; 55 56 case COMMENT_IN_RULESET: 57 case CCOMMENT_IN_RULESET: 58 case COMMENT_START: 59 case TEXT_IN_COMMENT: 60 case COMMENT_END: 61 case CCOMMENT_START: 62 case CCOMMENT_END: 63 case TEXT_IN_CCOMMENT: 64 65 return CSSTokenContext.COMMENT; 66 67 case SELECTOR: 68 69 return CSSTokenContext.SELECTOR; 70 71 case PROP: 72 return CSSTokenContext.PROPERTY; 73 74 default: 75 return CSSTokenContext.PLAIN; 76 } 77 78 } 79 80 public final JJTokenID guessToken(String token,int state,boolean lastBuffer) { 81 82 switch (state) { 83 default: 84 return cannotGuess(lastBuffer); 85 } 86 } 87 88 private JJTokenID cannotGuess(boolean lastBuffer) { 89 return cannotGuess(lastBuffer, CSSTokenContext.PLAIN); 90 } 91 92 private JJTokenID cannotGuess(boolean lastBuffer, JJTokenID supposed) { 93 if (lastBuffer) { 94 return supposed; 95 } else { 96 return null; 98 } 99 } 100 101 104 public JJTokenID supposedToken(String token,int state,int id) { 105 106 switch (state) { 107 case IN_COMMENT: 108 return CSSTokenContext.COMMENT; 109 110 default: 111 return null; 112 } 113 } 114 115 } 116 | Popular Tags |