Index: trunk/src/VBox/Runtime/common/script/scriptlex.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/script/scriptlex.cpp	(revision 106061)
+++ trunk/src/VBox/Runtime/common/script/scriptlex.cpp	(revision 108014)
@@ -422,17 +422,9 @@
 
 
-/**
- * Produce an error token with the given error message.
- *
- * @returns IPRT status code.
- * @param   pThis                  The lexer state.
- * @param   pTok                   The token to fill.
- * @param   rc                     The status code to use in the message.
- * @param   pszMsg                 The format string for the error message.
- * @param   ...                    Arguments to the format string.
- */
-static int rtScriptLexProduceTokError(PRTSCRIPTLEXINT pThis, PRTSCRIPTLEXTOKEN pTok,
-                                      int rc, const char *pszMsg, ...)
-{
+RTDECL(int) RTScriptLexProduceTokError(RTSCRIPTLEX hScriptLex, PRTSCRIPTLEXTOKEN pTok,
+                                       int rc, const char *pszMsg, ...)
+{
+    PRTSCRIPTLEXINT pThis = hScriptLex;
+
     va_list va;
     va_start(va, pszMsg);
@@ -447,4 +439,19 @@
 
     return rc;
+}
+
+
+RTDECL(int) RTScriptLexProduceTokIde(RTSCRIPTLEX hScriptLex, PRTSCRIPTLEXTOKEN pTok, const char *pszIde, size_t cchIde)
+{
+    PRTSCRIPTLEXINT pThis = hScriptLex;
+
+    /* Insert into string cache. */
+    pTok->enmType = RTSCRIPTLEXTOKTYPE_IDENTIFIER;
+    pTok->Type.Id.pszIde = RTStrCacheEnterN(pThis->hStrCacheId, pszIde, cchIde);
+    if (RT_UNLIKELY(!pTok->Type.Id.pszIde))
+        return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_NO_STR_MEMORY, "Lexer: Out of memory inserting identifier into string cache");
+
+    pTok->PosEnd = pThis->Pos;
+    return VINF_SUCCESS;
 }
 
@@ -476,5 +483,5 @@
             break;
         default:
-            rtScriptLexProduceTokError(pThis, pTok, VERR_INVALID_PARAMETER,
+            RTScriptLexProduceTokError(pThis, pTok, VERR_INVALID_PARAMETER,
                                        "Lexer: The match contains an invalid token type: %d\n",
                                        pTok->enmType);
@@ -541,5 +548,5 @@
             pThis->rcRdr = pThis->pCfg->pfnProdDef(pThis, ch, pTok, pThis->pCfg->pvProdDefUser);
         else
-            rtScriptLexProduceTokError(pThis, pTok, VERR_INVALID_PARAMETER,
+            RTScriptLexProduceTokError(pThis, pTok, VERR_INVALID_PARAMETER,
                                        "Lexer: Invalid character found in input: %c\n",
                                        ch);
@@ -974,5 +981,5 @@
     if (   idx == sizeof(aszIde) - 1
         && rtScriptLexLocateChInStrConsume(hScriptLex, ch, pszCharSet))
-        return rtScriptLexProduceTokError(hScriptLex, pTok, VERR_BUFFER_OVERFLOW, "Lexer: Identifier exceeds the allowed length");
+        return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_BUFFER_OVERFLOW, "Lexer: Identifier exceeds the allowed length");
 
     /* Insert into string cache. */
@@ -980,5 +987,5 @@
     pTok->Type.Id.pszIde = RTStrCacheEnterN(pThis->hStrCacheId, &aszIde[0], idx);
     if (RT_UNLIKELY(!pTok->Type.Id.pszIde))
-        return rtScriptLexProduceTokError(hScriptLex, pTok, VERR_NO_STR_MEMORY, "Lexer: Out of memory inserting identifier into string cache");
+        return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_NO_STR_MEMORY, "Lexer: Out of memory inserting identifier into string cache");
 
     pTok->PosEnd = pThis->Pos;
@@ -1034,5 +1041,5 @@
     int rc = rtScriptLexScanStringLiteralChAdd(pThis, '\0', idxChCur);
     if (RT_FAILURE(rc))
-        return rtScriptLexProduceTokError(hScriptLex, pTok, rc, "Lexer: Error adding character to string literal");
+        return RTScriptLexProduceTokError(hScriptLex, pTok, rc, "Lexer: Error adding character to string literal");
 
     ch = RTScriptLexGetCh(hScriptLex);
@@ -1040,7 +1047,9 @@
     {
         if (ch == '\0')
-            return rtScriptLexProduceTokError(hScriptLex, pTok, VERR_EOF, "Lexer: End of stream before closing string literal terminal");
+            return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_EOF, "Lexer: End of stream before closing string literal terminal");
         else if (ch == '\"')
         {
+            RTScriptLexConsumeCh(hScriptLex);
+
             /* End of string, add it to the string literal cache and build the token. */
             pTok->enmType = RTSCRIPTLEXTOKTYPE_STRINGLIT;
@@ -1048,5 +1057,5 @@
             pTok->Type.StringLit.pszString = RTStrCacheEnterN(pThis->hStrCacheStringLit, pThis->pszStrLit, idxChCur);
             if (RT_UNLIKELY(!pTok->Type.StringLit.pszString))
-                return rtScriptLexProduceTokError(hScriptLex, pTok, VERR_NO_STR_MEMORY, "Lexer: Error adding string literal to the cache");
+                return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_NO_STR_MEMORY, "Lexer: Error adding string literal to the cache");
             else
                 break;
@@ -1104,5 +1113,5 @@
                 default:
                     /* Not supported for now. */
-                    return rtScriptLexProduceTokError(hScriptLex, pTok, VERR_NOT_SUPPORTED, "Lexer: Invalid/unsupported escape sequence");
+                    return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_NOT_SUPPORTED, "Lexer: Invalid/unsupported escape sequence");
             }
         }
@@ -1112,5 +1121,5 @@
             idxChCur++;
         else
-            return rtScriptLexProduceTokError(hScriptLex, pTok, rc, "Lexer: Error adding character to string literal");
+            return RTScriptLexProduceTokError(hScriptLex, pTok, rc, "Lexer: Error adding character to string literal");
 
         ch = RTScriptLexConsumeChEx(hScriptLex, RTSCRIPT_LEX_CONV_F_NOTHING);
@@ -1132,5 +1141,5 @@
     int rc = rtScriptLexScanStringLiteralChAdd(pThis, '\0', idxChCur);
     if (RT_FAILURE(rc))
-        return rtScriptLexProduceTokError(hScriptLex, pTok, rc, "Lexer: Error adding character to string literal");
+        return RTScriptLexProduceTokError(hScriptLex, pTok, rc, "Lexer: Error adding character to string literal");
 
     ch = RTScriptLexGetChEx(hScriptLex, RTSCRIPT_LEX_CONV_F_NOTHING);
@@ -1138,5 +1147,5 @@
     {
         if (ch == '\0')
-            return rtScriptLexProduceTokError(hScriptLex, pTok, VERR_EOF, "Lexer: End of stream before closing string literal terminal");
+            return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_EOF, "Lexer: End of stream before closing string literal terminal");
         else if (ch == '\'')
         {
@@ -1153,5 +1162,5 @@
                 pTok->Type.StringLit.pszString = RTStrCacheEnterN(pThis->hStrCacheStringLit, pThis->pszStrLit, idxChCur);
                 if (RT_UNLIKELY(!pTok->Type.StringLit.pszString))
-                    return rtScriptLexProduceTokError(hScriptLex, pTok, VERR_NO_STR_MEMORY, "Lexer: Error adding string literal to the cache");
+                    return RTScriptLexProduceTokError(hScriptLex, pTok, VERR_NO_STR_MEMORY, "Lexer: Error adding string literal to the cache");
                 else
                     break;
@@ -1164,5 +1173,5 @@
             idxChCur++;
         else
-            return rtScriptLexProduceTokError(hScriptLex, pTok, rc, "Lexer: Error adding character to string literal");
+            return RTScriptLexProduceTokError(hScriptLex, pTok, rc, "Lexer: Error adding character to string literal");
         ch = RTScriptLexConsumeChEx(hScriptLex, RTSCRIPT_LEX_CONV_F_NOTHING);
     }
