summaryrefslogtreecommitdiffstats
path: root/generic/tclParseExpr.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclParseExpr.c')
-rw-r--r--generic/tclParseExpr.c146
1 files changed, 74 insertions, 72 deletions
diff --git a/generic/tclParseExpr.c b/generic/tclParseExpr.c
index 589dd49..27d980e 100644
--- a/generic/tclParseExpr.c
+++ b/generic/tclParseExpr.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclParseExpr.c,v 1.29 2005/10/19 18:39:58 dgp Exp $
+ * RCS: @(#) $Id: tclParseExpr.c,v 1.30 2005/10/31 15:59:41 dkf Exp $
*/
#include "tclInt.h"
@@ -140,26 +140,26 @@ static char *lexemeStrings[] = {
* Declarations for local functions to this file:
*/
-static int GetLexeme _ANSI_ARGS_((ParseInfo *infoPtr));
-static void LogSyntaxError _ANSI_ARGS_((ParseInfo *infoPtr,
- CONST char *extraInfo));
-static int ParseAddExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseBitAndExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseBitOrExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseBitXorExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseCondExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseEqualityExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseLandExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseLorExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseMultiplyExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParsePrimaryExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseRelationalExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseShiftExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseExponentialExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static int ParseUnaryExpr _ANSI_ARGS_((ParseInfo *infoPtr));
-static void PrependSubExprTokens _ANSI_ARGS_((CONST char *op,
- int opBytes, CONST char *src, int srcBytes,
- int firstIndex, ParseInfo *infoPtr));
+static int GetLexeme(ParseInfo *infoPtr);
+static void LogSyntaxError(ParseInfo *infoPtr,
+ CONST char *extraInfo);
+static int ParseAddExpr(ParseInfo *infoPtr);
+static int ParseBitAndExpr(ParseInfo *infoPtr);
+static int ParseBitOrExpr(ParseInfo *infoPtr);
+static int ParseBitXorExpr(ParseInfo *infoPtr);
+static int ParseCondExpr(ParseInfo *infoPtr);
+static int ParseEqualityExpr(ParseInfo *infoPtr);
+static int ParseLandExpr(ParseInfo *infoPtr);
+static int ParseLorExpr(ParseInfo *infoPtr);
+static int ParseMultiplyExpr(ParseInfo *infoPtr);
+static int ParsePrimaryExpr(ParseInfo *infoPtr);
+static int ParseRelationalExpr(ParseInfo *infoPtr);
+static int ParseShiftExpr(ParseInfo *infoPtr);
+static int ParseExponentialExpr(ParseInfo *infoPtr);
+static int ParseUnaryExpr(ParseInfo *infoPtr);
+static void PrependSubExprTokens(CONST char *op, int opBytes,
+ CONST char *src, int srcBytes, int firstIndex,
+ ParseInfo *infoPtr);
/*
* Macro used to debug the execution of the recursive descent parser used to
@@ -207,13 +207,13 @@ static void PrependSubExprTokens _ANSI_ARGS_((CONST char *op,
*/
int
-Tcl_ParseExpr(interp, start, numBytes, parsePtr)
- Tcl_Interp *interp; /* Used for error reporting. */
- CONST char *start; /* Start of source string to parse. */
- int numBytes; /* Number of bytes in string. If < 0, the
+Tcl_ParseExpr(
+ Tcl_Interp *interp, /* Used for error reporting. */
+ CONST char *start, /* Start of source string to parse. */
+ int numBytes, /* Number of bytes in string. If < 0, the
* string consists of all bytes up to the
* first null character. */
- Tcl_Parse *parsePtr; /* Structure to fill with information about
+ Tcl_Parse *parsePtr) /* Structure to fill with information about
* the parsed expression; any previous
* information in the structure is ignored. */
{
@@ -298,8 +298,8 @@ Tcl_ParseExpr(interp, start, numBytes, parsePtr)
*/
static int
-ParseCondExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseCondExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -411,8 +411,8 @@ ParseCondExpr(infoPtr)
*/
static int
-ParseLorExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseLorExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -470,8 +470,8 @@ ParseLorExpr(infoPtr)
*/
static int
-ParseLandExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseLandExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -529,8 +529,8 @@ ParseLandExpr(infoPtr)
*/
static int
-ParseBitOrExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseBitOrExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -589,8 +589,8 @@ ParseBitOrExpr(infoPtr)
*/
static int
-ParseBitXorExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseBitXorExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -649,8 +649,8 @@ ParseBitXorExpr(infoPtr)
*/
static int
-ParseBitAndExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseBitAndExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -709,8 +709,8 @@ ParseBitAndExpr(infoPtr)
*/
static int
-ParseEqualityExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseEqualityExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -772,8 +772,8 @@ ParseEqualityExpr(infoPtr)
*/
static int
-ParseRelationalExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseRelationalExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -839,8 +839,8 @@ ParseRelationalExpr(infoPtr)
*/
static int
-ParseShiftExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseShiftExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -900,8 +900,8 @@ ParseShiftExpr(infoPtr)
*/
static int
-ParseAddExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseAddExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -961,8 +961,8 @@ ParseAddExpr(infoPtr)
*/
static int
-ParseMultiplyExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseMultiplyExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -1022,8 +1022,8 @@ ParseMultiplyExpr(infoPtr)
*/
static int
-ParseExponentialExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseExponentialExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -1083,8 +1083,8 @@ ParseExponentialExpr(infoPtr)
*/
static int
-ParseUnaryExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParseUnaryExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -1130,7 +1130,7 @@ ParseUnaryExpr(infoPtr)
*
* This function parses a Tcl primary expression:
* primaryExpr ::= literal | varReference | quotedString |
- * '[' command ']' | mathFuncCall | '(' condExpr ')'
+ * '[' command ']' | mathFuncCall | '(' condExpr ')'
*
* Results:
* The return value is TCL_OK on a successful parse and TCL_ERROR on
@@ -1145,8 +1145,8 @@ ParseUnaryExpr(infoPtr)
*/
static int
-ParsePrimaryExpr(infoPtr)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ParsePrimaryExpr(
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -1564,8 +1564,8 @@ ParsePrimaryExpr(infoPtr)
*/
static int
-GetLexeme(infoPtr)
- ParseInfo *infoPtr; /* Holds state needed to parse the expr,
+GetLexeme(
+ ParseInfo *infoPtr) /* Holds state needed to parse the expr,
* including the resulting lexeme. */
{
register CONST char *src; /* Points to current source char. */
@@ -1615,11 +1615,12 @@ GetLexeme(infoPtr)
if ((c != '+') && (c != '-')) {
CONST char *end = infoPtr->lastChar;
CONST char* end2;
- int code = TclParseNumber(NULL, NULL, NULL,
- src, (unsigned)(end-src), &end2, 0);
- if ( code == TCL_OK ) {
+ int code = TclParseNumber(NULL, NULL, NULL, src, (unsigned)(end-src),
+ &end2, 0);
+
+ if (code == TCL_OK) {
length = end2-src;
- if ( length > 0 ) {
+ if (length > 0) {
infoPtr->lexeme = LITERAL;
infoPtr->start = src;
infoPtr->size = length;
@@ -1892,17 +1893,17 @@ GetLexeme(infoPtr)
*/
static void
-PrependSubExprTokens(op, opBytes, src, srcBytes, firstIndex, infoPtr)
- CONST char *op; /* Points to first byte of the operator in the
+PrependSubExprTokens(
+ CONST char *op, /* Points to first byte of the operator in the
* source script. */
- int opBytes; /* Number of bytes in the operator. */
- CONST char *src; /* Points to first byte of the subexpression
+ int opBytes, /* Number of bytes in the operator. */
+ CONST char *src, /* Points to first byte of the subexpression
* in the source script. */
- int srcBytes; /* Number of bytes in subexpression's
+ int srcBytes, /* Number of bytes in subexpression's
* source. */
- int firstIndex; /* Index of first token already emitted for
+ int firstIndex, /* Index of first token already emitted for
* operator's first (or only) operand. */
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+ ParseInfo *infoPtr) /* Holds the parse state for the expression
* being parsed. */
{
Tcl_Parse *parsePtr = infoPtr->parsePtr;
@@ -1953,17 +1954,18 @@ PrependSubExprTokens(op, opBytes, src, srcBytes, firstIndex, infoPtr)
*/
static void
-LogSyntaxError(infoPtr, extraInfo)
- ParseInfo *infoPtr; /* Holds the parse state for the expression
+LogSyntaxError(
+ ParseInfo *infoPtr, /* Holds the parse state for the expression
* being parsed. */
- CONST char *extraInfo; /* String to provide extra information about
+ CONST char *extraInfo) /* String to provide extra information about
* the syntax error. */
{
Tcl_Obj *result =
Tcl_NewStringObj("syntax error in expression \"", -1);
+
TclAppendLimitedToObj(result, infoPtr->originalExpr,
(int)(infoPtr->lastChar - infoPtr->originalExpr), 63, NULL);
- Tcl_AppendStringsToObj(result, "\": ", extraInfo, (char *) NULL);
+ Tcl_AppendStringsToObj(result, "\": ", extraInfo, NULL);
Tcl_SetObjResult(infoPtr->parsePtr->interp, result);
infoPtr->parsePtr->errorType = TCL_PARSE_SYNTAX;
infoPtr->parsePtr->term = infoPtr->start;