texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[6834] parsetexi update


From: Gavin D. Smith
Subject: [6834] parsetexi update
Date: Sat, 05 Dec 2015 16:51:14 +0000

Revision: 6834
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6834
Author:   gavin
Date:     2015-12-05 16:51:13 +0000 (Sat, 05 Dec 2015)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/ChangeLog
    trunk/parsetexi/close.c
    trunk/parsetexi/command_data.txt
    trunk/parsetexi/command_ids.h
    trunk/parsetexi/commands.h
    trunk/parsetexi/end_line.c
    trunk/parsetexi/handle_commands.c
    trunk/parsetexi/handle_commands.h
    trunk/parsetexi/macro.c
    trunk/parsetexi/parser.c
    trunk/parsetexi/parser.h
    trunk/parsetexi/separator.c

Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog   2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/ChangeLog   2015-12-05 16:51:13 UTC (rev 6834)
@@ -1,5 +1,9 @@
 2015-12-05  Gavin Smith  <address@hidden>
 
+       * commands.h (CF_global, CF_global_unique): New flags.
+
+2015-12-05  Gavin Smith  <address@hidden>
+
        * errors.c (command_warnf, command_errorf): Implement.
 
 2015-12-01  Gavin Smith  <address@hidden>

Modified: trunk/parsetexi/close.c
===================================================================
--- trunk/parsetexi/close.c     2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/close.c     2015-12-05 16:51:13 UTC (rev 6834)
@@ -319,7 +319,7 @@
 {
   *closed_element = 0;
   current = end_paragraph (current, closed_command, interrupting);
-  current = end_preformatted (current);
+  current = end_preformatted (current, closed_command, interrupting);
 
   while (current->parent
          && (!closed_command || current->cmd != closed_command)

Modified: trunk/parsetexi/command_data.txt
===================================================================
--- trunk/parsetexi/command_data.txt    2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/command_data.txt    2015-12-05 16:51:13 UTC (rev 6834)
@@ -59,83 +59,83 @@
 # number of arguments is not known in advance.
 columnfractions                misc            1
 # file names
-setfilename            misc            MISC_text
+setfilename            misc,global_unique              MISC_text
 verbatiminclude                misc            MISC_text
 include                misc            MISC_text
 
 raisesections                  misc            MISC_skipline
 lowersections                  misc            MISC_skipline
-contents                       misc            MISC_skipline
-shortcontents                  misc            MISC_skipline
+contents                       misc,global             MISC_skipline
+shortcontents                  misc,global             MISC_skipline
 summarycontents                        misc            MISC_skipline
-insertcopying                  misc            MISC_noarg
-clickstyle                     misc            MISC_special
+insertcopying                  misc,global             MISC_noarg
+clickstyle                     misc,global             MISC_special
 # more relevant in preamble
-setcontentsaftertitlepage      misc            MISC_skipline
-setshortcontentsaftertitlepage misc            MISC_skipline
-documentencoding               misc    MISC_text
-novalidate                     misc            MISC_skipline
+setcontentsaftertitlepage      misc,global_unique              MISC_skipline
+setshortcontentsaftertitlepage misc,global_unique              MISC_skipline
+documentencoding               misc,global     MISC_text
+novalidate                     misc,global_unique      MISC_skipline
+validatemenus                  misc,global_unique      1
 dircategory                    misc            MISC_line
 # with direntry is significant
-pagesizes                      misc            MISC_line
+pagesizes                      misc,global_unique      MISC_line
 # or one? 200mm,150mm 11.5in
 finalout                       misc            MISC_skipline
-paragraphindent                        misc            1
+paragraphindent                        misc,global             1
 # or a number and forbids anything else on the line
-firstparagraphindent           misc            1
-frenchspacing                  misc            1
-codequoteundirected            misc            1
-codequotebacktick              misc            1
-xrefautomaticsectiontitle      misc            1
-deftypefnnewline               misc            1
-fonttextsize                   misc            1
-allowcodebreaks                        misc            1
-exampleindent                  misc            1
-footnotestyle                  misc            1
-urefbreakstyle                 misc            1
+firstparagraphindent           misc,global             1
+frenchspacing                  misc,global             1
+codequoteundirected            misc,global             1
+codequotebacktick              misc,global             1
+xrefautomaticsectiontitle      misc,global             1
+deftypefnnewline               misc,global             1
+fonttextsize                   misc,global_unique              1
+allowcodebreaks                        misc,global                     1
+exampleindent                  misc,global             1
+footnotestyle                  misc,global_unique              1
+urefbreakstyle                 misc,global             1
 afourpaper                     misc            MISC_skipline
 afivepaper                     misc            MISC_skipline
 afourlatex                     misc            MISC_skipline
 afourwide                      misc            MISC_skipline
-headings                       misc            1
-# interacts with setchapternewpage
-setchapternewpage              misc            1
+headings                       misc,global             1
+setchapternewpage              misc,global_unique              1
 
 # only relevant in TeX, and special
-everyheading                   misc            MISC_lineraw
-everyfooting                   misc            MISC_lineraw
-evenheading                    misc            MISC_lineraw
-evenfooting                    misc            MISC_lineraw
-oddheading                     misc            MISC_lineraw
-oddfooting                     misc            MISC_lineraw
+everyheading                   misc,global_unique              MISC_lineraw
+everyfooting                   misc,global_unique              MISC_lineraw
+evenheading                    misc,global_unique              MISC_lineraw
+evenfooting                    misc,global_unique              MISC_lineraw
+oddheading                     misc,global_unique              MISC_lineraw
+oddfooting                     misc,global_unique              MISC_lineraw
 
 smallbook                      misc            MISC_skipline
 syncodeindex                   misc            2
 synindex                       misc            2
 defindex                       misc            1
 defcodeindex                   misc            1
-documentlanguage               misc            MISC_text
-kbdinputstyle                  misc            1
-everyheadingmarks              misc            1
-everyfootingmarks              misc            1
-evenheadingmarks               misc            1
-oddheadingmarks                        misc            1
-evenfootingmarks               misc            1
-oddfootingmarks                        misc            1
+documentlanguage               misc,global             MISC_text
+kbdinputstyle                  misc,global             1
+everyheadingmarks              misc,global_unique              1
+everyfootingmarks              misc,global_unique              1
+evenheadingmarks               misc,global_unique              1
+oddheadingmarks                        misc,global_unique              1
+evenfootingmarks               misc,global_unique              1
+oddfootingmarks                        misc,global_unique              1
 # not valid for info (should be in @iftex)
 cropmarks                      misc            MISC_skipline
 
 # formatting
 center                         misc            MISC_line
-printindex                     misc            1
-listoffloats                   misc            MISC_line
+printindex                     misc,global             1
+listoffloats                   misc,global             MISC_line
 # especially in titlepage
 #  shorttitle
-shorttitlepage                 misc            MISC_line
-settitle                       misc            MISC_line
-author                         misc            MISC_line
-subtitle                       misc            MISC_line
-title                          misc            MISC_line
+shorttitlepage                 misc,global_unique      MISC_line
+settitle                       misc,global_unique      MISC_line
+author                         misc,global             MISC_line
+subtitle                       misc,global             MISC_line
+title                          misc,global_unique      MISC_line
 sp                             misc            1
 page                           misc            MISC_skipline
 need                           misc            1
@@ -295,12 +295,12 @@
 # are said to take 1 argument in Common.pm.
 ctrl           brace   1
 dmn            brace   1
-titlefont      brace   1
+titlefont      brace,global    1
 
 w              brace   BRACE_other
 key            brace   BRACE_other
 
-hyphenation    brace   BRACE_other
+hyphenation    brace,global    BRACE_other
 anchor         brace   1
 errormsg       brace   1
 
@@ -318,7 +318,7 @@
 t              brace   BRACE_other
 
 # context brace commands - commands that enclose full texts
-footnote       brace   BRACE_context
+footnote       brace,global    BRACE_context
 caption                brace   BRACE_context
 shortcaption   brace   BRACE_context
 math           brace   BRACE_context
@@ -404,7 +404,7 @@
 
 # menu commands
 menu                   block,menu
-detailmenu             block,menu
+detailmenu             block,menu,global
 direntry               block,menu
 
 # align commands
@@ -419,9 +419,9 @@
 smallindentedblock     block
 
 # region commands
-titlepage              block
-copying                        block
-documentdescription    block
+titlepage              block,global_unique
+copying                        block,global_unique
+documentdescription    block,global_unique
 
 # preformatted commands
 example                        block,preformatted,preformatted_code
@@ -480,7 +480,7 @@
 ##########################################################
 # Root commands - line 887
 node                   root,misc                       MISC_line
-top                    root,misc,sectioning            MISC_line
+top                    root,misc,sectioning,global_unique      MISC_line
 chapter                        root,misc,sectioning            MISC_line
 unnumbered             root,misc,sectioning            MISC_line
 chapheading            misc,sectioning                 MISC_line
@@ -498,7 +498,7 @@
 subsubheading          misc,sectioning                 MISC_line
 appendixsubsubsec      root,misc,sectioning            MISC_line
 
-part                   root,misc,sectioning    MISC_line
+part                   root,misc,sectioning,global     MISC_line
 appendixsection                root,misc,sectioning    MISC_line
 majorheading           misc,sectioning         MISC_line
 centerchap             root,misc,sectioning    MISC_line

Modified: trunk/parsetexi/command_ids.h
===================================================================
--- trunk/parsetexi/command_ids.h       2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/command_ids.h       2015-12-05 16:51:13 UTC (rev 6834)
@@ -365,6 +365,7 @@
 CM_urefbreakstyle,
 CM_url,
 CM_v,
+CM_validatemenus,
 CM_value,
 CM_var,
 CM_verb,

Modified: trunk/parsetexi/commands.h
===================================================================
--- trunk/parsetexi/commands.h  2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/commands.h  2015-12-05 16:51:13 UTC (rev 6834)
@@ -60,7 +60,7 @@
 #define CF_block                       0x2000
 #define CF_raw                         0x4000
 #define CF_format_raw                  0x8000
-// #define free                        0x00010000
+#define CF_global                      0x00010000
 #define CF_def                         0x00020000
 #define CF_def_alias                   0x00040000
 #define CF_menu                                0x00080000
@@ -75,7 +75,7 @@
 #define CF_inline                      0x10000000
 #define CF_MACRO                       0x20000000
 #define CF_index_entry_command         0x40000000
-// #define free                        0x80000000
+#define CF_global_unique               0x80000000
 
 /* Types of misc command (has CF_misc flag).  Values for COMMAND.data. */
 /* See Common.pm:376 */

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/end_line.c  2015-12-05 16:51:13 UTC (rev 6834)
@@ -60,6 +60,7 @@
 }
 
 /* Process argument to special line command. */
+// 5377
 ELEMENT *
 parse_special_misc_command (char *line, enum command_id cmd
                            /* , int *has_comment */)
@@ -72,6 +73,7 @@
 
   ELEMENT *args = new_element (ET_NONE);
   char *p, *q;
+  char *value;
 
   switch (cmd)
     {
@@ -99,7 +101,9 @@
 
       /* TODO: Skip optional comment. */
       /* This is strange - how can you have a comment in the middle
-         of a line?  And what does "@comment@" mean? */
+         of a line?  And what does "@comment@" mean?
+         I guess this is following TeX syntax in ending reading a control
+         sequence name at an escape character. */
 
       p = q + strspn (q, whitespace_chars);
       /* Actually, whitespace characters except form feed. */
@@ -129,9 +133,45 @@
     case CM_clear:
       break;
     case CM_unmacro:
+      p = line;
+      p += strspn (p, whitespace_chars);
+      if (!*p)
+        goto unmacro_noname;
+      q = p;
+      value = read_command_name (&q);
+      if (!value)
+        goto unmacro_badname;
+      /* TODO: Check comment syntax is right */
+      delete_macro (value);
+      ADD_ARG(value, q - p);
+      debug ("UNMACRO %s", value);
+      free (value);
       break;
+unmacro_noname:
+      line_error ("@unmacro requires a name");
+      break;
+unmacro_badname:
+      line_error ("bad name for @unmacro");
+      break;
     case CM_clickstyle:
+      p = line;
+      p += strspn (p, whitespace_chars);
+      if (*p++ != '@')
+        goto clickstyle_invalid;
+      q = p;
+      value = read_command_name (&q);
+      if (!value)
+        goto clickstyle_invalid;
+      ADD_ARG (p - 1, q - p + 1);
+      if (memcmp (q, "{}", 2))
+        q += 2;
+      free (value);
+      /* TODO: check comment */
       break;
+clickstyle_invalid:
+      line_errorf ("@clickstyle should only accept an @-command as argument, "
+                   "not `%s'", line);
+      break;
     default:
       abort ();
     }

Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c   2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/handle_commands.c   2015-12-05 16:51:13 UTC (rev 6834)
@@ -41,15 +41,42 @@
   return 0;
 }
 
