![]() |
This is Unofficial EPICS BASE Doxygen Site
|
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "dbDefs.h"
#include "epicsAssert.h"
#include "epicsStdlib.h"
#include "epicsString.h"
#include "epicsTypes.h"
#include "postfix.h"
#include "postfixPvt.h"
#include "libComAPI.h"
Go to the source code of this file.
Classes | |
struct | expression_element |
Typedefs | |
typedef struct expression_element | ELEMENT |
Enumerations | |
enum | element_type { OPERAND, LITERAL_OPERAND, STORE_OPERATOR, UNARY_OPERATOR, VARARG_OPERATOR, BINARY_OPERATOR, SEPERATOR, CLOSE_PAREN, CONDITIONAL, EXPR_TERMINATOR } |
Functions | |
LIBCOM_API long | postfix (const char *psrc, char *pout, short *perror) |
Compile an infix expression into postfix byte-code. More... | |
LIBCOM_API const char * | calcErrorStr (short error) |
Convert an error code to a string. More... | |
LIBCOM_API void | calcExprDump (const char *pinst) |
Disassemble a postfix expression. More... | |
typedef struct expression_element ELEMENT |
enum element_type |
Enumerator | |
---|---|
OPERAND | |
LITERAL_OPERAND | |
STORE_OPERATOR | |
UNARY_OPERATOR | |
VARARG_OPERATOR | |
BINARY_OPERATOR | |
SEPERATOR | |
CLOSE_PAREN | |
CONDITIONAL | |
EXPR_TERMINATOR |
Definition at line 33 of file postfix.c.
LIBCOM_API const char* calcErrorStr | ( | short | error | ) |
Convert an error code to a string.
Gives out a printable version of an individual error code. The error codes are macros defined here with names starting CALC_ERR_
error | Error code |
Definition at line 493 of file postfix.c.
LIBCOM_API void calcExprDump | ( | const char * | pinst | ) |
Disassemble a postfix expression.
Convert the byte-code stream to text and print to stdout.
pinst | postfix instructions |
Definition at line 523 of file postfix.c.
LIBCOM_API long postfix | ( | const char * | pinfix, |
char * | ppostfix, | ||
short * | perror | ||
) |
Compile an infix expression into postfix byte-code.
Converts an expression from an infix string to postfix byte-code
pinfix | Pointer to the infix string |
ppostfix | Pointer to the postfix buffer |
perror | Place to return an error code |
It is the callers's responsibility to ensure that ppostfix
points to sufficient storage to hold the postfix expression. The macro INFIX_TO_POSTFIX_SIZE(n) can be used to calculate an appropriate postfix buffer size from the length of the infix buffer.
***Arithmetic Operators*** The usual binary arithmetic operators are provided: + - * and / with their usual relative precedence and left-to-right associativity, and - may also be used as a unary negate operator where it has a higher precedence and associates from right to left. There is no unary plus operator, so numeric literals cannot begin with a + sign.
Three other binary operators are also provided: % is the integer modulo operator, while the synonymous operators ** and ^ raise their left operand to the power of the right operand. % has the same precedence and associativity as * and /, while the power operators associate left-to-right and have a precedence in between * and unary minus.
Definition at line 209 of file postfix.c.