All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.nasa.pds.tools.label.antlr.ODLParser Maven / Gradle / Ivy

Go to download

The PDS3 Product Tools Library project supports design/generation, validation and submission of archival products to the PDS. This project consists of a library of software classes to support the development of tools to perform these functions and is designed to be utilized by developers from the Engineering Node, Discipline Nodes and the PDS community.

There is a newer version: 4.4.0
Show newest version
// $ANTLR 3.2 Sep 23, 2009 14:05:07 /Users/jpadams/Documents/proj/pds/pdsen/workspace/pds3-product-tools/src/main/antlr3/gov/nasa/pds/tools/label/antlr/ODL.g 2019-06-28 13:16:16

package gov.nasa.pds.tools.label.antlr;

import gov.nasa.pds.tools.constants.Constants.ProblemType;
import gov.nasa.pds.tools.LabelParserException;
import gov.nasa.pds.tools.label.AttributeStatement;
import gov.nasa.pds.tools.label.CommentStatement;
import gov.nasa.pds.tools.label.DateTime;
import gov.nasa.pds.tools.label.GroupStatement;
import gov.nasa.pds.tools.label.Label;
import gov.nasa.pds.tools.label.Numeric;
import gov.nasa.pds.tools.label.ObjectStatement;
import gov.nasa.pds.tools.label.PointerResolver;
import gov.nasa.pds.tools.label.PointerStatement;
import gov.nasa.pds.tools.label.PointerStatementFactory;
import gov.nasa.pds.tools.label.Scalar;
import gov.nasa.pds.tools.label.Sequence;
import gov.nasa.pds.tools.label.Set;
import gov.nasa.pds.tools.label.Statement;
import gov.nasa.pds.tools.label.IncludePointer;
import gov.nasa.pds.tools.label.Symbol;
import gov.nasa.pds.tools.label.TextString;
import gov.nasa.pds.tools.label.ValueType;
import gov.nasa.pds.tools.label.Value;
import gov.nasa.pds.tools.util.AntlrUtils;

import java.io.File;
import java.io.IOException;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;@SuppressWarnings("all")
public class ODLParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "", "", "", "", "END", "END_GROUP", "END_OBJECT", "COMMENT", "EOL", "IDENTIFIER", "UNITS", "INTEGER", "BASED_INTEGER", "REAL", "QUOTED", "BAD_TOKEN", "QUOTED_UNTERMINATED", "DATETIME", "SYMBOL", "SIGN", "DIGIT", "LETTER", "EXTENDED_DIGIT", "DIGITS", "SPECIALCHAR", "WS", "TIME", "INTEGER_OR_TIME", "'OBJECT'", "'='", "'GROUP'", "'^'", "'('", "')'", "','", "'{'", "'}'"
    };
    public static final int LETTER=21;
    public static final int DIGITS=23;
    public static final int COMMENT=7;
    public static final int T__33=33;
    public static final int T__34=34;
    public static final int T__35=35;
    public static final int T__36=36;
    public static final int IDENTIFIER=9;
    public static final int SIGN=19;
    public static final int WS=25;
    public static final int INTEGER_OR_TIME=27;
    public static final int EOF=-1;
    public static final int T__30=30;
    public static final int UNITS=10;
    public static final int T__31=31;
    public static final int T__32=32;
    public static final int INTEGER=11;
    public static final int BASED_INTEGER=12;
    public static final int EOL=8;
    public static final int QUOTED=14;
    public static final int EXTENDED_DIGIT=22;
    public static final int BAD_TOKEN=15;
    public static final int TIME=26;
    public static final int QUOTED_UNTERMINATED=16;
    public static final int DIGIT=20;
    public static final int DATETIME=17;
    public static final int SYMBOL=18;
    public static final int SPECIALCHAR=24;
    public static final int T__28=28;
    public static final int T__29=29;
    public static final int REAL=13;
    public static final int END=4;
    public static final int END_GROUP=5;
    public static final int END_OBJECT=6;

    // delegates
    // delegators


        public ODLParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public ODLParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        

    public String[] getTokenNames() { return ODLParser.tokenNames; }
    public String getGrammarFileName() { return "/Users/jpadams/Documents/proj/pds/pdsen/workspace/pds3-product-tools/src/main/antlr3/gov/nasa/pds/tools/label/antlr/ODL.g"; }



        private PointerResolver pointerResolver;

        private Boolean loadIncludes = true;

        public void setPointerResolver(final PointerResolver pointerResolver) {
            this.pointerResolver = pointerResolver;
        }

        public void setLoadIncludes(Boolean loadIncludes) {
            this.loadIncludes = loadIncludes;
        }

        private Label label = null;

        @Override
        public void displayRecognitionError(String[] tokenNames,
                                            RecognitionException e) {
            if (label != null) {
            	if(e instanceof NoViableAltException) {
                    label.addProblem(e.line, e.charPositionInLine, "parser.error.noViableAlternative", ProblemType.PARSE_ERROR, e.token.getText());
                } else if(e instanceof MissingTokenException) {
                    final MissingTokenException mte = (MissingTokenException) e;
                    String missing = tokenNames[mte.expecting];
                    label.addProblem(e.line, e.charPositionInLine, "parser.error.missingToken", ProblemType.PARSE_ERROR, missing, mte.token.getText());
                } else if(e instanceof UnwantedTokenException) {
                    final UnwantedTokenException ute = (UnwantedTokenException) e;
                    String expectingToken = tokenNames[ute.expecting];
                    label.addProblem(e.line, e.charPositionInLine, "parser.error.extraToken", ProblemType.PARSE_ERROR, e.token.getText(), expectingToken);
                } else {
                	// unhandled, if example found, do another instanceof case
                	String msg = getErrorMessage(e, tokenNames);
                	label.addProblem(e.line, e.charPositionInLine, "parser.error.unhandledException", ProblemType.PARSE_ERROR, msg, e.getClass().getName());
                }
            }
        }

        public void reportExtraTokens(final List extraTokens, final Value value, final String idText) {
        	if(extraTokens.size() > 0) {
        		final Token first = extraTokens.get(0);
                String extraTokensString = value.toString() + ", ";
                extraTokensString+= AntlrUtils.toSeparatedString(extraTokens);
                label.addProblem(first.getLine(), first.getCharPositionInLine(), "parser.error.tooManyTokens", ProblemType.BAD_VALUE, extraTokensString, idText);
            }
        }



    // $ANTLR start "dictionary"
    // /Users/jpadams/Documents/proj/pds/pdsen/workspace/pds3-product-tools/src/main/antlr3/gov/nasa/pds/tools/label/antlr/ODL.g:180:1: dictionary returns [List




© 2015 - 2024 Weber Informatics LLC | Privacy Policy