klel-expr man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

KLEL-EXPR(1)			    libklel			  KLEL-EXPR(1)

NAME
       klel-expr - Compile and execute a KL-EL expression

SYNOPSIS
       klel-expr [{-d|--debug-output}] {-e|--expression} expression

       klel-expr {-v|--version}

       Note: Command line arguments are position dependent, and argument
       snuggling (e.g., '-de') is not supported.  All arguments and their
       values (if any) must be separated by whitespace.

DESCRIPTION
       klel-expr executes a single KL-EL expression (see klellang(3)) and
       displays its result.  User-provided expressions have full access to the
       variables and functions exported by KL-EL standard library (see
       klelstdlib(3)).

   Executing Value Expressions
       klel-expr will execute a value expression (see klellang(3)) by
       calculating its value and displaying the result.

   Executing Guarded Commands
       klel-expr will execute a guarded command (see klellang(3)) by testing
       the guard.  If the guard succeeds (i.e., evaluates to Boolean true),
       the command is executed using the specified interpreter, which can be
       one of echo or system.

       The echo interpreter takes an arbitrary number of string arguments and
       echos them back to the display separated by whitespace.

       The system interpereter takes a single string argument, passes that
       string unchanged to system(3), and displays the output (if any) of the
       executed command.

MODES OF OPERATION
       The modes of operation described in this section are mutually
       exclusive.  In other words, only one mode may be specified per
       invocation.

       {-e|--expression} expression
	   Compile and execute the specified expression.

       {-v|--version}
	   Display version information and exit.

OPTIONS
       {-d|--debug-output}
	   Print additional debug output during program execution.

RETURN VALUES
       Upon successful completion, a value of 0 (XER_OK) is returned.
       Otherwise, one of the following error codes is returned:

       ·    1 = XER_Usage

       ·    2 = XER_Setup

       ·    3 = XER_Out_Of_Memory

       ·    4 = XER_Execute

       ·    5 = XER_GuardedCommand

EXAMPLES
       The following examples are intended to demonstrate different ways of
       invoking klel-expr.  Lines prefixed with $ indicate user input within a
       Bourne or Bourne-like shell.

   Example 1. A simple expression.
       In this example, a simple arithmetic expression is evaluated.

	   $ klel-expr -e '1 + 2'
	   3

       When you run the command shown above, klel-expr will compile the
       expression, evaluate it, and then print out the result ('3').

       Note that the quotes around the expression are required since klel-expr
       accepts only a single expression argument.

   Example 2. A simple expression with debug output.
       In this example, another arithmetic expression is evaluated.  More
       importantly, the debug-output option is exercised.

	   $ klel-expr -d -e '2 * pi + 7 / 42 + entier(299.398)'
	   KlelType='value expression'
	   KlelExpr='((2 * pi) + 7 / 42) + entier(299.398)'
	   KlelExprName='expr(00003e7b)'
	   KlelExprStatus='pass'
	   KlelExprType='real'
	   KlelExprOutput=<<EndOfOutput
	   305.283
	   EndOfOutput

       When you run the command shown above, klel-expr will compile the
       expression, evaluate it, and then print out the result (305.283) along
       with additional data that are useful for debugging and/or informational
       purposes.

   Example 3. Executing a guarded command.
       In this example, a guarded command is evaluated and conditionally
       executed using system(3).

	   $ klel-expr -e 'if (true) then eval("system", "echo -n GIGO | sum")'
	   41101 1

       When you run the command shown above, klel-expr will compile the
       expression, evaluate it, and conditionally execute the guarded command
       ('echo -n GIGO | sum').	Since the expression always evaluates to true,
       the guarded command will always be executed.

       Note that klel-expr supports two interpreters, system and echo.	The
       system interpreter takes one argument (a string) and passes it to
       system(3).  The echo interpreter takes an arbitrary number of arguments
       (the first of which must be a literal string) and echos them to the
       standard output.

   Example 4. Executing a named expression.
       In this example, a named expression is evaluated.

	   $ klel-expr -e 'my_expression : 1 + 2.1'
	   3.1

       When you run the command shown above, klel-expr will compile the
       expression, evaluate it, and then print out the result (3.1).

   Example 5. Using let and variable interpolation.
       In this example, a simple expression involving the use of let and
       variable interpolation is evaluated.

	   $ klel-expr -e 'let t = now() in odd(t) ? "%{t} --> odd" : "%{t} --> even"'
	   1353099233 --> odd

       When you run the command shown above, klel-expr will compile the
       expression, evaluate it, and then print out the result.

       Note how the variable t is expressed as '%{t}' in the ternary, which
       allows its value to be interpolated to produce the resulting string
       value.

SEE ALSO
       klelapi(3), klellang(3), klelstdlib(3), kleltut(3)

1.1.0				  2015-09-16			  KLEL-EXPR(1)
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net