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

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

/**
 * 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 {

  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() :
{}
{
  (command() ((< PIPELINE > command())+)?)? < EOF >
  {
	return ((SimpleNode)jjtree.rootNode());
  }
}

void pipelinedCommand() :
{}
{
	command() (< PIPELINE > command())+
}

void command() :
{}
{
  word() ( number() | word() )*
}

Number number() :
{
  Number n;
}
{
  n = Integer()
  {
    jjtThis.value = n.intValue();
    return n;
  }
| n = Long()
  {
    jjtThis.value = n.longValue();
    return n;
  }
| n = Float()
  {
    jjtThis.value = n.floatValue();
    return n;
  }
| n = Double()
  {
    jjtThis.value = n.doubleValue();
    return n;
  }
}

double Double() :
{
  Token t;
}
{
  t = < DOUBLE_POINT_LITERAL >
  {
    jjtThis.value = Double.parseDouble(t.image);
    return Double.parseDouble(t.image);
  }
}

float Float() :
{
  Token t;
}
{
  t = < FLOATING_POINT_LITERAL >
  {
    jjtThis.value = Float.parseFloat(t.image);
    return Float.parseFloat(t.image);
  }
}

int Integer() :
{
  Token t;
}
{
  t = < INTEGER_LITERAL >
  {
    jjtThis.value = Integer.parseInt(t.image);
    return Integer.parseInt(t.image);
  }
}

long Long() :
{
  Token t;
}
{
  t = < LONG_LITERAL >
  {
    jjtThis.value = Long.parseLong(t.image.replace("l", "").replace("L", ""));
    return (long) jjtThis.value;
  }
}

String word() :
{
  String n;
  Token t;
}
{
  t = < WORD >
  {
    jjtThis.value = t.image;
    return t.image;
  }
}
  




© 2015 - 2025 Weber Informatics LLC | Privacy Policy