[Tinyos-commits] CVS: tinyos-1.x/tos/lib/VM/languages/motlle/standalone lexer.h, 1.3, 1.4 lexer.l, 1.6, 1.7 motlle.c, 1.4, 1.5 mparser.c, 1.5, 1.6 parser.y, 1.5, 1.6 tokens.h, 1.3, 1.4

David Gay idgay at users.sourceforge.net
Tue Oct 25 15:33:23 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26029/standalone

Modified Files:
	lexer.h lexer.l motlle.c mparser.c parser.y tokens.h 
Log Message:
-s option to mload to specify scheme code


Index: lexer.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/lexer.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** lexer.h	7 Oct 2005 17:15:11 -0000	1.3
--- lexer.h	25 Oct 2005 22:33:21 -0000	1.4
***************
*** 31,36 ****
  int yylex(void);
  
! void read_from_string(const char *str);
! void read_from_file(FILE *f);
  
  void scheme_lexing(void);
--- 31,36 ----
  int yylex(void);
  
! void read_from_string(const char *str, bool is_scheme);
! void read_from_file(FILE *f, bool is_scheme);
  
  void scheme_lexing(void);

Index: lexer.l
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/lexer.l,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** lexer.l	25 Oct 2005 22:00:41 -0000	1.6
--- lexer.l	25 Oct 2005 22:33:21 -0000	1.7
***************
*** 32,35 ****
--- 32,37 ----
  #include "types.h"
  
+ #define YY_DECL static int yylex_internal(void)
+ 
  /* We never wrap into another file */
  #define YY_SKIP_YYWRAP
***************
*** 50,53 ****
--- 52,56 ----
  static int length;
  struct location lexloc;
+ static bool schemefile;
  
  struct lkeyword {
***************
*** 76,80 ****
    { "writes", WRITES },
    { "defines", DEFINES },
!   { "scheme", SCHEME }
  };
  #define NKEYWORDS (sizeof keywords / sizeof(struct lkeyword))
--- 79,84 ----
    { "writes", WRITES },
    { "defines", DEFINES },
!   { "scheme", SCHEME },
!   { "schemefile", SCHEMEFILE }
  };
  #define NKEYWORDS (sizeof keywords / sizeof(struct lkeyword))
***************
*** 259,263 ****
  
  
! void read_from_file(FILE *f)
  {
    if (!mbuf) mbuf = yy_create_buffer(f, YY_BUF_SIZE);
--- 263,267 ----
  
  
! void read_from_file(FILE *f, bool is_scheme)
  {
    if (!mbuf) mbuf = yy_create_buffer(f, YY_BUF_SIZE);
***************
*** 268,274 ****
    line_read = FALSE;
    lexloc.lineno = 1;
  }
  
! void read_from_string(const char *str)
  {
    if (!mbuf) mbuf = yy_create_buffer(stdin, YY_BUF_SIZE);
--- 272,280 ----
    line_read = FALSE;
    lexloc.lineno = 1;
+   normal_lexing();
+   schemefile = is_scheme;
  }
  
! void read_from_string(const char *str, bool is_scheme)
  {
    if (!mbuf) mbuf = yy_create_buffer(stdin, YY_BUF_SIZE);
***************
*** 281,284 ****
--- 287,292 ----
    length = strlen(line);
    lexloc.lineno = 0;
+   normal_lexing();
+   schemefile = is_scheme;
  }
  
***************
*** 293,295 ****
  }
  
! 
--- 301,313 ----
  }
  
! int yylex(void)
! {
!   /* Force a SCHEMEFILE token to dispatch to the correct grammar rule,
!      when requested */
!   if (schemefile)
!     {
!       schemefile = FALSE;
!       return SCHEMEFILE;
!     }
!   return yylex_internal();
! }

Index: motlle.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/motlle.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** motlle.c	19 May 2005 17:23:48 -0000	1.4
--- motlle.c	25 Oct 2005 22:33:21 -0000	1.5
***************
*** 94,98 ****
  	  }
  #endif
! 	  read_from_string(frame->line);
  	  frame->state = print_result;
  	  context.display_error = TRUE;
--- 94,98 ----
  	  }
  #endif
! 	  read_from_string(frame->line, FALSE);
  	  frame->state = print_result;
  	  context.display_error = TRUE;
***************
*** 172,176 ****
      }
    push_frame(mload_action, sizeof(struct generic_frame));
!   read_from_file(f);
    compile_and_run(NULL, globals, fname, NULL, FALSE);
  }
