Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JShellParser.cc File Reference
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <list>
#include "JLang/JNullType.hh"
#include "JLang/JEquation.hh"
#include "JLang/JEquationFacet.hh"
#include "JLang/JException.hh"
#include "JLang/JRedirectStream.hh"
#include "JLang/JLangToolkit.hh"
#include "JSystem/JSystemToolkit.hh"
#include "Jeep/JParser.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 Auxiliary program to interface JPARSER::JParser to command line of shell scripts. More...
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Auxiliary program to interface JPARSER::JParser to command line of shell scripts.

Syntax:

  eval JShellParser -o "-a \<environment variable\> [= \<default value\>[, \<possible value\>]]" -- $*

Definition at line 420 of file JShellParser.cc.

421 {
422  using namespace std;
423 
424  int debug;
425 
426  try {
427 
428  JEnvironment<bool> boolean;
429  JEnvironment<string> regular;
430 
431  JParser<> zap("Auxiliary program to interface C++ parser to command line of shell scripts.");
432 
433  zap['b'] = make_field(boolean) = JPARSER::initialised();
434  zap['o'] = make_field(regular) = JPARSER::initialised();
435  zap['d'] = make_field(debug) = 1;
436 
437  if (zap.read(argc, argv) != 0) {
438  return gexit(1);
439  }
440 
441  JEnvironment<> buffer;
442 
444 
445  buffer.join(boolean);
446  buffer.join(regular);
447 
448  if (buffer(argc, argv) == 0) {
449  evaluate(boolean);
450  evaluate(regular);
451  } else {
452  gexit(1);
453  }
454  }
455  catch(const exception& error) {
456  return gexit(2, error.what());
457  }
458 }
Utility class to parse command line options.
Definition: JParser.hh:1410
Empty structure for specification of parser element that is initialised (i.e.
Definition: JParser.hh:64
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
int gexit(int status, const std::string &message="")
Exit method.