+// 1056
+/* Record the information from a command of global effect. */
+static int
+register_global_command (enum command_id cmd, ELEMENT *current)
+{
+  if (cmd == CM_shortcontents)
+    cmd == CM_summarycontents;
+
+  // TODO: Why even give @author this flag in the first place?
+  if (cmd != CM_author && (command_data(cmd).flags & CF_global))
+    {
+      if (!current->line_nr.line_nr)
+        current->line_nr = line_nr;
+      return 1;
+    }
+  else if ((command_data(cmd).flags & CF_global_unique))
+    {
+      if (!current->line_nr.line_nr)
+        current->line_nr = line_nr;
+      return 1;
+    }
+
+  return 0;
+}
+
 /* Line 4289 */
+/* STATUS is set to 1 if we should get a new line after this. */
 ELEMENT *
 handle_misc_command (ELEMENT *current, char **line_inout,
-                     enum command_id cmd)
+                     enum command_id cmd, int *status)
 {
   ELEMENT *misc = 0;
   char *line = *line_inout;
   int arg_spec;
 
+  *status = 0;
   /* Root commands (like @node) and @bye 4290 */
   if (command_data(cmd).flags & CF_root || cmd == CM_bye)
     {
@@ -92,9 +119,14 @@
            || arg_spec == MISC_special)
     {
       ELEMENT *args = 0;
-      /* 4350 TODO: If the current input is the result of a macro expansion,
+      /* 4350 If the current input is the result of a macro expansion,
          it may not be a complete line.  Check for this and acquire the rest
          of the line if necessary. */
+      if (!strchr (line, '\n'))
+        {
+          input_push_text (strdup (line));
+          line = new_line ();
+        }
 
       misc = new_element (ET_NONE);
       misc->cmd = cmd;
@@ -151,17 +183,23 @@
         } */
 
       // mark_and_warn_invalid ();
-      // register_global_command ();
+      register_global_command (cmd, misc); // 4423
 
       if (arg_spec != MISC_special /* || !has_comment */ )
         current = end_line (current);
 
-      // 4429 TODO @bye
+      // 4429
+      if (cmd == CM_bye)
+        {
+          // last NEXT_LINE
+        }
 
       if (close_preformatted_command(cmd))
         current = begin_preformatted (current);
 
-      line += strlen (line); /* FIXME: Where does the control flow go? */
+      //line += strlen (line); /* FIXME: Where does the control flow go? */
+      // last; go to line 3687
+      *status = 1; /* Get a new line */
     }
   else
     {

Modified: trunk/parsetexi/handle_commands.h
===================================================================
--- trunk/parsetexi/handle_commands.h   2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/handle_commands.h   2015-12-05 16:51:13 UTC (rev 6834)
@@ -1,6 +1,6 @@
 
 ELEMENT *handle_misc_command (ELEMENT *current, char **line_inout,
-                     enum command_id cmd_id);
+                     enum command_id cmd_id, int *status);
 ELEMENT *handle_block_command (ELEMENT *current, char **line_inout,
                       enum command_id cmd_id, int *new_line);
 ELEMENT *handle_brace_command (ELEMENT *current, char **line_inout,

Modified: trunk/parsetexi/macro.c
===================================================================
--- trunk/parsetexi/macro.c     2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/macro.c     2015-12-05 16:51:13 UTC (rev 6834)
@@ -375,6 +375,22 @@
   return 0;
 }
 
