Package com.dtrules.compiler.el.cup.parser

Examples of com.dtrules.compiler.el.cup.parser.RSymbol


        return "-not found-";
    }
   
   
    public Symbol next_token() throws Exception {
        RSymbol next=null;
       
        if(unget!=null){
            next  = unget;
            unget = null;
        }else{
            try {
              next = new RSymbol(false, scanner.next_token());
              if(next.sym == sym.IDENT){
                  next.leftvalue = "/"+next.value.toString()+" xdef ";
              }
            } catch (Error e) {
              throw new Exception(e);
            }
        }
       
        if(next.sym == sym.RCURLY && lastToken.sym != sym.SEMI){
            lastToken = new RSymbol(false, new Symbol(sym.SEMI));
            unget     = next;
            next      = lastToken;
        }
       
        if(next.sym == sym.NAME &&
              next.value.toString().charAt(0)=='$'){
            next.value = next.value.toString().substring(1);
        }
       
        if(next.value==null){
            if(EOF==false) {
                next.value=";";
                next.sym = sym.SEMI;
                EOF = true;
            }else{   
                next.value="EOF";
                next.sym=sym.EOF;
            }
        }else{
            EOF = false;
        }
       
        // Look for Possessives.
        // Remove the 's from them.  They are in a form:  client's plan's contract
        // What we feed the parser is:  POSSESSIVE client COMMA , POSSESSIVE plan COMMA , ENTITY contract
        if(next.sym==sym.POSSESSIVE){
            String entity = "";
            String ident = next.value.toString();
            ident = ident.replace("'s", "");
            if(ident.indexOf('.')>=0){
                entity=ident.substring(0,ident.indexOf('.'));
                ident =ident.substring(ident.indexOf('.')+1);
            }
            int    theType = identType(ident,entity);
           
            if(theType!= IRObject.iEntity && theType != -1 ){
                throw new RuntimeException("Invalid Possessive. "+ident+" is not an Entity");
            }
           
            if(theType == -1){
                if(localtypes.containsKey(ident.toLowerCase())){
                    RLocalType t = localtypes.get(ident.toLowerCase());
                    theType    = t.type;
                    next.local = true;
                    next.value = t.index +" local@ ";
                }else{
                    throw new RuntimeException("Undefined attribute '"+next.value+"'");
                }
            }else{
                next.value = (entity.length()>0?entity+".":"")+ident;
            }       
            unget = new RSymbol(false, new Symbol(sym.COMMA)); // Inject a comma after every possessive
            unget.value = ",";
           
        }
       
        if(next.sym==sym.IDENT){
            String entity  = "";
            String ident   = next.value.toString();
            if(ident.indexOf('.')>=0){
                entity=ident.substring(0,ident.indexOf('.'));
                ident =ident.substring(ident.indexOf('.')+1);
            }
           
            int    theType = identType(ident,entity);
           
            if(theType == -1 ){
                if(localtypes.containsKey(next.value.toString().toLowerCase())){
                    RLocalType t = localtypes.get(next.value.toString().toLowerCase());
                    theType = t.type;
                    next = new RSymbol(true, next);
                    next.value = t.index +" local@ ";
                    ((RSymbol)next).leftvalue = t.index +" local! ";
                }
            }
           
View Full Code Here


        return "-not found-";
    }
   
   
    public Symbol next_token() throws Exception {
        RSymbol next=null;
       
        if(unget!=null){
            next  = unget;
            unget = null;
        }else{
            try {
              next = new RSymbol(false, scanner.next_token());
              if(next.sym == sym.IDENT){
                  next.leftvalue = "/"+next.value.toString()+" xdef ";
              }
            } catch (Error e) {
              throw new Exception(e);
            }
        }
       
        if(next.sym == sym.RCURLY && lastToken.sym != sym.SEMI){
            lastToken = new RSymbol(false, new Symbol(sym.SEMI));
            unget     = next;
            next      = lastToken;
        }
       
        if(next.sym == sym.NAME &&
              next.value.toString().charAt(0)=='$'){
            next.value = next.value.toString().substring(1);
        }
       
        if(next.value==null){
            if(EOF==false) {
                next.value=";";
                next.sym = sym.SEMI;
                EOF = true;
            }else{   
                next.value="EOF";
                next.sym=sym.EOF;
            }
        }else{
            EOF = false;
        }
       
        // Look for Possessives.
        // Remove the 's from them.  They are in a form:  client's plan's contract
        // What we feed the parser is:  POSSESSIVE client COMMA , POSSESSIVE plan COMMA , ENTITY contract
        if(next.sym==sym.POSSESSIVE){
            String entity = "";
            String ident = next.value.toString();
            ident = ident.replace("'s", "");
            if(ident.indexOf('.')>=0){
                entity=ident.substring(0,ident.indexOf('.'));
                ident =ident.substring(ident.indexOf('.')+1);
            }
            int    theType = identType(ident,entity);
           
            if(theType!= IRObject.iEntity && theType != -1 ){
                throw new RuntimeException("Invalid Possessive. "+ident+" is not an Entity");
            }
           
            if(theType == -1){
                if(localtypes.containsKey(ident.toLowerCase())){
                    RLocalType t = localtypes.get(ident.toLowerCase());
                    theType    = t.type;
                    next.local = true;
                    next.value = t.index +" local@ ";
                }else{
                    throw new RuntimeException("Undefined attribute '"+next.value+"'");
                }
            }else{
                next.value = (entity.length()>0?entity+".":"")+ident;
            }       
            unget = new RSymbol(false, new Symbol(sym.COMMA)); // Inject a comma after every possessive
            unget.value = ",";
           
        }
       
        if(next.sym==sym.IDENT){
            String entity  = "";
            String ident   = next.value.toString();
            if(ident.indexOf('.')>=0){
                entity=ident.substring(0,ident.indexOf('.'));
                ident =ident.substring(ident.indexOf('.')+1);
            }
           
            int    theType = identType(ident,entity);
           
            if(theType == -1 ){
                if(localtypes.containsKey(next.value.toString().toLowerCase())){
                    RLocalType t = localtypes.get(next.value.toString().toLowerCase());
                    theType = t.type;
                    next = new RSymbol(true, next);
                    next.value = t.index +" local@ ";
                    ((RSymbol)next).leftvalue = t.index +" local! ";
                }
            }
           
View Full Code Here

        return "-not found-";
    }
   
   
    public Symbol next_token() throws Exception {
        RSymbol next=null;
       
        if(unget!=null){
            next  = unget;
            unget = null;
        }else{
            try {
              next = new RSymbol(false, scanner.next_token());
              if(next.sym == sym.IDENT){
                  next.leftvalue = "/"+next.value.toString()+" xdef ";
              }
            } catch (Error e) {
              throw new Exception(e);
            }
        }
       
        if(next.sym == sym.RCURLY && lastToken.sym != sym.SEMI){
            lastToken = new RSymbol(false, new Symbol(sym.SEMI));
            unget     = next;
            next      = lastToken;
        }
       
        if(next.sym == sym.NAME &&
              next.value.toString().charAt(0)=='$'){
            next.value = next.value.toString().substring(1);
        }
       
        if(next.value==null){
            if(EOF==false) {
                next.value=";";
                next.sym = sym.SEMI;
                EOF = true;
            }else{   
                next.value="EOF";
                next.sym=sym.EOF;
            }
        }else{
            EOF = false;
        }
       
        // Look for Possessives.
        // Remove the 's from them.  They are in a form:  client's plan's contract
        // What we feed the parser is:  POSSESSIVE client COMMA , POSSESSIVE plan COMMA , ENTITY contract
        if(next.sym==sym.POSSESSIVE){
            String entity = "";
            String ident = next.value.toString();
            ident = ident.replace("'s", "");
            if(ident.indexOf('.')>=0){
                entity=ident.substring(0,ident.indexOf('.'));
                ident =ident.substring(ident.indexOf('.')+1);
            }
            int    theType = identType(ident,entity);
           
            if(theType!= IRObject.iEntity && theType != -1 ){
                throw new RuntimeException("Invalid Possessive. "+ident+" is not an Entity");
            }
           
            if(theType == -1){
                if(localtypes.containsKey(ident.toLowerCase())){
                    RLocalType t = localtypes.get(ident.toLowerCase());
                    theType    = t.type;
                    next.local = true;
                    next.value = t.index +" local@ ";
                }else{
                    throw new RuntimeException("Undefined attribute '"+next.value+"'");
                }
            }else{
                next.value = (entity.length()>0?entity+".":"")+ident;
            }       
            unget = new RSymbol(false, new Symbol(sym.COMMA)); // Inject a comma after every possessive
            unget.value = ",";
           
        }
       
        if(next.sym==sym.IDENT){
            String entity  = "";
            String ident   = next.value.toString();
            if(ident.indexOf('.')>=0){
                entity=ident.substring(0,ident.indexOf('.'));
                ident =ident.substring(ident.indexOf('.')+1);
            }
            int    theType = identType(ident,entity);
           
            if(theType == -1 ){
                if(localtypes.containsKey(next.value.toString().toLowerCase())){
                    RLocalType t = localtypes.get(next.value.toString().toLowerCase());
                    theType = t.type;
                    next = new RSymbol(true, next);
                    next.value = t.index +" local@ ";
                    ((RSymbol)next).leftvalue = t.index +" local! ";
                }
            }
           
View Full Code Here

TOP

Related Classes of com.dtrules.compiler.el.cup.parser.RSymbol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.