Example #1
0
 @Override
 protected void parse(final ArrayList<Command> cmds) throws QueryException {
   final Scanner sc = new Scanner(string).useDelimiter(single ? "\0" : "\r\n?|\n");
   while (sc.hasNext()) {
     final String line = sc.next().trim();
     if (line.isEmpty() || line.startsWith("#")) continue;
     parser = new InputParser(line);
     parser.file = ctx.options.get(MainOptions.QUERYPATH);
     while (parser.more()) {
       final Cmd cmd = consume(Cmd.class, null);
       if (cmd != null) cmds.add(parse(cmd));
       if (parser.more() && !parser.consume(';')) throw help(null, cmd);
     }
   }
 }
Example #2
0
 /**
  * Returns a single line from standard input.
  *
  * @return string
  */
 public static String input() {
   final Scanner sc = new Scanner(System.in);
   return sc.hasNextLine() ? sc.nextLine().trim() : "";
 }