--- 172,176 ----
      }
    push_frame(mload_action, sizeof(struct generic_frame));
!   read_from_file(f, FALSE);
    compile_and_run(NULL, globals, fname, NULL, FALSE);
  }

Index: mparser.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/mparser.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** mparser.c	25 Oct 2005 22:00:41 -0000	1.5
--- mparser.c	25 Oct 2005 22:33:21 -0000	1.6
***************
*** 65,95 ****
       ELLIPSIS = 274,
       DO = 275,
!      SCHEME = 276,
!      MODULE = 277,
!      LIBRARY = 278,
!      IMPORTS = 279,
!      DEFINES = 280,
!      READS = 281,
!      WRITES = 282,
!      INTEGER = 283,
[...3257 lines suppressed...]
  
--- 2476,2480 ----
  # undef YYRECOVERING
  /* Line 671 of glr.c.  */
! #line 2478 "parser.tab.c"
  }
  
***************
*** 3731,3735 ****
  
  
! #line 763 "../standalone/parser.y"
  
  
--- 3759,3763 ----
  
  
! #line 777 "../standalone/parser.y"
  
  

Index: parser.y
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/parser.y,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** parser.y	25 Oct 2005 22:00:41 -0000	1.5
--- parser.y	25 Oct 2005 22:33:21 -0000	1.6
***************
*** 61,65 ****
  %token <symbol> FUNCTION IF ELSE WHILE FOR ASSIGN QUOTE BREAK CONTINUE RETURN
  %token <symbol> SYMBOL BIGINT SINK SWITCH CASE DEFAULT
! %token <symbol> ELLIPSIS DO SCHEME
  %token <symbol> MODULE LIBRARY IMPORTS DEFINES READS WRITES 
  %token <integer> INTEGER
--- 61,65 ----
  %token <symbol> FUNCTION IF ELSE WHILE FOR ASSIGN QUOTE BREAK CONTINUE RETURN
  %token <symbol> SYMBOL BIGINT SINK SWITCH CASE DEFAULT
! %token <symbol> ELLIPSIS DO
  %token <symbol> MODULE LIBRARY IMPORTS DEFINES READS WRITES 
  %token <integer> INTEGER
***************
*** 67,71 ****
  %token <mudlle_float> FLOAT
  %token <operator> OP_ASSIGN INCREMENTER
! 
  
  %right '.'
--- 67,71 ----
  %token <mudlle_float> FLOAT
  %token <operator> OP_ASSIGN INCREMENTER
! %token <symbol> SCHEME SCHEMEFILE
  
  %right '.'
***************
*** 106,109 ****
--- 106,111 ----
  %type <tmatchcond> match_pattern match_patterns
  %type <tmatchnodelist> match_list
+ %type <tcomponent> scheme_expression
+ %type <tclist> scheme_file scheme_file1
  
  %glr-parser
***************
*** 331,338 ****
    module ;
  
! simple : stmt_list 
!  { $$ = new_file(parser_memory, f_plain, NULL, NULL, NULL, NULL, NULL, $1); } |
!  expression 
!  { $$ = new_file(parser_memory, f_plain, NULL, NULL, NULL, NULL, NULL, new_clist(parser_memory, $1, NULL)); } ;
  
  module : MODULE optional_symbol imports reads writes '[' stmt_list ']' optional_semi
--- 333,349 ----
    module ;
  
! simple : 
!   stmt_list 
!     { $$ = new_file(parser_memory, f_plain, NULL, NULL, NULL, NULL, NULL, $1); } |
!   expression 
!      { $$ = new_file(parser_memory, f_plain, NULL, NULL, NULL, NULL, NULL, new_clist(parser_memory, $1, NULL)); } |
!   SCHEMEFILE { scheme_lexing(); } scheme_file 
!     { $$ = new_file(parser_memory, f_plain, NULL, NULL, NULL, NULL, NULL, $3); } ;
! 
! scheme_file : scheme_file1 { $$ = reverse_clist($1); } ;
! 
! scheme_file1 :
!   scheme_file1 scheme_expression { $$ = new_clist(parser_memory, $2, $1); } |
!   scheme_expression { $$ = new_clist(parser_memory, $1, NULL); } ;
  
  module : MODULE optional_symbol imports reads writes '[' stmt_list ']' optional_semi
***************
*** 393,399 ****
  expression : 
    control_expression |
!   SCHEME { scheme_lexing(); } constant { normal_lexing(); $$ = new_component(parser_memory, c_scheme, $3); } |
    e0 ;
  
  optional_expression :
    expression |
