http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/scfb/SCFbParser.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/scfb/SCFbParser.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/scfb/SCFbParser.java new file mode 100644 index 0000000..ec055f9 --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/scfb/SCFbParser.java @@ -0,0 +1,580 @@ +/* +* +* 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.airavata.datacat.parsers.gridchem.scfb; + + +import java_cup.runtime.lr_parser; +import org.apache.airavata.datacat.parsers.gridchem.GridChemQueueParser; + +import javax.swing.*; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.HashMap; + +public class SCFbParser extends java_cup.runtime.lr_parser implements GridChemQueueParser{ + + /** Default constructor. */ + public SCFbParser() {super();} + + /** Constructor which sets the default scanner. */ + public SCFbParser(java_cup.runtime.Scanner s) {super(s);} + + /** + * Constructor which uses a file reader. + */ + public SCFbParser(final FileReader fileReader) { + super(new SCFbLexer(fileReader)); + } + + + /** Production table. */ + protected static final short _production_table[][] = + lr_parser.unpackFromStrings(new String[]{ + "\000\016\000\002\015\002\000\002\003\006\000\002\002" + + "\004\000\002\016\002\000\002\004\006\000\002\017\002" + + "\000\002\020\002\000\002\021\002\000\002\022\002\000" + + "\002\023\002\000\002\024\002\000\002\025\002\000\002" + + "\026\002\000\002\014\043"}); + + /** Access to production table. */ + public short[][] production_table() {return _production_table;} + + /** Parse-action table. */ + protected static final short[][] _action_table = + lr_parser.unpackFromStrings(new String[]{ + "\000\054\000\004\004\006\001\002\000\004\033\014\001" + + "\002\000\004\002\012\001\002\000\004\005\ufffe\001\002" + + "\000\004\005\010\001\002\000\004\050\011\001\002\000" + + "\004\033\ufffd\001\002\000\004\002\uffff\001\002\000\004" + + "\046\001\001\002\000\004\034\ufffc\001\002\000\004\034" + + "\016\001\002\000\004\044\017\001\002\000\004\051\020" + + "\001\002\000\004\040\ufffb\001\002\000\004\040\022\001" + + "\002\000\004\047\023\001\002\000\004\045\024\001\002" + + "\000\004\035\ufffa\001\002\000\004\035\026\001\002\000" + + "\004\044\027\001\002\000\004\051\030\001\002\000\004" + + "\037\ufff9\001\002\000\004\037\032\001\002\000\004\044" + + "\033\001\002\000\004\051\034\001\002\000\004\036\ufff8" + + "\001\002\000\004\036\036\001\002\000\004\044\037\001" + + "\002\000\004\051\040\001\002\000\004\041\ufff7\001\002" + + "\000\004\041\042\001\002\000\004\044\043\001\002\000" + + "\004\051\044\001\002\000\004\042\ufff6\001\002\000\004" + + "\042\046\001\002\000\004\044\047\001\002\000\004\051" + + "\050\001\002\000\004\043\ufff5\001\002\000\004\043\052" + + "\001\002\000\004\044\053\001\002\000\004\051\054\001" + + "\002\000\004\046\ufff4\001\002\000\004\046\056\001\002" + + "\000\004\002\000\001\002"}); + + /** Access to parse-action table. */ + public short[][] action_table() {return _action_table;} + + /** <code>reduce_goto</code> table. */ + protected static final short[][] _reduce_table = + lr_parser.unpackFromStrings(new String[]{ + "\000\054\000\006\003\004\004\003\001\001\000\004\014" + + "\012\001\001\000\002\001\001\000\004\016\006\001\001" + + "\000\002\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\004\015\054\001\001\000\004\017\014" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\004\020\020\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001\000\004\021\024\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\004" + + "\022\030\001\001\000\002\001\001\000\002\001\001\000" + + "\002\001\001\000\004\023\034\001\001\000\002\001\001" + + "\000\002\001\001\000\002\001\001\000\004\024\040\001" + + "\001\000\002\001\001\000\002\001\001\000\002\001\001" + + "\000\004\025\044\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\004\026\050\001\001\000\002" + + "\001\001\000\002\001\001\000\002\001\001\000\002\001" + + "\001\000\002\001\001\000\002\001\001"}); + + /** Access to <code>reduce_goto</code> table. */ + public short[][] reduce_table() {return _reduce_table;} + + /** Instance of action encapsulation class. */ + protected CUP$parser$actions action_obj; + + private ArrayList<String> result = new ArrayList<String>(); + private String tempStr = ""; + + + + public ArrayList<String> getResult() { + return result; + } + + public void addToResult(String value) { + result.add(value); + } + + + public String getTempStr() { + return tempStr; + } + + public void setTempStr(String s) { + this.tempStr = s; + } + + + /*Adding the parsed data to the hash map */ + @Override + public HashMap<String, String> getParsedData() throws Exception { + parse(); + HashMap<String,String> results= new HashMap<String,String>(); + int eeCount=0; + int peCount=0; + int keCount=0; + int s2Count=0; + int minUSVTCount=0; + int convgCount=0; + int auCount=0; + int erhfCount=0; + int lenxCount=0; + for(int i=0;i<result.size();i++){ + String singleString = result.get(i); + String[] temp= singleString.split(" "); + if(temp.length>1){ + String keyString= temp[0]; + String dataString=temp[1]; + if(keyString.equalsIgnoreCase("EE")){ + results.put("SCFbParser_EE_"+eeCount,dataString); + eeCount++; + }else if(keyString.equalsIgnoreCase("PE")){ + results.put("SCFbParser_PE_"+peCount,dataString); + peCount++; + }else if(keyString.equalsIgnoreCase("KE")){ + results.put("SCFbParser_KE_"+keCount,dataString); + keCount++; + }else if(keyString.equalsIgnoreCase("S2")) { + results.put("SCFbParser_S2_" + s2Count, dataString); + s2Count++; + }else if(keyString.equalsIgnoreCase("MINUSVT")) { + results.put("SCFbParser_MINUSVT_" + minUSVTCount, dataString); + minUSVTCount++; + }else if(keyString.equalsIgnoreCase("CONVG")) { + results.put("SCFbParser_CONVG_" + convgCount, dataString); + convgCount++; + }else if(keyString.equalsIgnoreCase("AU")) { + results.put("SCFbParser_AU_" + auCount, dataString); + auCount++; + }else if(keyString.equalsIgnoreCase("ERHF")) { + results.put("SCFbParser_ERHF_" + erhfCount, dataString); + erhfCount++; + }else if(keyString.equalsIgnoreCase("LENX")) { + results.put("SCFbParser_LENX_" + lenxCount, dataString); + lenxCount++; + } + + + } + + } + return results; + } + + /** Action encapsulation object initializer. */ + protected void init_actions() + { + action_obj = new CUP$parser$actions(this); + } + + /** Invoke a user supplied parse action. */ + public java_cup.runtime.Symbol do_action( + int act_num, + java_cup.runtime.lr_parser parser, + java.util.Stack stack, + int top) + throws java.lang.Exception + { + /* call code in generated class */ + return action_obj.CUP$parser$do_action(act_num, parser, stack, top); + } + + /** Indicates start state. */ + public int start_state() {return 0;} + /** Indicates start production. */ + public int start_production() {return 2;} + + /** <code>EOF</code> Symbol index. */ + public int EOF_sym() {return 0;} + + /** <code>error</code> Symbol index. */ + public int error_sym() {return 1;} + +} + +/** Cup generated class to encapsulate user supplied action code.*/ +class CUP$parser$actions { + + + //__________________________________ + public static boolean DEBUG = true; + private static JTable table; + private static final String tableLabel = "SCF Final Results:"; + + public static JTable getTable() { + return table; + } + + public static String getTableLabel() { + return tableLabel; + } + + private final SCFbParser SCFbParser; + + /** Constructor */ + CUP$parser$actions(SCFbParser SCFbParser) { + this.SCFbParser = SCFbParser; + } + + /** Method with the actual generated action code. */ + public final java_cup.runtime.Symbol CUP$parser$do_action( + int CUP$parser$act_num, + java_cup.runtime.lr_parser CUP$parser$parser, + java.util.Stack CUP$parser$stack, + int CUP$parser$top) + throws java.lang.Exception + { + /* Symbol object for return from actions */ + java_cup.runtime.Symbol CUP$parser$result; + + /* select the action based on the action number */ + switch (CUP$parser$act_num) + { + /*. . . . . . . . . . . . . . . . . . . .*/ + case 13: // scffinal ::= SCFDONE NT$2 ERHF EQUALS FLOAT NT$3 AU INT DUMMY NT$4 CONVG EQUALS FLOAT NT$5 MINUSVT EQUALS FLOAT NT$6 S2 EQUALS FLOAT NT$7 KE EQUALS FLOAT NT$8 PE EQUALS FLOAT NT$9 EE EQUALS FLOAT + { + Object RESULT = null; + // propagate RESULT from NT$2 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-31)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-31)).value; + // propagate RESULT from NT$3 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-27)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-27)).value; + // propagate RESULT from NT$4 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-23)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-23)).value; + // propagate RESULT from NT$5 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-19)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-19)).value; + // propagate RESULT from NT$6 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-15)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-15)).value; + // propagate RESULT from NT$7 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-11)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-11)).value; + // propagate RESULT from NT$8 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-7)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-7)).value; + // propagate RESULT from NT$9 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-28)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-28)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-28)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-25)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-25)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-25)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-20)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-20)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-20)).value; + int mleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-16)).left; + int mright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-16)).right; + String m = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-16)).value; + int s2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)).left; + int s2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)).right; + String s2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-12)).value; + int keleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).left; + int keright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).right; + String ke = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-8)).value; + int peleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int peright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String pe = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int eeleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int eeright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + String ee = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //____________________________________________________ +if (DEBUG) System.out.println("CUP:scfb: EE "+ee); +SCFbParser.addToResult("EE "+ee); +//parseSCF.putField("EE", ee); + + CUP$parser$result = new java_cup.runtime.Symbol(10/*scffinal*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-32)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 12: // NT$9 ::= + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-24)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-24)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-24)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-21)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-21)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-21)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-16)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-16)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-16)).value; + int mleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)).left; + int mright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)).right; + String m = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-12)).value; + int s2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).left; + int s2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).right; + String s2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-8)).value; + int keleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int keright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String ke = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int peleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int peright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + String pe = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //____________________________________________________ +if (DEBUG) System.out.println("CUP:scfb: PE "+pe); +SCFbParser.addToResult("PE "+pe); +//parseSCF.putField("PE", pe); + + CUP$parser$result = new java_cup.runtime.Symbol(20/*NT$9*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 11: // NT$8 ::= + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-20)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-20)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-20)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-17)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-17)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-17)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-12)).value; + int mleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).left; + int mright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).right; + String m = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-8)).value; + int s2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int s2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String s2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int keleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int keright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + String ke = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //____________________________________________________ +if (DEBUG) System.out.println("CUP:scfb: KE "+ke); +SCFbParser.addToResult("KE "+ke); +//parseSCF.putField("KE", ke); + + CUP$parser$result = new java_cup.runtime.Symbol(19/*NT$8*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 10: // NT$7 ::= + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-16)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-16)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-16)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-13)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-13)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-13)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-8)).value; + int mleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int mright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String m = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int s2left = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int s2right = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + String s2 = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //____________________________________________________ +if (DEBUG) System.out.println("CUP:scfb: S2 "+s2); +SCFbParser.addToResult("S2 "+s2); +//parseSCF.putField("S2", s2); + + CUP$parser$result = new java_cup.runtime.Symbol(18/*NT$7*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 9: // NT$6 ::= + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-12)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-12)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-9)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-9)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-9)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int mleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int mright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + String m = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //________________________________________________________ +if (DEBUG) System.out.println("CUP:scfb: MINUSVT "+m); +SCFbParser.addToResult("MINUSVT "+m); +//parseSCF.putField("-V/T", m); + + CUP$parser$result = new java_cup.runtime.Symbol(17/*NT$6*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 8: // NT$5 ::= + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-8)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-8)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-5)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-5)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + String c = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //______________________________________________________ +if (DEBUG) System.out.println("CUP:scfb: CONVG "+c); +SCFbParser.addToResult("CONVG "+c); +//parseSCF.putField("CONVG", c); + + CUP$parser$result = new java_cup.runtime.Symbol(16/*NT$5*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 7: // NT$4 ::= + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-4)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + //___________________________________________________ +if (DEBUG) System.out.println("CUP:scfb: AU "+i); + SCFbParser.addToResult("AU "+i); +//parseSCF.putField("AU", i); + + CUP$parser$result = new java_cup.runtime.Symbol(15/*NT$4*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 6: // NT$3 ::= + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + String e = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //_____________________________________________________ +if (DEBUG) System.out.println("CUP:scfb: ERHF "+e); + SCFbParser.addToResult("ERHF "+e); +//parseSCF.putField("E(RHF)", e); + + CUP$parser$result = new java_cup.runtime.Symbol(14/*NT$3*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // NT$2 ::= + { + Object RESULT = null; + if (DEBUG) System.out.println("CUP:scfb: scfdone "); + CUP$parser$result = new java_cup.runtime.Symbol(13/*NT$2*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // scfintro ::= FOUNDSCF NT$1 FOUNDLENX LENXINT + { + Object RESULT = null; + // propagate RESULT from NT$1 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int ileft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int iright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + String i = (String)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + if (DEBUG) System.out.println("CUP:scfb: LENX --> "+i); + SCFbParser.addToResult("LENX "+i); + + CUP$parser$result = new java_cup.runtime.Symbol(2/*scfintro*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 3: // NT$1 ::= + { + Object RESULT = null; + if (DEBUG) System.out.println("CUP:scfb: found SCF"); + CUP$parser$result = new java_cup.runtime.Symbol(12/*NT$1*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 2: // $START ::= startpt EOF + { + Object RESULT = null; + int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = start_val; + CUP$parser$result = new java_cup.runtime.Symbol(0/*$START*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + /* ACCEPT */ + CUP$parser$parser.done_parsing(); + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 1: // startpt ::= scfintro scffinal NT$0 LEAVE + { + Object RESULT = null; + // propagate RESULT from NT$0 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + if (DEBUG) System.out.println("CUP:scfb: found LEAVE"); + + CUP$parser$result = new java_cup.runtime.Symbol(1/*startpt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 0: // NT$0 ::= + { + Object RESULT = null; + if (DEBUG) System.out.println("CUP:scfa: found scfintro scffinal"); + table = new JTable(); + // table = parseSCF.getTable(); + + CUP$parser$result = new java_cup.runtime.Symbol(11/*NT$0*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /* . . . . . .*/ + default: + throw new Exception( + "Invalid action number found in internal parse table"); + + } + } +} +
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/scfb/SCFbSym.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/scfb/SCFbSym.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/scfb/SCFbSym.java new file mode 100644 index 0000000..ba1693f --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/scfb/SCFbSym.java @@ -0,0 +1,71 @@ +/* +* +* 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.airavata.datacat.parsers.gridchem.scfb; +//---------------------------------------------------- +// The following code was generated by CUP v0.10k +// Mon Sep 15 16:04:59 IST 2014 +//---------------------------------------------------- + +/** CUP generated class containing symbol constants. */ +public class SCFbSym { + /* terminals */ + public static final int TEE = 12; + public static final int EQUALS = 34; + public static final int PE = 32; + public static final int GTEF = 20; + public static final int INT = 37; + public static final int LEAVE = 36; + public static final int LTEF = 19; + public static final int SCFDONE = 25; + public static final int CONVG = 27; + public static final int DUMMY = 35; + public static final int IS = 15; + public static final int PASS = 5; + public static final int ERR = 21; + public static final int MAXDP = 23; + public static final int S2 = 28; + public static final int ATCYCLE = 10; + public static final int IE = 16; + public static final int EOF = 0; + public static final int COEFF = 11; + public static final int RMSDP = 22; + public static final int IDIAG = 6; + public static final int error = 1; + public static final int ERHF = 26; + public static final int NO09 = 17; + public static final int FOUNDLENX = 3; + public static final int COLON = 24; + public static final int GAP = 13; + public static final int DELTAE = 8; + public static final int NK = 14; + public static final int EE = 33; + public static final int DIIS = 9; + public static final int LENXINT = 38; + public static final int FLOAT = 39; + public static final int KE = 31; + public static final int MINUSVT = 29; + public static final int NV01 = 18; + public static final int AU = 30; + public static final int FOUNDSCF = 2; + public static final int CYCLE = 4; + public static final int ENERGY = 7; +} + http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/AccessLevels.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/AccessLevels.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/AccessLevels.java new file mode 100644 index 0000000..f08cb5d --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/AccessLevels.java @@ -0,0 +1,28 @@ +/* +* +* 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.airavata.datacat.parsers.gridchem.util; + +public class AccessLevels { + public static final String PRIVATE = "private"; + public static final String GROUP = "group"; + public static final String COMMUNITY = "community"; + public static final String GLOBAL = "global"; +} http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/Constants.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/Constants.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/Constants.java new file mode 100644 index 0000000..2f0fc0a --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/Constants.java @@ -0,0 +1,39 @@ +/* +* +* 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.airavata.datacat.parsers.gridchem.util; + +public class Constants { + public static final String PARSER_SEQUENCE = "PARSER_SEQUENCE"; + + public static final String ARCHIVING_NODE = "ARCHIVING_NODE"; + + public static final String APPLICATION_NAME = "APPLICATION_NAME"; + + public static final String USERNAME = "USERNAME"; + + public static final String AGENT_USERNAME = "AGENT_USERNAME"; + + public static final String AGENT_PASSWORD = "AGENT_PASSWORD"; + + public static final String TMP_DIR = "TMP_DIR"; + + public static final String SAMPLE_OUTPUT = "SAMPLE_OUTPUT"; +} http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/Fields.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/Fields.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/Fields.java new file mode 100644 index 0000000..01d93f7 --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/Fields.java @@ -0,0 +1,26 @@ +/* +* +* 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.airavata.datacat.parsers.gridchem.util; + +public class Fields { + public static final String INCHI = "inchi"; + public static final String INCHI_KEY = "inchi_key"; +} http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/GridChemProperties.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/GridChemProperties.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/GridChemProperties.java new file mode 100644 index 0000000..6d2b29f --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/util/GridChemProperties.java @@ -0,0 +1,77 @@ +/* +* +* 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.airavata.datacat.parsers.gridchem.util; + +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; + +import java.io.*; + +public class GridChemProperties { + public static final String GRIDCHEM_PARSERS_PROPERTIES = "../conf/gridchem.properties"; + public static final String DEFAULT_GRIDCHEM_PARSERS_PROPERTIES = "gridchem.properties"; + + private static GridChemProperties instance; + + private final Logger logger = LogManager.getLogger(GridChemProperties.class); + private java.util.Properties properties = null; + + private GridChemProperties() { + try { + InputStream fileInput; + if (new File(GRIDCHEM_PARSERS_PROPERTIES).exists()) { + fileInput = new FileInputStream(GRIDCHEM_PARSERS_PROPERTIES); + } else { + fileInput = ClassLoader.getSystemResource(DEFAULT_GRIDCHEM_PARSERS_PROPERTIES).openStream(); + } + java.util.Properties properties = new java.util.Properties(); + properties.load(fileInput); + fileInput.close(); + this.properties = properties; + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static GridChemProperties getInstance() { + if (instance == null) { + instance = new GridChemProperties(); + } + return instance; + } + + public String[] getParserSequence() { + String parsers = getProperty(Constants.PARSER_SEQUENCE, ""); + String[] parserArray = parsers.split(","); + return parserArray; + } + public String getProperty(String key, String defaultVal) { + String val = this.properties.getProperty(key); + + if (val.isEmpty() || val == "") { + return defaultVal; + } else { + return val; + } + } +} http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramLexer.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramLexer.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramLexer.java new file mode 100644 index 0000000..10d93b7 --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramLexer.java @@ -0,0 +1,642 @@ +package org.apache.airavata.datacat.parsers.gridchem.whichProgram;/* The following code was generated by JFlex 1.4.3 on 11/12/14 6:52 PM */ + + +/* +* +* 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. +* +*/ +import java_cup.runtime.Symbol; +import org.apache.airavata.datacat.parsers.gridchem.Settings; + +/** + * This class is a scanner generated by + * <a href="http://www.jflex.de/">JFlex</a> 1.4.3 + * on 11/12/14 6:52 PM from the specification file + * <tt>whichProgram.flex</tt> + */ +public class WhichProgramLexer implements java_cup.runtime.Scanner{ + + /** This character denotes the end of file */ + public static final int YYEOF = -1; + + /** initial size of the lookahead buffer */ + private static final int ZZ_BUFFERSIZE = 16384; + + /** lexical states */ + public static final int IGNOREALL = 6; + public static final int GETREVISION = 2; + public static final int YYINITIAL = 0; + public static final int GETVERSION = 4; + + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l + * at the beginning of a line + * l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1, 2, 2, 3, 3 + }; + + /** + * Translates characters to character classes + */ + private static final char [] ZZ_CMAP = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 1, 0, + 10, 2, 2, 11, 2, 2, 2, 2, 2, 2, 0, 0, 0, 22, 0, 0, + 0, 13, 1, 1, 1, 15, 1, 3, 1, 19, 1, 1, 26, 14, 21, 20, + 23, 1, 18, 16, 25, 1, 17, 1, 1, 24, 1, 0, 0, 0, 0, 0, + 0, 4, 1, 1, 1, 1, 1, 1, 1, 7, 1, 1, 1, 1, 8, 1, + 1, 1, 1, 6, 1, 5, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + + /** + * Translates DFA states to action switch labels. + */ + private static final int [] ZZ_ACTION = zzUnpackAction(); + + private static final String ZZ_ACTION_PACKED_0 = + "\4\0\3\1\1\2\1\1\13\0\1\3\25\0\1\4"+ + "\10\0\1\5\5\0\1\6"; + + private static int [] zzUnpackAction() { + int [] result = new int[58]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /** + * Translates a state to a row index in the transition table + */ + private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); + + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\33\0\66\0\121\0\154\0\207\0\242\0\275"+ + "\0\330\0\363\0\u010e\0\u0129\0\u0144\0\u015f\0\u017a\0\u0195"+ + "\0\u01b0\0\u01cb\0\u01e6\0\u0201\0\154\0\u021c\0\u0237\0\u0252"+ + "\0\u026d\0\u0288\0\u02a3\0\u02be\0\u02d9\0\u02f4\0\u030f\0\u032a"+ + "\0\u0345\0\u0360\0\u037b\0\u0396\0\u03b1\0\u03cc\0\u03e7\0\u0402"+ + "\0\u041d\0\u0438\0\154\0\u0453\0\u046e\0\u0489\0\u04a4\0\u04bf"+ + "\0\u04da\0\u04f5\0\u0510\0\154\0\u052b\0\u0546\0\u0561\0\u057c"+ + "\0\u0597\0\154"; + + private static int [] zzUnpackRowMap() { + int [] result = new int[58]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + + /** + * The transition table of the DFA + */ + private static final int [] ZZ_TRANS = zzUnpackTrans(); + + private static final String ZZ_TRANS_PACKED_0 = + "\3\5\1\6\23\5\1\7\4\5\10\10\1\5\2\10"+ + "\1\5\11\10\1\5\4\10\2\5\1\11\7\5\2\11"+ + "\52\5\37\0\1\12\10\0\1\13\37\0\1\14\11\0"+ + "\10\10\1\0\2\10\1\0\11\10\1\0\4\10\2\0"+ + "\1\15\7\0\2\15\24\0\1\16\43\0\1\17\40\0"+ + "\1\20\10\0\1\21\7\0\2\21\25\0\1\22\43\0"+ + "\1\23\16\0\1\24\31\0\1\25\7\0\2\25\25\0"+ + "\1\26\44\0\1\27\34\0\1\30\17\0\1\31\43\0"+ + "\1\32\27\0\1\33\21\0\1\34\37\0\1\35\37\0"+ + "\1\36\24\0\1\37\43\0\1\40\22\0\1\41\32\0"+ + "\1\42\40\0\1\43\33\0\1\44\24\0\1\45\42\0"+ + "\1\46\40\0\1\47\15\0\1\50\37\0\1\51\32\0"+ + "\1\52\26\0\1\53\41\0\1\54\40\0\1\55\25\0"+ + "\1\56\25\0\1\57\40\0\1\60\23\0\1\61\25\0"+ + "\1\62\32\0\1\63\47\0\1\64\22\0\1\65\40\0"+ + "\1\66\40\0\1\67\27\0\1\70\25\0\1\71\34\0"+ + "\1\72\6\0"; + + private static int [] zzUnpackTrans() { + int [] result = new int[1458]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do result[j++] = value; while (--count > 0); + } + return j; + } + + + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code> + */ + private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); + + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\4\0\1\11\4\1\13\0\1\11\25\0\1\11\10\0"+ + "\1\11\5\0\1\11"; + + private static int [] zzUnpackAttribute() { + int [] result = new int[58]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int [] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do result[j++] = value; while (--count > 0); + } + return j; + } + + /** the input device */ + private java.io.Reader zzReader; + + /** the current state of the DFA */ + private int zzState; + + /** the current lexical state */ + private int zzLexicalState = YYINITIAL; + + /** this buffer contains the current text to be matched and is + the source of the yytext() string */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + + /** the textposition at the last accepting state */ + private int zzMarkedPos; + + /** the current text position in the buffer */ + private int zzCurrentPos; + + /** startRead marks the beginning of the yytext() string in the buffer */ + private int zzStartRead; + + /** endRead marks the last character in the buffer, that has been read + from input */ + private int zzEndRead; + + /** number of newlines encountered up to the start of the matched text */ + private int yyline; + + /** the number of characters up to the start of the matched text */ + private int yychar; + + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + + /** zzAtEOF == true <=> the scanner is at the EOF */ + private boolean zzAtEOF; + + /** denotes if the user-EOF-code has already been executed */ + private boolean zzEOFDone; + + /* user code: */ + public static boolean DEBUG = false; + public static String format; + + + /** + * Creates a new scanner + * There is also a java.io.InputStream version of this constructor. + * + * @param in the java.io.Reader to read input from. + */ + public WhichProgramLexer(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. + * There is also java.io.Reader version of this constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public WhichProgramLexer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + + /** + * Refills the input buffer. + * + * @return <code>false</code>, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead-zzStartRead); + + /* translate stored positions */ + zzEndRead-= zzStartRead; + zzCurrentPos-= zzStartRead; + zzMarkedPos-= zzStartRead; + zzStartRead = 0; + } + + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos*2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } + + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length-zzEndRead); + + if (numRead > 0) { + zzEndRead+= numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } + + // numRead < 0 + return true; + } + + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) + zzReader.close(); + } + + + /** + * Resets the scanner to read from a new input stream. + * Does not close the old reader. + * + * All internal variables are reset, the old input stream + * <b>cannot</b> be reused (internal buffer is discarded and lost). + * Lexical state is set to <tt>ZZ_INITIAL</tt>. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); + } + + + /** + * Returns the character at position <tt>pos</tt> from the + * matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. + * A value from 0 to yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead+pos]; + } + + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos-zzStartRead; + } + + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of + * yypushback(int) and a match-all fallback rule) this method + * will only be called with things that "Can't Possibly Happen". + * If this method is called, something is seriously wrong + * (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done + * in error fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } + catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. + * This number must not be greater than yylength()! + */ + public void yypushback(int number) { + if ( number > yylength() ) + zzScanError(ZZ_PUSHBACK_2BIG); + + zzMarkedPos -= number; + } + + + /** + * Resumes scanning until the next regular expression is matched, + * the end of input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public int yylex() throws java.io.IOException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char [] zzBufferL = zzBuffer; + char [] zzCMapL = ZZ_CMAP; + + int [] zzTransL = ZZ_TRANS; + int [] zzRowMapL = ZZ_ROWMAP; + int [] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + + zzForAction: { + while (true) { + + if (zzCurrentPosL < zzEndReadL) + zzInput = zzBufferL[zzCurrentPosL++]; + else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } + else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } + else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; + if (zzNext == -1) break zzForAction; + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ( (zzAttributes & 1) == 1 ) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ( (zzAttributes & 8) == 8 ) break zzForAction; + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 2: + { if (Settings.DEBUG) System.out.println(yytext()); + yybegin(IGNOREALL); + } + case 7: break; + case 3: + { if (Settings.DEBUG) System.out.println(yytext()); + yybegin(IGNOREALL); + } + case 8: break; + case 4: + { if (Settings.DEBUG) System.out.println(yytext()); + WhichProgramLexer.format = "Gauss03"; + } + case 9: break; + case 6: + { System.out.println(yytext()); + WhichProgramLexer.format = "Molpro"; + yybegin(IGNOREALL); + } + case 10: break; + case 5: + { if (Settings.DEBUG) System.out.println(yytext()); + WhichProgramLexer.format = "GAMESS"; + yybegin(GETVERSION); + } + case 11: break; + case 1: + { + } + case 12: break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + return YYEOF; + } + else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + + /** + * Runs the scanner on input files. + * + * This is a standalone scanner, it will print any unmatched + * text to System.out unchanged. + * + * @param argv the command line, contains the filenames to run + * the scanner on. + */ + public static void main(String argv[]) { + if (argv.length == 0) { + System.out.println("Usage : java WhichProgram <inputfile>"); + } + else { + for (int i = 0; i < argv.length; i++) { + WhichProgramLexer scanner = null; + try { + scanner = new WhichProgramLexer( new java.io.FileReader(argv[i]) ); + while ( !scanner.zzAtEOF ) scanner.yylex(); + } + catch (java.io.FileNotFoundException e) { + System.out.println("File not found : \""+argv[i]+"\""); + } + catch (java.io.IOException e) { + System.out.println("IO error scanning file \""+argv[i]+"\""); + System.out.println(e); + } + catch (Exception e) { + System.out.println("Unexpected exception:"); + e.printStackTrace(); + } + } + } + } + + + @Override + public Symbol next_token() throws Exception { + return null; + } +} http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramParser.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramParser.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramParser.java new file mode 100644 index 0000000..a929b4a --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramParser.java @@ -0,0 +1,306 @@ +/* +* +* 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.airavata.datacat.parsers.gridchem.whichProgram; + +import java_cup.runtime.lr_parser; + +import javax.swing.*; + + +public class WhichProgramParser extends java_cup.runtime.lr_parser { + + /** Default constructor. */ + public WhichProgramParser() {super();} + + /** Constructor which sets the default scanner. */ + public WhichProgramParser(java_cup.runtime.Scanner s) {super(s);} + + /** Production table. */ + protected static final short _production_table[][] = + lr_parser.unpackFromStrings(new String[]{ + "\000\013\000\002\003\005\000\002\002\004\000\002\004" + + "\003\000\002\005\004\000\002\005\003\000\002\012\002" + + "\000\002\006\006\000\002\013\002\000\002\007\007\000" + + "\002\010\004\000\002\011\004"}); + + /** Access to production table. */ + public short[][] production_table() {return _production_table;} + + /** Parse-action table. */ + protected static final short[][] _action_table = + lr_parser.unpackFromStrings(new String[]{ + "\000\026\000\004\004\005\001\002\000\004\007\011\001" + + "\002\000\004\007\uffff\001\002\000\004\002\007\001\002" + + "\000\004\002\000\001\002\000\006\005\027\007\011\001" + + "\002\000\004\013\013\001\002\000\006\005\ufffd\007\ufffd" + + "\001\002\000\004\006\ufffc\001\002\000\004\006\015\001" + + "\002\000\004\012\017\001\002\000\006\005\ufffb\007\ufffb" + + "\001\002\000\004\010\ufffa\001\002\000\004\010\021\001" + + "\002\000\004\014\026\001\002\000\004\011\024\001\002" + + "\000\006\005\ufff9\007\ufff9\001\002\000\004\015\025\001" + + "\002\000\006\005\ufff7\007\ufff7\001\002\000\004\011\ufff8" + + "\001\002\000\004\002\001\001\002\000\006\005\ufffe\007" + + "\ufffe\001\002"}); + + /** Access to parse-action table. */ + public short[][] action_table() {return _action_table;} + + /** <code>reduce_goto</code> table. */ + protected static final short[][] _reduce_table = + lr_parser.unpackFromStrings(new String[]{ + "\000\026\000\006\003\005\004\003\001\001\000\006\005" + + "\007\006\011\001\001\000\002\001\001\000\002\001\001" + + "\000\002\001\001\000\004\006\027\001\001\000\002\001" + + "\001\000\002\001\001\000\004\012\013\001\001\000\004" + + "\007\015\001\001\000\002\001\001\000\002\001\001\000" + + "\004\013\017\001\001\000\004\010\021\001\001\000\002" + + "\001\001\000\004\011\022\001\001\000\002\001\001\000" + + "\002\001\001\000\002\001\001\000\002\001\001\000\002" + + "\001\001\000\002\001\001"}); + + /** Access to <code>reduce_goto</code> table. */ + public short[][] reduce_table() {return _reduce_table;} + + /** Instance of action encapsulation class. */ + protected CUP$parser$actions action_obj; + + /** Action encapsulation object initializer. */ + protected void init_actions() + { + action_obj = new CUP$parser$actions(this); + } + + /** Invoke a user supplied parse action. */ + public java_cup.runtime.Symbol do_action( + int act_num, + java_cup.runtime.lr_parser parser, + java.util.Stack stack, + int top) + throws java.lang.Exception + { + /* call code in generated class */ + return action_obj.CUP$parser$do_action(act_num, parser, stack, top); + } + + /** Indicates start state. */ + public int start_state() {return 0;} + /** Indicates start production. */ + public int start_production() {return 1;} + + /** <code>EOF</code> Symbol index. */ + public int EOF_sym() {return 0;} + + /** <code>error</code> Symbol index. */ + public int error_sym() {return 1;} + +} + +/** Cup generated class to encapsulate user supplied action code.*/ +class CUP$parser$actions { + + + //__________________________________ + public static boolean DEBUG = true; + private static JTable table; + private static final String tableLabel = "SCF Intermediate Results:"; +// private static String cycle = "0"; + + + public static JTable getTable() { + return table; + } + + public static String getTableLabel() { + return tableLabel; + } + +// } + + private final WhichProgramParser parser; + + /** Constructor */ + CUP$parser$actions(WhichProgramParser WhichProgramParser) { + this.parser = WhichProgramParser; + } + + /** Method with the actual generated action code. */ + public final java_cup.runtime.Symbol CUP$parser$do_action( + int CUP$parser$act_num, + java_cup.runtime.lr_parser CUP$parser$parser, + java.util.Stack CUP$parser$stack, + int CUP$parser$top) + throws java.lang.Exception + { + /* Symbol object for return from actions */ + java_cup.runtime.Symbol CUP$parser$result; + + /* select the action based on the action number */ + switch (CUP$parser$act_num) + { + /*. . . . . . . . . . . . . . . . . . . .*/ + case 10: // grad2 ::= RmsGrad RGRAD + { + Object RESULT = null; + int rgleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int rgright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + Float rg = (Float)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:gopt: RMS Force "+rg); + + CUP$parser$result = new java_cup.runtime.Symbol(7/*grad2*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 9: // grad1 ::= MaxGrad MGRAD + { + Object RESULT = null; + int mgleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int mgright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + Float mg = (Float)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:gopt: Maximum Force "+mg); + + CUP$parser$result = new java_cup.runtime.Symbol(6/*grad1*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 8: // cycle ::= NSearch ITERATION NT$1 grad1 grad2 + { + Object RESULT = null; + // propagate RESULT from NT$1 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).right; + Integer c = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-3)).value; + + CUP$parser$result = new java_cup.runtime.Symbol(5/*cycle*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-4)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 7: // NT$1 ::= + { + Object RESULT = null; + int cleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int cright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + Integer c = (Integer)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:gopt: ITERATION "+c); + + CUP$parser$result = new java_cup.runtime.Symbol(9/*NT$1*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 6: // scfcycle ::= Energ ENERGY NT$0 cycle + { + Object RESULT = null; + // propagate RESULT from NT$0 + if ( ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value != null ) + RESULT = (Object) ((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).right; + Float e = (Float)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-2)).value; + + CUP$parser$result = new java_cup.runtime.Symbol(4/*scfcycle*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-3)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 5: // NT$0 ::= + { + Object RESULT = null; + int eleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left; + int eright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right; + Float e = (Float)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-0)).value; + //___________________________________________________________________ + if (DEBUG) System.out.println("CUP:gopt: ENERGY "+e); + + CUP$parser$result = new java_cup.runtime.Symbol(8/*NT$0*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 4: // scfpat ::= scfcycle + { + Object RESULT = null; + + CUP$parser$result = new java_cup.runtime.Symbol(3/*scfpat*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 3: // scfpat ::= scfpat scfcycle + { + Object RESULT = null; + if (DEBUG) System.out.println("CUP:gopt: in scfpat"); + CUP$parser$result = new java_cup.runtime.Symbol(3/*scfpat*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 2: // scfintro ::= FOUNDITER + { + Object RESULT = null; + if (DEBUG) System.out.println("CUP:gopt: found the start of Iteration"); + CUP$parser$result = new java_cup.runtime.Symbol(2/*scfintro*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 1: // $START ::= startpt EOF + { + Object RESULT = null; + int start_valleft = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left; + int start_valright = ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).right; + Object start_val = (Object)((java_cup.runtime.Symbol) CUP$parser$stack.elementAt(CUP$parser$top-1)).value; + RESULT = start_val; + CUP$parser$result = new java_cup.runtime.Symbol(0/*$START*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-1)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + /* ACCEPT */ + CUP$parser$parser.done_parsing(); + return CUP$parser$result; + + /*. . . . . . . . . . . . . . . . . . . .*/ + case 0: // startpt ::= scfintro scfpat SCFDONE + { + Object RESULT = null; + if (DEBUG) System.out.println("CUP:gopt: end of parse tree "); + table = new JTable(); + +// table = parseSCF.getTable(); + + CUP$parser$result = new java_cup.runtime.Symbol(1/*startpt*/, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-2)).left, ((java_cup.runtime.Symbol)CUP$parser$stack.elementAt(CUP$parser$top-0)).right, RESULT); + } + return CUP$parser$result; + + /* . . . . . .*/ + default: + throw new Exception( + "Invalid action number found in internal parse table"); + + } + } +} + http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramSym.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramSym.java b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramSym.java new file mode 100644 index 0000000..01fce30 --- /dev/null +++ b/datacat/parsers/src/main/java/org/apache/airavata/datacat/parsers/gridchem/whichProgram/WhichProgramSym.java @@ -0,0 +1,43 @@ +/* +* +* 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.airavata.datacat.parsers.gridchem.whichProgram; +//---------------------------------------------------- +// The following code was generated by CUP v0.10k +// Wed Nov 12 18:52:46 IST 2014 +//---------------------------------------------------- + +/** CUP generated class containing symbol constants. */ +public class WhichProgramSym { + /* terminals */ + public static final int MGRAD = 10; + public static final int RmsGrad = 7; + public static final int Energ = 5; + public static final int MaxGrad = 6; + public static final int ENERGY = 9; + public static final int EOF = 0; + public static final int ITERATION = 8; + public static final int NSearch = 4; + public static final int RGRAD = 11; + public static final int error = 1; + public static final int SCFDONE = 3; + public static final int FOUNDITER = 2; +} + http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/resources/gridchem.properties ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/resources/gridchem.properties b/datacat/parsers/src/main/resources/gridchem.properties new file mode 100644 index 0000000..859d6db --- /dev/null +++ b/datacat/parsers/src/main/resources/gridchem.properties @@ -0,0 +1,16 @@ +TMP_DIR=/home/supun/datacat/tmp + +SAMPLE_OUTPUT=/home/supun/datacat/data_root/2H2OOHNCmin.com.out/2H2OOHNCmin.com.out + +ARCHIVING_NODE=localhost + +APPLICATION_NAME=gaussian 9 + +USERNAME=sudhakar + +AGENT_USERNAME=datacat_agent + +AGENT_PASSWORD=agent_password + +#specify the parser sequence using commas ( ',' ) +PARSER_SEQUENCE= org.apache.airavata.datacat.parsers.gridchem.gopt.GoptParser \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/main/resources/regexParser.properties ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/main/resources/regexParser.properties b/datacat/parsers/src/main/resources/regexParser.properties new file mode 100644 index 0000000..3464bf5 --- /dev/null +++ b/datacat/parsers/src/main/resources/regexParser.properties @@ -0,0 +1,9 @@ +#here you can specify which details to extract by +#<key_value>=<regex> +#ex: RMS FORCE=RMS\s+Force\s+(\d*\.?\d*) + +RMS_Force = RMS\s+Force\s+(\d*\.?\d*) +Maximum_Force = Maximum\s+Force\s+(\d*\.?\d*) +Maximum_Displacement = Maximum\s+Displacement\s+(\d*\.?\d*) +RMS_Displacement = RMS\s+Displacement\s+(\d*\.?\d*) +Energy = Predicted\s+change\s+in\s+Energy=(.*) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/4231ac35/datacat/parsers/src/test/java/org/apche/airavata/datacat/parsers/gridchem/AbstractGridChemParserTest.java ---------------------------------------------------------------------- diff --git a/datacat/parsers/src/test/java/org/apche/airavata/datacat/parsers/gridchem/AbstractGridChemParserTest.java b/datacat/parsers/src/test/java/org/apche/airavata/datacat/parsers/gridchem/AbstractGridChemParserTest.java new file mode 100644 index 0000000..8ea3aaf --- /dev/null +++ b/datacat/parsers/src/test/java/org/apche/airavata/datacat/parsers/gridchem/AbstractGridChemParserTest.java @@ -0,0 +1,39 @@ +/* +* +* 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.apche.airavata.datacat.parsers.gridchem; + +import org.apache.airavata.datacat.parsers.gridchem.util.Constants; +import org.apache.airavata.datacat.parsers.gridchem.util.GridChemProperties; +import org.apache.log4j.Logger; +import org.junit.Before; + +import java.util.Properties; + +public abstract class AbstractGridChemParserTest { + protected Properties testProperties; + protected String TEST_OUTPUT; + private Logger logger = Logger.getLogger(AbstractGridChemParserTest.class); + + @Before + public void setUp() { + TEST_OUTPUT = GridChemProperties.getInstance().getProperty(Constants.SAMPLE_OUTPUT,""); + } +} \ No newline at end of file
