changeset 1060:8c1a25cdfa81

[project @ 1995-01-23 00:10:03 by jwe]
author jwe
date Mon, 23 Jan 1995 00:10:03 +0000
parents 7f42e76331b0
children a08b7d48e3bc
files src/lex.h src/lex.l src/parse.y src/pt-exp-base.cc
diffstat 4 files changed, 36 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/lex.h	Mon Jan 23 00:01:39 1995 +0000
+++ b/src/lex.h	Mon Jan 23 00:10:03 1995 +0000
@@ -57,6 +57,15 @@
     } \
   while (0)
 
+#define TOK_PUSH_AND_RETURN(name,tok) \
+  do \
+    { \
+      yylval.tok_val = new token (input_line_number, current_input_column); \
+      token_stack.push (yylval.tok_val); \
+      TOK_RETURN (tok); \
+    } \
+  while (0)
+
 #define BIN_OP_RETURN(tok,convert) \
   do \
     { \
--- a/src/lex.l	Mon Jan 23 00:01:39 1995 +0000
+++ b/src/lex.l	Mon Jan 23 00:10:03 1995 +0000
@@ -164,9 +164,7 @@
 <TEXT_FCN>[\;\,] {
     if (doing_set && strcmp (yytext, ",") == 0)
       {
-	yylval.tok_val = new token (yytext);
-	token_stack.push (yylval.tok_val);
-	TOK_RETURN (TEXT);
+	TOK_PUSH_AND_RETURN (yytext, TEXT);
       }
     else
       {
@@ -188,9 +186,7 @@
     static char *tok = 0;
     delete [] tok;
     tok = strip_trailing_whitespace (yytext);
-    yylval.tok_val = new token (tok);
-    token_stack.push (yylval.tok_val);
-    TOK_RETURN (TEXT);
+    TOK_PUSH_AND_RETURN (tok, TEXT);
   }
 
 %{
@@ -379,7 +375,6 @@
     static char *tok = 0;
     delete [] tok;
     tok = strip_trailing_whitespace (yytext);
-    current_input_column += yyleng;
     int c = yytext[yyleng-1];
     int cont_is_spc = eat_continuation ();
     int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t');
@@ -1688,11 +1683,7 @@
 // TEXT_ID, which is a string that is also a valid identifier.
 
   if (looking_at_indirect_ref)
-    {
-      yylval.tok_val = new token (tok);
-      token_stack.push (yylval.tok_val);
-      TOK_RETURN (TEXT_ID);
-    }
+    TOK_PUSH_AND_RETURN (tok, TEXT_ID);
 
 // If we have a regular keyword, or a plot STYLE, return it.  Keywords
 // can be followed by identifiers (TOK_RETURN handles that).
@@ -1702,6 +1693,7 @@
     {
       if (kw_token == STYLE)
 	{
+	  current_input_column += yyleng;
 	  quote_is_transpose = 0;
 	  convert_spaces_to_comma = 1;
 	  return kw_token;
@@ -1776,6 +1768,7 @@
 
   if (next_tok_is_eq)
     {
+      current_input_column += yyleng;
       if (defining_func && maybe_screwed)
 	return SCREW;
       else
@@ -1813,6 +1806,7 @@
 	unput (',');
     }
 
+  current_input_column += yyleng;
   return NAME;
 }
 
--- a/src/parse.y	Mon Jan 23 00:01:39 1995 +0000
+++ b/src/parse.y	Mon Jan 23 00:10:03 1995 +0000
@@ -635,17 +635,17 @@
 		  }
 		| BREAK
 		  {
-		    if (!looping)
+		    if (! (looping || defining_func))
 		      {
-			yyerror ("break: only meaningful within a `for'\
- or `while' loop");
+			yyerror ("break: only meaningful within a loop\
+ or function body");
 			ABORT_PARSE;
 		      }
 		    $$ = new tree_break_command ($1->line (), $1->column ());
 		  }
 		| CONTINUE
 		  {
-		    if (!looping)
+		    if (! looping)
 		      {
 			yyerror ("continue: only meaningful within a\
  `for' or `while' loop");
@@ -656,7 +656,7 @@
 		  }
 		| FUNC_RET
 		  {
-		    if (!defining_func)
+		    if (! defining_func)
 		      {
 			yyerror ("return: only meaningful within a function");
 			ABORT_PARSE;
@@ -1186,8 +1186,6 @@
 {
   char *line = current_input_line;
   int err_col = current_input_column - 1;
-  if (err_col == 0 && line)
-    err_col = strlen (line) + 1;
 
   ostrstream output_buf;
 
@@ -1205,6 +1203,7 @@
   if (line)
     {
       int len = strlen (line);
+
       if (line[len-1] == '\n')
         {
           len--;
@@ -1213,13 +1212,15 @@
 
 // Print the line, maybe with a pointer near the error token.
 
-      output_buf << "  " << line << "\n";
-      if (err_col <= len)
-	{
-	  for (int i = 0; i < err_col + 1; i++)
-	    output_buf << " ";
-	  output_buf << "^";
-	}
+      output_buf << ">>> " << line << "\n";
+
+      if (err_col == 0)
+	err_col = len;
+
+      for (int i = 0; i < err_col + 3; i++)
+	output_buf << " ";
+
+      output_buf << "^";
     }
 
   output_buf << "\n" << ends;
--- a/src/pt-exp-base.cc	Mon Jan 23 00:01:39 1995 +0000
+++ b/src/pt-exp-base.cc	Mon Jan 23 00:10:03 1995 +0000
@@ -61,6 +61,9 @@
 // Nonzero means we're returning from a function.
 extern int returning;
 
+// Nonzero means we're breaking out of a loop or function body.
+extern int breaking;
+
 // But first, some extra functions used by the tree classes.
 
 // We seem to have no use for this now.  Maybe it will be needed at
@@ -2773,6 +2776,9 @@
     if (returning)
       returning = 0;
 
+    if (breaking)
+      breaking--;
+
     if (error_state)
       {
 	traceback_error ();