r7214: Undo my interpreter patch. Tridge thought of a much better way to do it
authorTim Potter <tpot@samba.org>
Fri, 3 Jun 2005 07:56:41 +0000 (07:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:26 +0000 (13:17 -0500)
that doesn't involve any changes to ejs at all.
(This used to be commit 7b49711ecb87e8618be5ae934ffed5995408b748)

source4/lib/ejs/ejs.c
source4/lib/ejs/ejsInternal.h
source4/lib/ejs/ejsLex.c
source4/lib/ejs/ejsParser.c

index d0eaf6e3893eba669e25561f3c2a33b0794fb277..41af795370c284e055c498f1a925aed99a5fbe5b 100644 (file)
@@ -418,10 +418,8 @@ int ejsEvalScript(EjsId eid, char *script, MprVar *vp, char **emsg)
        endlessLoopTest = NULL;
        ep->exitStatus = 0;
 
-       ejsParse(ep, EJS_STATE_BEGIN, EJS_FLAGS_EXE); /* Skip over #! */
-
        do {
-               state = ejsParse(ep, EJS_STATE_STMT, EJS_FLAGS_EXE);
+               state = ejsParse(ep, EJS_STATE_BEGIN, EJS_FLAGS_EXE);
 
                if (state == EJS_STATE_RET) {
                        state = EJS_STATE_EOF;
index 2f776b8b798f7f994152c5804d182850d90a487c..4d54c4e8c61eca4e25825dcb8ec7f19465909f74 100644 (file)
@@ -100,7 +100,7 @@ extern "C" {
 #define EJS_TOK_IN                                     26              /* in */
 #define EJS_TOK_FUNCTION                       27              /* function */
 #define EJS_TOK_NUMBER                         28              /* Number */
-#define EJS_TOK_HASHBANG            29      /* #!/path/to/interpreter */
+
 /*
  *     Expression operators
  */
@@ -150,7 +150,8 @@ extern "C" {
 #define EJS_STATE_DEC                          18              /* Declaration statement */
 #define EJS_STATE_DEC_DONE                     19
 #define EJS_STATE_RET                          20              /* Return statement */
-#define EJS_STATE_BEGIN             21      /* Start of script */
+
+#define EJS_STATE_BEGIN                                EJS_STATE_STMT
 
 /*
  *     General parsing flags.
index 81f56b092e2dec0a3be5e4dfabaa6e5dc93bb04a..b0d6483c2adff0a986e7831c59e785090bf7b81d 100644 (file)
@@ -674,26 +674,6 @@ static int getLexicalToken(Ejs *ep, int state)
                        inputPutback(ep, c);
                        return EJS_TOK_NUMBER;
 
-               case '#':
-                       if (ip->lineNumber == 1) {
-                               if ((c = inputGetc(ep)) < 0) {
-                                       ejsError(ep, "Syntax Error");
-                                       return EJS_TOK_ERR;
-                               }
-                               if (c != '!') {
-                                       ejsError(ep, "Syntax Error");
-                                       return EJS_TOK_ERR;
-                               }
-                               while ((c = inputGetc(ep)) != -1) {
-                                       if (c == '\r' || c == '\n')
-                                               break;
-                                       tokenAddChar(ep, c);
-                               }
-                               return EJS_TOK_HASHBANG;
-                       }
-
-                       /* Fall through to default handling */
-
                default:
                        /*
                         *      Identifiers or a function names
index 942b08272ea16c84d7ec1fb80e23e55d1db27610..17fe0ce98af930ceaed3a461ec301b8de5a15db0 100644 (file)
@@ -67,7 +67,6 @@ static int            parseId(Ejs *ep, int state, int flags, char **id,
 static int             parseInc(Ejs *ep, int state, int flags);
 static int             parseIf(Ejs *ep, int state, int flags, int *done);
 static int             parseStmt(Ejs *ep, int state, int flags);
-static int             parseHashBang(Ejs *ep, int state, int flags);
 static void    removeNewlines(Ejs *ep, int state);
 static void    updateResult(Ejs *ep, int state, int flags, MprVar *vp);
 
@@ -81,12 +80,6 @@ int ejsParse(Ejs *ep, int state, int flags)
        mprAssert(ep);
 
        switch (state) {
-       /*
-        *      The very start of a script.
-        */
-       case EJS_STATE_BEGIN:
-               state = parseHashBang(ep, state, flags);
-               break;
        /*
         *      Any statement, function arguments or conditional expressions
         */
@@ -147,26 +140,6 @@ int ejsParse(Ejs *ep, int state, int flags)
        return state;
 }
 
-/******************************************************************************/
-/*
- *     Parse a #!/path/to/interpreter line which we just throw away.
- */
-
-static int parseHashBang(Ejs *ep, int state, int flags)
-{
-       int tid;
-
-       /* Look for #! */
-
-       tid = ejsLexGetToken(ep, state);
-
-       if (tid != EJS_TOK_HASHBANG) {
-               ejsLexPutbackToken(ep, tid, ep->token);
-       }
-
-       return EJS_STATE_STMT;
-}
-
 /******************************************************************************/
 /*
  *     Parse any statement including functions and simple relational operations