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

com.sirolf2009.husk.dsl.CLI.jj Maven / Gradle / Ivy

/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. CLI.jj */
/*@egen*//**
 * JavaCC template file created by SF JavaCC plugin 1.5.28+ wizard for JavaCC 1.5.0+
 */
options
{
  static = false;
}

PARSER_BEGIN(CLI)
package com.sirolf2009.husk.dsl;

public class CLI/*@bgen(jjtree)*/implements CLITreeConstants/*@egen*/ {/*@bgen(jjtree)*/
  protected JJTCLIState jjtree = new JJTCLIState();

/*@egen*/

  public static void main(String args []) throws ParseException {
      parse("getFromDatabase 1 | parse report | print").dump(" >");
      parse("print").dump(" >");
  }
  
  public static SimpleNode parse(String command) throws ParseException {
    SimpleNode node = new CLI(new java.io.StringReader(command)).cliCommand();
    return node;
  }
}

PARSER_END(CLI)

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

TOKEN : {
   |  | >
|  (["l","L"])? |  (["l","L"])? |  (["l","L"])?>
| <#DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])*>
| <#HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+>
| <#OCTAL_LITERAL: "0" (["0"-"7"])*>
|  | >
|  | >
| <#DECIMAL_DOUBLE_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* ()? (["d","D"])? | "." (["0"-"9"])+ ()? (["d","D"])? | (["0"-"9"])+  (["d","D"])? | (["0"-"9"])+ ()? ["d","D"]>
| <#DECIMAL_FLOATING_POINT_LITERAL: (["0"-"9"])+ "." (["0"-"9"])* ()? (["f","F"])? | "." (["0"-"9"])+ ()? (["f","F"])? | (["0"-"9"])+  (["f","F"])? | (["0"-"9"])+ ()? ["f","F"]>
| <#DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+>
| <#HEXADECIMAL_DOUBLE_POINT_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ (".")?  (["d","D"])? | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+  (["d","D"])?>
| <#HEXADECIMAL_FLOATING_POINT_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ (".")?  (["f","F"])? | "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+  (["f","F"])?>
| <#HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+>
| <#CHARACTER_LITERAL: "\'" (~["\'","\\","\n","\r"] | "\\" (["n","t","b","r","f","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"])) "\'">
| <#STRING_LITERAL: (~["\"","\\","\n","\r"] | "\\" (["n","t","b","r","f","\\","\'","\""] | ["0"-"7"] (["0"-"7"])? | ["0"-"3"] ["0"-"7"] ["0"-"7"]))* >
}

TOKEN :
{
  < PIPELINE : "|" >
| < WORD : (< CHAR >)+ >
| < #CHAR : [ "a"-"z" , "A"-"Z", "[", "$", "&", "+", ",", ":", ";", "=", "?", "@", "#", "|", "'", "<", ">", ".", "^", "*", "(", ")", "%", "!", "-", "]", "/", "\\", "0"-"9" ] >
}


SimpleNode cliCommand() :
{/*@bgen(jjtree) cliCommand */
  SimpleNode jjtn000 = new SimpleNode(JJTCLICOMMAND);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) cliCommand */
  try {
/*@egen*/
  (command() ((< PIPELINE > command())+)?)? < EOF >/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
	return ((SimpleNode)jjtree.rootNode());
  }/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void pipelinedCommand() :
{/*@bgen(jjtree) pipelinedCommand */
  SimpleNode jjtn000 = new SimpleNode(JJTPIPELINEDCOMMAND);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) pipelinedCommand */
        try {
/*@egen*/
	command() (< PIPELINE > command())+/*@bgen(jjtree)*/
        } catch (Throwable jjte000) {
          if (jjtc000) {
            jjtree.clearNodeScope(jjtn000);
            jjtc000 = false;
          } else {
            jjtree.popNode();
          }
          if (jjte000 instanceof RuntimeException) {
            throw (RuntimeException)jjte000;
          }
          if (jjte000 instanceof ParseException) {
            throw (ParseException)jjte000;
          }
          throw (Error)jjte000;
        } finally {
          if (jjtc000) {
            jjtree.closeNodeScope(jjtn000, true);
          }
        }
/*@egen*/
}

void command() :
{/*@bgen(jjtree) command */
  SimpleNode jjtn000 = new SimpleNode(JJTCOMMAND);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) command */
  try {
/*@egen*/
  word() ( number() | word() )*/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

Number number() :
{/*@bgen(jjtree) number */
  SimpleNode jjtn000 = new SimpleNode(JJTNUMBER);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/
  Number n;
}
{/*@bgen(jjtree) number */
  try {
/*@egen*/
  n = Integer()/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = n.intValue();
    return n;
  }
| n = Long()/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = n.longValue();
    return n;
  }
| n = Float()/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = n.floatValue();
    return n;
  }
| n = Double()/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = n.doubleValue();
    return n;
  }/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

double Double() :
{/*@bgen(jjtree) Double */
  SimpleNode jjtn000 = new SimpleNode(JJTDOUBLE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/
  Token t;
}
{/*@bgen(jjtree) Double */
  try {
/*@egen*/
  t = < DOUBLE_POINT_LITERAL >/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = Double.parseDouble(t.image);
    return Double.parseDouble(t.image);
  }/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

float Float() :
{/*@bgen(jjtree) Float */
  SimpleNode jjtn000 = new SimpleNode(JJTFLOAT);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/
  Token t;
}
{/*@bgen(jjtree) Float */
  try {
/*@egen*/
  t = < FLOATING_POINT_LITERAL >/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = Float.parseFloat(t.image);
    return Float.parseFloat(t.image);
  }/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

int Integer() :
{/*@bgen(jjtree) Integer */
  SimpleNode jjtn000 = new SimpleNode(JJTINTEGER);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/
  Token t;
}
{/*@bgen(jjtree) Integer */
  try {
/*@egen*/
  t = < INTEGER_LITERAL >/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = Integer.parseInt(t.image);
    return Integer.parseInt(t.image);
  }/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

long Long() :
{/*@bgen(jjtree) Long */
  SimpleNode jjtn000 = new SimpleNode(JJTLONG);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/
  Token t;
}
{/*@bgen(jjtree) Long */
  try {
/*@egen*/
  t = < LONG_LITERAL >/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = Long.parseLong(t.image.replace("l", "").replace("L", ""));
    return (long) jjtn000.value;
  }/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

String word() :
{/*@bgen(jjtree) word */
  SimpleNode jjtn000 = new SimpleNode(JJTWORD);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/
  String n;
  Token t;
}
{/*@bgen(jjtree) word */
  try {
/*@egen*/
  t = < WORD >/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/
  {
    jjtn000.value = t.image;
    return t.image;
  }/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}
  




© 2015 - 2025 Weber Informatics LLC | Privacy Policy