v4: Fix BlankListenerFile (these files should be part of CL9408)

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9409]
This commit is contained in:
sharwell 2011-11-19 15:32:40 -08:00
parent 426d96c3b8
commit beb4386fd0
4 changed files with 53 additions and 18 deletions

View File

@ -36,15 +36,12 @@ import org.antlr.v4.tool.ast.GrammarAST;
import java.util.HashMap;
import java.util.Map;
public class LexerFile extends OutputModelObject {
public String fileName;
public class LexerFile extends OutputFile {
@ModelElement public Lexer lexer;
@ModelElement public Map<String, Action> namedActions;
public LexerFile(OutputModelFactory factory, String fileName) {
super(factory);
this.fileName = fileName;
super(factory, fileName);
namedActions = new HashMap<String, Action>();
Grammar g = factory.getGrammar();
for (String name : g.namedActions.keySet()) {

View File

@ -11,8 +11,7 @@ import java.util.List;
/** A model object representing a parse tree listener file.
* These are the rules specific events triggered by a parse tree visitor.
*/
public class ListenerFile extends OutputModelObject {
public String fileName;
public class ListenerFile extends OutputFile {
public String grammarName;
public String parserName;
public List<String> listenerNames = new ArrayList<String>();
@ -21,8 +20,7 @@ public class ListenerFile extends OutputModelObject {
@ModelElement public Action header;
public ListenerFile(OutputModelFactory factory, String fileName) {
super(factory);
this.fileName = fileName;
super(factory, fileName);
Grammar g = factory.getGrammar();
parserName = g.getRecognizerName();
grammarName = g.name;

View File

@ -0,0 +1,47 @@
/*
[The "BSD license"]
Copyright (c) 2011 Terence Parr
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.antlr.v4.codegen.model;
import org.antlr.v4.codegen.OutputModelFactory;
import org.antlr.v4.tool.Grammar;
public abstract class OutputFile extends OutputModelObject {
public final String fileName;
public final String TokenLabelType;
public final String ASTLabelType;
public OutputFile(OutputModelFactory factory, String fileName) {
super(factory);
this.fileName = fileName;
Grammar g = factory.getGrammar();
TokenLabelType = g.getOptionString("TokenLabelType");
ASTLabelType = g.getOptionString("ASTLabelType", "CommonAST");
}
}

View File

@ -36,20 +36,13 @@ import org.antlr.v4.tool.ast.GrammarAST;
import java.util.*;
/** */
public class ParserFile extends OutputModelObject {
public String fileName;
public String TokenLabelType;
public String ASTLabelType;
public class ParserFile extends OutputFile {
@ModelElement public Parser parser;
@ModelElement public Map<String, Action> namedActions;
public ParserFile(OutputModelFactory factory, String fileName) {
super(factory);
this.fileName = fileName;
super(factory, fileName);
Grammar g = factory.getGrammar();
TokenLabelType = g.getOptionString("TokenLabelType");
ASTLabelType = g.getOptionString("ASTLabelType", "CommonAST");
namedActions = new HashMap<String, Action>();
for (String name : g.namedActions.keySet()) {
GrammarAST ast = g.namedActions.get(name);