+void
+delete_macro (char *name)
+{
+  enum command_id cmd;
+  MACRO *m;
+  cmd = lookup_command (name);
+  if (!cmd)
+    return;
+  m = lookup_macro (cmd);
+  if (!m)
+    return;
+  m->cmd = 0;
+  m->macro_name = "";
+  m->element = 0;
+}
+
 // 3898
 ELEMENT *
 handle_macro (ELEMENT *current, char **line_inout, enum command_id cmd)

Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c    2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/parser.c    2015-12-05 16:51:13 UTC (rev 6834)
@@ -259,9 +259,12 @@
 
 /* 1328 */
 ELEMENT *
-end_preformatted (ELEMENT *current)
+end_preformatted (ELEMENT *current,
+                  enum command_id closed_command,
+                  enum command_id interrupting_command)
 {
-  //current = close_all_style_commands (current);
+  current = close_all_style_commands (current,
+                                      closed_command, interrupting_command);
   if (current->type == ET_preformatted
       || current->type == ET_rawpreformatted)
     {
@@ -833,6 +836,7 @@
      get it in the top-level loop in parse_texi - this is mostly
      (always?) when we don't want to start a new, empty line, and
      need to get more from the current, incomplete line of input. */
+  // 3878
   while (*line == '\0')
     {
       static char *allocated_text;
@@ -849,8 +853,8 @@
           /* TODO: Can this only happen at end of file? */
           current = end_line (current);
           retval = GET_A_NEW_LINE;
+          goto funexit;
         }
-      goto funexit;
     }
 
   /* Handle user-defined macros before anything else because their expansion 
@@ -1046,18 +1050,13 @@
           if (close_paragraph_command (cmd))
             current = end_paragraph (current, 0, 0);
           if (close_preformatted_command (cmd))
-            current = end_preformatted (current);
+            current = end_preformatted (current, 0, 0);
         }
 
       if (cmd == 0)
         {
-          // Unknown command
-          /* FIXME: Just add it as a new element for now to check it worked. */
-          /* Elements corresponding to Texinfo commands don't have types.  
They 
-             are identified by the cmdname instead. */
-          ELEMENT *e = new_element (ET_NONE);
-          e->cmd = CM_NONE;
-          add_to_element_contents (current, e);
+          // 4287 Unknown command
+          //line_errorf ("unknown command address@hidden'",);
           retval = 1;
           goto funexit;
         }