--- 404,413 ----
  expression : 
    control_expression |
!   SCHEME { scheme_lexing(); } scheme_expression { normal_lexing(); $$ = $3; } |
    e0 ;
  
+ scheme_expression :
+   constant { $$ = new_component(parser_memory, c_scheme, $1); } ;
+ 
  optional_expression :
    expression |

Index: tokens.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/tokens.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tokens.h	6 Oct 2005 23:38:01 -0000	1.3
--- tokens.h	25 Oct 2005 22:33:21 -0000	1.4
***************
*** 43,73 ****
       ELLIPSIS = 274,
       DO = 275,
!      SCHEME = 276,
!      MODULE = 277,
!      LIBRARY = 278,
!      IMPORTS = 279,
!      DEFINES = 280,
!      READS = 281,
!      WRITES = 282,
!      INTEGER = 283,
!      STRING = 284,
!      FLOAT = 285,
!      OP_ASSIGN = 286,
!      INCREMENTER = 287,
!      XOR = 288,
!      OR = 289,
!      SC_OR = 290,
!      AND = 291,
!      SC_AND = 292,
!      GE = 293,
!      GT = 294,
!      LE = 295,
!      LT = 296,
!      NE = 297,
!      EQ = 298,
!      SHIFT_RIGHT = 299,
!      SHIFT_LEFT = 300,
!      UMINUS = 301,
!      NOT = 302
     };
  #endif
--- 43,74 ----
       ELLIPSIS = 274,
       DO = 275,
!      MODULE = 276,
!      LIBRARY = 277,
!      IMPORTS = 278,
!      DEFINES = 279,
!      READS = 280,
!      WRITES = 281,
!      INTEGER = 282,
!      STRING = 283,
!      FLOAT = 284,
!      OP_ASSIGN = 285,
!      INCREMENTER = 286,
!      SCHEME = 287,
!      SCHEMEFILE = 288,
!      XOR = 289,
!      OR = 290,
!      SC_OR = 291,
!      AND = 292,
!      SC_AND = 293,
!      GE = 294,
!      GT = 295,
!      LE = 296,
!      LT = 297,
!      NE = 298,
!      EQ = 299,
!      SHIFT_RIGHT = 300,
!      SHIFT_LEFT = 301,
!      UMINUS = 302,
!      NOT = 303
     };
  #endif
***************
*** 90,120 ****
  #define ELLIPSIS 274
  #define DO 275
! #define SCHEME 276
! #define MODULE 277
! #define LIBRARY 278
! #define IMPORTS 279
! #define DEFINES 280
! #define READS 281
! #define WRITES 282
! #define INTEGER 283
! #define STRING 284
! #define FLOAT 285
! #define OP_ASSIGN 286
! #define INCREMENTER 287
! #define XOR 288
! #define OR 289
! #define SC_OR 290
! #define AND 291
! #define SC_AND 292
! #define GE 293
! #define GT 294
! #define LE 295
! #define LT 296
! #define NE 297
! #define EQ 298
! #define SHIFT_RIGHT 299
! #define SHIFT_LEFT 300
! #define UMINUS 301
! #define NOT 302
  
  
--- 91,122 ----
  #define ELLIPSIS 274
  #define DO 275
! #define MODULE 276
! #define LIBRARY 277
! #define IMPORTS 278
! #define DEFINES 279
! #define READS 280
! #define WRITES 281
! #define INTEGER 282
! #define STRING 283
! #define FLOAT 284
! #define OP_ASSIGN 285
! #define INCREMENTER 286
! #define SCHEME 287
! #define SCHEMEFILE 288
! #define XOR 289
! #define OR 290
! #define SC_OR 291
! #define AND 292
! #define SC_AND 293
! #define GE 294
! #define GT 295
! #define LE 296
! #define LT 297
! #define NE 298
! #define EQ 299
! #define SHIFT_RIGHT 300
! #define SHIFT_LEFT 301
! #define UMINUS 302
! #define NOT 303
  
  
***************
*** 147,151 ****
  } YYSTYPE;
  /* Line 1985 of glr.c.  */
! #line 149 "parser.tab.h"
  # define YYSTYPE_IS_DECLARED 1
  # define YYSTYPE_IS_TRIVIAL 1
--- 149,153 ----
  } YYSTYPE;
  /* Line 1985 of glr.c.  */
! #line 151 "parser.tab.h"
  # define YYSTYPE_IS_DECLARED 1
  # define YYSTYPE_IS_TRIVIAL 1



More information about the Tinyos-commits mailing list