1 19 20 package org.netbeans.modules.lexer.gen.antlr; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import org.netbeans.modules.lexer.gen.DescriptionReader; 25 import org.netbeans.modules.lexer.gen.LanguageGenerator; 26 import org.netbeans.modules.lexer.gen.MutableTokenId; 27 import org.netbeans.modules.lexer.gen.LanguageData; 28 import org.netbeans.modules.lexer.gen.TokenTypes; 29 import org.netbeans.modules.lexer.gen.util.LexerGenUtilities; 30 import org.xml.sax.SAXException ; 31 32 38 39 public class AntlrLanguageGenerator extends LanguageGenerator { 40 41 public String generate(String langClassName, String lexerClassName, 42 String tokenTypesClassName, File xmlLangDescFile) 43 throws ClassNotFoundException , SAXException , IOException { 44 45 LanguageData data = new LanguageData(); 46 data.setLanguageClassName(langClassName); 47 data.setLexerClassName(lexerClassName); 48 49 if (tokenTypesClassName != null) { 51 Class tokenTypesClass = Class.forName(tokenTypesClassName); 52 TokenTypes tokenTypes = new AntlrTokenTypes(tokenTypesClass); 53 data.registerTokenTypes(tokenTypes); 54 } 55 56 if (xmlLangDescFile != null) { 58 DescriptionReader xmlLangDesc = new DescriptionReader( 59 xmlLangDescFile.getAbsolutePath()); 60 61 xmlLangDesc.applyTo(data); 62 } 63 64 65 data.updateUnassignedIntIds(); 67 68 return createSource(data); 69 } 70 71 } 72 73 | Popular Tags |