@@ -1067,7 +1066,13 @@
          of exceptions, like @tab. */
       else if (command_data(cmd).flags & CF_misc)
         {
-          current = handle_misc_command (current, &line, cmd);
+          int status;
+          current = handle_misc_command (current, &line, cmd, &status);
+          if (status == 1)
+            {
+              retval = GET_A_NEW_LINE;
+              goto funexit;
+            }
         }
 
       /* line 4632 */

Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h    2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/parser.h    2015-12-05 16:51:13 UTC (rev 6834)
@@ -47,7 +47,9 @@
 void isolate_last_space (ELEMENT *current, enum element_type type);
 int command_with_command_as_argument (ELEMENT *current);
 ELEMENT *begin_preformatted (ELEMENT *current);
-ELEMENT *end_preformatted (ELEMENT *current);
+ELEMENT *end_preformatted (ELEMENT *current,
+                           enum command_id closed_command,
+                           enum command_id interrupting_command);
 char *read_command_name (char **ptr);
 ELEMENT *merge_text (ELEMENT *current, char *text);
 void start_empty_line_after_command (ELEMENT *current, char **line_inout,

Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2015-12-05 11:31:25 UTC (rev 6833)
+++ trunk/parsetexi/separator.c 2015-12-05 16:51:13 UTC (rev 6834)
@@ -21,6 +21,7 @@
 #include "tree.h"
 #include "text.h"
 #include "errors.h"
+#include "convert.h"
 
 // 3600
 /* Add the contents of CURRENT as an element to the extra value with




reply via email to

[Prev in Thread] Current Thread [Next in Thread]