KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > lexer > gen > handcoded > HandcodedLanguageGenerator


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.lexer.gen.handcoded;
21
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
24 import org.netbeans.modules.lexer.gen.DescriptionReader;
25 import org.netbeans.modules.lexer.gen.LanguageGenerator;
26 import org.netbeans.modules.lexer.gen.LanguageData;
27 import org.netbeans.modules.lexer.gen.util.LexerGenUtilities;
28 import org.xml.sax.SAXException JavaDoc;
29
30 /**
31  * Language class generator for handcoded lexers.
32  *
33  * @author Miloslav Metelka
34  * @version 1.00
35  */

36
37 public class HandcodedLanguageGenerator extends LanguageGenerator {
38
39     public String JavaDoc generate(String JavaDoc langClassName, String JavaDoc lexerClassName,
40     String JavaDoc tokenTypesClassName, File JavaDoc xmlLangDescFile)
41     throws SAXException JavaDoc, IOException JavaDoc {
42
43         LanguageData data = new LanguageData();
44         data.setLanguageClassName(langClassName);
45         data.setLexerClassName(lexerClassName);
46
47         // Apply possible xml description
48
if (xmlLangDescFile != null) {
49             DescriptionReader xmlLangDesc = new DescriptionReader(
50                 xmlLangDescFile.getAbsolutePath());
51
52             xmlLangDesc.applyTo(data);
53         }
54
55         // Update int ids that do not specify integer ids specifically
56
data.updateUnassignedIntIds();
57
58         return createSource(data);
59     }
60
61 }
62
63
Popular Tags