Changeset 9d2a70c in tol


Ignore:
Timestamp:
Feb 13, 2012, 5:03:25 PM (15 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
ab6d232
Parents:
96de79c
Message:

refs #994, #1404: implementing the command tol::checksyntax

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@4124 be4846ae-f051-483a-831f-b64e7d08527f

Location:
toltcl/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • toltcl/generic/tolaccess.cpp

    r96de79c r9d2a70c  
    4242#include <tol/tol_btxtgra.h>
    4343#include <tol/tol_bmethodhook.h>
     44#include <tol/tol_bparser.h>
    4445
    4546#include <toltclInt.h>
    … …  
    18791880}
    18801881
     1882int Tol_CheckSyntax(Tcl_Interp * interp,
     1883                    Tcl_Obj    * obj_expr,
     1884                    Tcl_Obj    * obj_result)
     1885{
     1886  Tcl_DString dstr;
     1887  BText tol_expr;
     1888
     1889  Tcl_DStringInit(&dstr);
     1890  tol_expr = Tcl_UtfToExternalDString( NULL, Tcl_GetString( obj_expr ),
     1891                                       -1, &dstr );
     1892  Tcl_DStringFree(&dstr);
     1893 
     1894  BBool stat = BOut::ErrorHci();
     1895  BOut::PutErrorHci(BFALSE);
     1896  BParser* parser = new BParser;
     1897  Tree* tree = parser->Parsing( tol_expr );
     1898  Tcl_SetStringObj( obj_result, parser->MessageError(), -1 );
     1899  delete parser;
     1900  BOut::PutErrorHci( stat );
     1901  DESTROY(tree);
     1902  return TCL_OK;
     1903}
     1904
    18811905/*
    18821906 * Fill in obj_result the result of evaluating including the file
  • toltcl/generic/toltcl.c

    r96de79c r9d2a70c  
    4040
    4141static int Tol_InitLibraryCmd _ANSI_ARGS_((ClientData clientData,
     42                                           Tcl_Interp *interp,
     43                                           int objc, Tcl_Obj *CONST objv[]));
     44
     45static int Tol_CheckSyntaxCmd _ANSI_ARGS_((ClientData clientData,
    4246                                           Tcl_Interp *interp,
    4347                                           int objc, Tcl_Obj *CONST objv[]));
    … …  
    257261                        (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
    258262
     263  Tcl_CreateObjCommand( interp, "::tol::checksyntax", Tol_CheckSyntaxCmd,
     264                        (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
     265
    259266  Tcl_CreateObjCommand( interp, "::tol::include", Tol_IncludeCmd,
    260267                        (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
    … …  
    351358  }
    352359  return status;
     360}
     361
     362
     363
     364/*
     365 *----------------------------------------------------------------------
     366 *
     367 * Tol_CheckSyntaxCmd --
     368 *
     369 *      Implements the new Tcl "::tol::checksyntax" command.
     370 *
     371 * Results:
     372 *
     373 *      Returns the syntax error found in the tol expression given as
     374 *      argument. If no error is found then the empty string is
     375 *      returned.
     376 *
     377 * Side effects:
     378 *      None.
     379 *
     380 *----------------------------------------------------------------------
     381 */
     382
     383static int
     384Tol_CheckSyntaxCmd(clientData, interp, objc, objv)
     385     ClientData clientData;  /* Not used. */
     386     Tcl_Interp *interp;             /* Current interpreter */
     387     int objc;                                 /* Number of arguments */
     388     Tcl_Obj *CONST objv[];  /* Argument objects */
     389{
     390  Tcl_Obj * obj_result= Tcl_NewObj();
     391  int tcl_result;
     392 
     393  if (objc != 2) {
     394    Tcl_SetStringObj(obj_result,
     395                     "wrong # args: should be \"::tol::checksyntax tolcode\"",
     396                     -1);
     397    tcl_result = TCL_ERROR;
     398  } else
     399    tcl_result = Tol_CheckSyntax( interp, objv[1], obj_result );
     400  Tcl_SetObjResult( interp, obj_result );
     401  return tcl_result;
    353402}
    354403
  • toltcl/generic/toltclInt.h

    r96de79c r9d2a70c  
    6161                                        Tcl_Obj * obj_result));
    6262
     63
     64/*! Check the syntax of a given expresion.
     65 */
     66extern int Tol_CheckSyntax _ANSI_ARGS_((Tcl_Interp * interp,
     67                                        Tcl_Obj * obj_expr,
     68                                        Tcl_Obj * obj_result));
     69
    6370/*! Fill in obj_result the result of evaluating including the file
    6471 *  given as argument: the absolute path.
Note: See TracChangeset for help on using the changeset viewer.