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

org.coode.owlapi.obo12.parser.OBOParser.jj Maven / Gradle / Ivy

There is a newer version: 5.5.1
Show newest version
options {
JAVA_UNICODE_ESCAPE=true;
    STATIC=false;
    // DEBUG_TOKEN_MANAGER=true;
}

PARSER_BEGIN(OBOParser)

package org.coode.owlapi.obo.parser;

import org.semanticweb.owlapi.model.*;
import java.net.*;
import java.util.*;
import org.coode.string.*;

@SuppressWarnings("all")
public class OBOParser {

    private OBOParserHandler handler;

    public void setHandler(OBOParserHandler handler) {
        this.handler = handler;
    }
}

PARSER_END(OBOParser)



/////////////////////////////////////////////////////////////////////////////////

SKIP:
{
    <"\n">
}

SKIP:
{
    <"\r">
}

SKIP:
{
    <"\t">
}

SKIP:
{
    <" ">
}

/////////////////////////////////////////////////////////////////////////////////////

 SKIP :
{
    
}

TOKEN:
{
     : IN_STANZA_HEADER
}

 TOKEN:
{
    
}

 TOKEN:
{
     : DEFAULT
}



TOKEN:
{
     : IN_TAG_VALUE_PAIR
}

 SKIP:
{
     : IN_TAG_VALUE
}


/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
////
////
////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////


 SKIP:
{
     : IN_QUOTED_STRING
}

 TOKEN :
{
    
}

 SKIP :
{
     : IN_TAG_VALUE  // To allow for malformed files - they do exist!
}

 SKIP :
{
     : DEFAULT
}




 TOKEN:
{
    
}


 TOKEN :
{
    
}


 SKIP:
{
     : DEFAULT
}


 SKIP:
{
     : IN_COMMENT
}

 TOKEN:
{
    
}

 SKIP :
{
     : DEFAULT
}




TOKEN:
{
    
}


public void parse() :
{
}
{
    Header()(Stanza())+
}

void Header() :
{
}
{
    {handler.startHeader();}
    ((TagValuePair())*)
    {handler.endHeader();}
}




void Stanza() :
{
    Token t;
}
{


    (t={handler.startFrame(t.image);} (TagValuePair())*)
    {handler.endFrame();}
}


void TagValuePair() :
{
    Token tagToken = null;
    Token valToken = null;
    String qualifierBlock = "";
    String comment = "";
    Token t;
    StringBuilder sb = new StringBuilder();

}
{
    tagToken= ((t={sb.append(t.image);} | t={sb.append(t.image);} | t={sb.append(t.image);}))* (comment=Comment())? {
        String name = tagToken.image.trim();
        String val = sb.toString().trim();
        // This a real mess.  The OBO format allows qualifier blocks at the end of lines.  However, things that look
        // like qualifier blocks can appear in the middle of values for comment tags.
        if(val.endsWith("}")) {
            int qualifierStart = val.lastIndexOf("{");
            if(qualifierStart != -1) {
                qualifierBlock = val.substring(qualifierStart);
                val = val.substring(0, qualifierStart).trim();
            }
        }
        handler.handleTagValue(name, val, qualifierBlock, comment);
    }


}


String Comment() :
{
    Token t;
}
{
     t= {return t.image;}
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy