WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Merge firebug.cl.cam.ac.uk:/local/scratch/smh22/xen-unst

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Merge firebug.cl.cam.ac.uk:/local/scratch/smh22/xen-unstable.bk
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Fri, 13 May 2005 18:28:59 +0000
Delivery-date: Fri, 13 May 2005 20:07:19 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1405, 2005/05/13 19:28:59+01:00, smh22@xxxxxxxxxxxxxxxxxxxx

        Merge firebug.cl.cam.ac.uk:/local/scratch/smh22/xen-unstable.bk
        into firebug.cl.cam.ac.uk:/local/scratch/smh22/mwray-xend2.bk



 sxpr_parser.c | 1108 ++++++++++++++++++++++++++++++----------------------------
 sxpr_parser.h |   68 ++-
 2 files changed, 626 insertions(+), 550 deletions(-)


diff -Nru a/tools/libxutil/sxpr_parser.c b/tools/libxutil/sxpr_parser.c
--- a/tools/libxutil/sxpr_parser.c      2005-05-13 16:07:55 -04:00
+++ b/tools/libxutil/sxpr_parser.c      2005-05-13 16:07:55 -04:00
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001 - 2004 Mike Wray <mike.wray@xxxxxx>
+ * Copyright (C) 2001 - 2005 Mike Wray <mike.wray@xxxxxx>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as
@@ -26,6 +26,8 @@
 #  include <errno.h>
 #endif
 
+#include "sys_net.h"
+
 #include "iostream.h"
 #include "lexis.h"
 #include "sxpr_parser.h"
@@ -42,45 +44,25 @@
  * @author Mike Wray <mike.wray@xxxxxxxxxx>
  */
 
+#ifdef DEBUG
 #define dprintf(fmt, args...) IOStream_print(iostdout, "[DEBUG] %s" fmt, 
__FUNCTION__, ##args)
+#else
+#define dprintf(fmt, args...) do{ }while(0)
+#endif
+
 #undef printf
 #define printf(fmt, args...)   IOStream_print(iostdout, fmt, ##args)
 
-static void reset(Parser *z);
-static int inputchar(Parser *p, char c);
-static int savechar(Parser *p, char c);
-extern void parse_error(Parser *in);
-extern void parse_error_id(Parser *in, ParseErrorId id);
-
-static int begin_start(Parser *p, char c);
 static int state_start(Parser *p, char c);
-static int end_start(Parser *p);
-
-static int begin_comment(Parser *p, char c);
-static int state_comment(Parser *p, char c);
-static int end_comment(Parser *p);
-
-static int begin_string(Parser *p, char c);
-static int state_string(Parser *p, char c);
-static int end_string(Parser *p);
-static int state_escape(Parser *p, char c);
-static int state_octal(Parser *p, char c);
-static int state_hex(Parser *p, char c);
-
-static int begin_atom(Parser *p, char c);
-static int state_atom(Parser *p, char c);
-static int end_atom(Parser *p);
-
-static int state_list(Parser *p, char c);
-static int begin_list(Parser *p, char c);
-static int end_list(Parser *p);
+static int begin_start(Parser *p, char c);
 
+#if 0
 /** Print a parse error.
  *
  * @param in parser
  * @param msg format followed by printf arguments
  */
-void eprintf(Parser *in, char *msg, ...){
+static void eprintf(Parser *in, char *msg, ...){
     va_list args;
     if(in->error_out){
         va_start(args, msg);
@@ -94,7 +76,7 @@
  * @param in parser
  * @param msg format followed by printf arguments
  */
-void wprintf(Parser *in, char *msg, ...){
+static void wprintf(Parser *in, char *msg, ...){
     va_list args;
     if(in->error_out){
         va_start(args, msg);
@@ -102,13 +84,15 @@
         va_end(args);
     }
 }
+#endif
+
 
 
/*============================================================================*/
 
 /** Record defining the message for a parse error. */
 typedef struct {
-  ParseErrorId id;
-  char *message;
+    ParseErrorId id;
+    char *message;
 } ParseError;
 
 /** Format for printing parse error messages. */
@@ -116,156 +100,245 @@
 
 /** Message catalog for the parse error codes. */
 static ParseError catalog[] = {
-  { PARSE_ERR_UNSPECIFIED,            "unspecified error" },
-  { PARSE_ERR_NOMEM,                  "out of memory" },
-  { PARSE_ERR_UNEXPECTED_EOF,         "unexpected end of input" },
-  { PARSE_ERR_TOKEN_TOO_LONG,         "token too long" },
-  { PARSE_ERR_INVALID_SYNTAX,         "syntax error" },
-  { PARSE_ERR_INVALID_ESCAPE,         "invalid escape" },
-  { 0, NULL }
+    { PARSE_ERR_UNSPECIFIED,            "unspecified error" },
+    { PARSE_ERR_NOMEM,                  "out of memory" },
+    { PARSE_ERR_UNEXPECTED_EOF,         "unexpected end of input" },
+    { PARSE_ERR_TOKEN_TOO_LONG,         "token too long" },
+    { PARSE_ERR_INVALID_SYNTAX,         "syntax error" },
+    { PARSE_ERR_INVALID_ESCAPE,         "invalid escape" },
+    { 0, NULL }
 };
 
 /** Number of entries in the message catalog. */
 const static int catalog_n = sizeof(catalog)/sizeof(ParseError);
 
-void ParserState_free(ParserState *z){
-    if(!z) return;
-    objfree(z->val);
-    deallocate(z);
+/** Set the parser error stream.
+ * Parse errors are reported on the the error stream if it is non-null.
+ * 
+ * @param z parser
+ * @param error_out error stream
+ */
+void Parser_set_error_stream(Parser *z, IOStream *error_out){
+    z->error_out = error_out;
 }
 
-int ParserState_new(ParserStateFn *fn, char *name,
-                    ParserState *parent, ParserState **val){
-    int err = 0;
-    ParserState *z;
-    z = ALLOCATE(ParserState);
-    if(z){
-        z->name = name;
-        z->fn = fn;
-        z->parent = parent;
-        z->val = ONULL;
-    } else {
-        err = -ENOMEM;
+/** Get the parser error message for an error code.
+ *
+ * @param id error code
+ * @return error message (empty string if the code is unknown)
+ */
+static char *get_message(ParseErrorId id){
+    int i;
+    for(i = 0; i < catalog_n; i++){
+        if(id == catalog[i].id){
+            return catalog[i].message;
+        }
     }
-    if(!err) *val = z;
-    return err;
+    return "";
 }
 
-/** Free a parser.
- * No-op if the parser is null.
+#if 0
+/** Get the line number.
  *
- * @param z parser 
+ * @param in parser
  */
-void Parser_free(Parser *z){
-    if(!z) return;
-    objfree(z->val);
-    z->val = ONONE;
-    deallocate(z);
+static int get_line(Parser *in){
+    return in->line_no;
 }
 
-/** Create a new parser. The error stream defaults to null.
+/** Get the column number.
+ *
+ * @param in parser
  */
-Parser * Parser_new(void){
-    Parser *z = ALLOCATE(Parser);
-    int err = -ENOMEM;
-  
-    if(!z) goto exit;
-    err = 0;
-    reset(z);
-  exit:
-    if(err){
-        Parser_free(z);
-        z = NULL;
-    }
-    return z;
+static int get_column(Parser *in){
+    return in->char_no;
 }
+#endif
 
-/** Get the next character.
- * Records the character read in the parser,
- * and sets the line and character counts.
+/** Get the line number the current token started on.
+ *
+ * @param in parser
+ */
+static int get_tok_line(Parser *in){
+    return in->tok_begin_line;
+}
+
+/** Get the column number the current token started on.
+ *
+ * @param in parser
+ */
+static int get_tok_column(Parser *in){
+    return in->tok_begin_char;
+}
+
+/** Return the current token.
+ * The return value points at the internal buffer, so
+ * it must not be modified (or freed). Use copy_token() if you need a copy.
  *
  * @param p parser
- * @return error flag: 0 on success, non-zero on error
+ * @return token
  */
-static int inputchar(Parser *p, char c){
-    int err = 0;
-    if(c=='\n'){
-        p->line_no++;
-        p->char_no = 0;
-    } else {
-        p->char_no++;
-    }
-    return err;
+char *peek_token(Parser *p){
+    return p->tok;
 }
 
-static int savechar(Parser *p, char c){
-    int err = 0;
-    if(p->buf_i >= p->buf_n){
-        err = -ENOMEM;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Merge firebug.cl.cam.ac.uk:/local/scratch/smh22/xen-unstable.bk, BitKeeper Bot <=