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

org.apache.jute.compiler.generated.rcc.jj Maven / Gradle / Ivy

The newest version!
options {
STATIC=false;
}

PARSER_BEGIN(Rcc)
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jute.compiler.generated;

import org.apache.jute.compiler.*;
import java.util.ArrayList;
import java.util.Hashtable;
import java.io.File;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.IOException;

@SuppressWarnings("unused")
public class Rcc {
    private static Hashtable recTab = new Hashtable();
    private static String curDir = System.getProperty("user.dir");
    private static String curFileName;
    private static String curModuleName;

    public static void main(String args[]) {
        String language = "java";
        ArrayList recFiles = new ArrayList();
        JFile curFile=null;
        
        for (int i=0; i();
            return parser.Input();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
            }
        }
    }
}

PARSER_END(Rcc)

SKIP :
{
  " "
| "\t"
| "\n"
| "\r"
}

SPECIAL_TOKEN :
{
  "//" : WithinOneLineComment
}

 SPECIAL_TOKEN :
{
  <("\n" | "\r" | "\r\n" )> : DEFAULT
}

 MORE :
{
  <~[]>
}

SPECIAL_TOKEN :
{
  "/*" : WithinMultiLineComment
}

 SPECIAL_TOKEN :
{
  "*/" : DEFAULT
}

 MORE :
{
  <~[]>
}

TOKEN :
{
    
|   
|   
|   
|   
|   
|   
|   
|   
|   
|   
|   
|   
|   
|   
|   
|   ">
|   
|   
|   
|   
|   
}

JFile Input() :
{
    ArrayList ilist = new ArrayList();
    ArrayList rlist = new ArrayList();
    JFile i;
    ArrayList l;
}
{
    (
        i = Include()
        { ilist.add(i); }
    |   l = Module()
        { rlist.addAll(l); }
    )+
    
    { return new JFile(curFileName, ilist, rlist); }
}

JFile Include() :
{
    String fname;
    Token t;
}
{
    
    t = 
    {
        JFile ret = null;
        fname = t.image.replaceAll("^\"", "").replaceAll("\"$","");
        File file = new File(curDir, fname);
        String tmpDir = curDir;
        String tmpFile = curFileName;
        curDir = file.getParent();
        curFileName = file.getName();
        try {
            FileReader reader = new FileReader(file);
            Rcc parser = new Rcc(reader);
            try {
                ret = parser.Input();
                System.out.println(fname + " Parsed Successfully");
            } catch (ParseException e) {
                System.out.println(e.toString());
                System.exit(1);
            }
            try {
                reader.close();
            } catch (IOException e) {
            }
        } catch (FileNotFoundException e) {
            System.out.println("File " + fname +
                " Not found.");
            System.exit(1);
        }
        curDir = tmpDir;
        curFileName = tmpFile;
        return ret;
    }
}

ArrayList Module() :
{
    String mName;
    ArrayList rlist;
}
{
    
    mName = ModuleName()
    { curModuleName = mName; }
    
    rlist = RecordList()
    
    { return rlist; }
}

String ModuleName() :
{
    String name = "";
    Token t;
}
{
    t = 
    { name += t.image; }
    (
        
        t = 
        { name += "." + t.image; }
    )*
    { return name; }
}

ArrayList RecordList() :
{
    ArrayList rlist = new ArrayList();
    JRecord r;
}
{
    (
        r = Record()
        { rlist.add(r); }
    )+
    { return rlist; }
}

JRecord Record() :
{
    String rname;
    ArrayList flist = new ArrayList();
    Token t;
    JField f;
}
{
    
    t = 
    { rname = t.image; }
    
    (
        f = Field()
        { flist.add(f); }
        
    )+
    
    {
        String fqn = curModuleName + "." + rname;
        JRecord r = new JRecord(fqn, flist);
        recTab.put(fqn, r);
        return r;
    }
}

JField Field() :
{
    JType jt;
    Token t;
}
{
    jt = Type()
    t = 
    { return new JField(jt, t.image); }
}

JType Type() :
{
    JType jt;
    Token t;
    String rname;
}
{
    jt = Map()
    { return jt; }
|   jt = Vector()
    { return jt; }
|   
    { return new JByte(); }
|   
    { return new JBoolean(); }
|   
    { return new JInt(); }
|   
    { return new JLong(); }
|   
    { return new JFloat(); }
|   
    { return new JDouble(); }
|   
    { return new JString(); }
|   
    { return new JBuffer(); }
|   rname = ModuleName()
    {
        if (rname.indexOf('.', 0) < 0) {
            rname = curModuleName + "." + rname;
        }
        JRecord r = recTab.get(rname);
        if (r == null) {
            System.out.println("Type " + rname + " not known. Exiting.");
            System.exit(1);
        }
        return r;
    }
}

JMap Map() :
{
    JType jt1;
    JType jt2;
}
{
    
    
    jt1 = Type()
    
    jt2 = Type()
    
    { return new JMap(jt1, jt2); }
}

JVector Vector() :
{
    JType jt;
}
{
    
    
    jt = Type()
    
    { return new JVector(jt); }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy