texinfo-commits
[Top][All Lists]
Advanced

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

[6059] parsetexi update


From: Gavin D. Smith
Subject: [6059] parsetexi update
Date: Fri, 23 Jan 2015 17:19:04 +0000

Revision: 6059
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6059
Author:   gavin
Date:     2015-01-23 17:18:57 +0000 (Fri, 23 Jan 2015)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/ChangeLog
    trunk/parsetexi/command_data.awk
    trunk/parsetexi/command_data.txt
    trunk/parsetexi/command_ids.h
    trunk/parsetexi/dump_perl.c
    trunk/parsetexi/end_line.c
    trunk/parsetexi/extra.c
    trunk/parsetexi/handle_commands.c
    trunk/parsetexi/makeinfo
    trunk/parsetexi/parser.h
    trunk/parsetexi/tree_types.h

Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog   2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/ChangeLog   2015-01-23 17:18:57 UTC (rev 6059)
@@ -1,3 +1,28 @@
+2015-01-23  Gavin Smith  <address@hidden>
+
+       * tree_types.h (enum extra_type): Add extra_string value.
+       * extra.c (add_extra_string): New function.
+       * dump_perl.c (dump_extra) <extra_string>: Support.
+
+       * end_line.c (parse_line_command_args): New function.
+       <CM_columnfractions>: Split argument line up by whitespace.
+
+       * end_line.c (end_line) <ET_misc_line_arg>: Call 
+       parse_line_command_args, and store result in "misc_args" key.
+       <@multitable @columnfractions>: Copy "misc_args" key into
+       "columnfractions" key.
+       <@multitable prototype line>: Set 'prototypes' extra key, 
+       copying from contents of argument container.
+
+       * handle_commands.c (handle_misc_command): Set "cell_number" 
+       extra keys for a multitable (not correctly yet).
+       * end_line.c (end_line) <CM_enumerate>: Output 
+       "enumerate_specification" key.
+
+       * command_data.txt: Add @heading.  Remove root flag from heading 
+       commands.
+       * command_data.awk: Correct output of CM_APOSTROPHE symbol.
+
 2015-01-22  Gavin Smith  <address@hidden>
 
        * parser.c (big_loop) <reading @ command>: Don't advance the 

Modified: trunk/parsetexi/command_data.awk
===================================================================
--- trunk/parsetexi/command_data.awk    2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/command_data.awk    2015-01-23 17:18:57 UTC (rev 6059)
@@ -76,7 +76,7 @@
     print "#define CM_hex_20 CM_SPACE"
     print "#define CM_hex_21 CM_EXCLAMATION_MARK"
     print "#define CM_hex_22 CM_POUND_SIGN"
-    print "#define CM_hex_27 CM_BACKQUOTE"
+    print "#define CM_hex_27 CM_APOSTROPHE"
     print "#define CM_hex_2a CM_ASTERISK"
     print "#define CM_hex_2c CM_COMMA"
     print "#define CM_hex_2d CM_HYPHEN"

Modified: trunk/parsetexi/command_data.txt
===================================================================
--- trunk/parsetexi/command_data.txt    2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/command_data.txt    2015-01-23 17:18:57 UTC (rev 6059)
@@ -474,18 +474,19 @@
 top                    root,misc               MISC_line
 chapter                        root,misc               MISC_line
 unnumbered             root,misc               MISC_line
-chapheading            root,misc               MISC_line
+chapheading            misc                    MISC_line
 appendix               root,misc               MISC_line
 section                        root,misc               MISC_line
 unnumberedsec          root,misc               MISC_line
+heading                        misc                    MISC_line
 appendixsec            root,misc               MISC_line
 subsection             root,misc               MISC_line
 unnumberedsubsec       root,misc               MISC_line
-subheading             root,misc               MISC_line
+subheading             misc                    MISC_line
 appendixsubsec         root,misc               MISC_line
 subsubsection          root,misc               MISC_line
 unnumberedsubsubsec    root,misc               MISC_line
-subsubheading          root,misc               MISC_line
+subsubheading          misc                    MISC_line
 appendixsubsubsec      root,misc               MISC_line
 
 part                   root,misc               MISC_line

Modified: trunk/parsetexi/command_ids.h
===================================================================
--- trunk/parsetexi/command_ids.h       2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/command_ids.h       2015-01-23 17:18:57 UTC (rev 6059)
@@ -205,6 +205,7 @@
 CM_guilsinglleft,
 CM_guilsinglright,
 CM_hashchar,
+CM_heading,
 CM_headings,
 CM_headitem,
 CM_headitemfont,

Modified: trunk/parsetexi/dump_perl.c
===================================================================
--- trunk/parsetexi/dump_perl.c 2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/dump_perl.c 2015-01-23 17:18:57 UTC (rev 6059)
@@ -269,6 +269,14 @@
               dump_indent ();
               printf ("],\n");
             }
+          else if (e->extra[i].type == extra_string)
+            {
+              char *value = (char *) e->extra[i].value;
+
+              printf ("'%s' => '", e->extra[i].key);
+              dump_string (value);
+              printf ("',\n");
+            }
           else if (e->extra[i].value->parent_type == route_not_in_tree)
             {
               switch (e->extra[i].type)

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/end_line.c  2015-01-23 17:18:57 UTC (rev 6059)
@@ -56,6 +56,117 @@
   return trimmed;
 }
 
+// 5475
+ELEMENT *
+parse_line_command_args (ELEMENT *line_command)
+{
+  ELEMENT *line_args;
+  ELEMENT *arg = line_command->args.list[0];
+  ELEMENT *argarg = 0;
+  enum command_id command = line_command->cmd;
+  char *line;
+  int i;
+
+  line_args = new_element (ET_NONE);
+
+  i = 0;
+  while (i < arg->contents.number)
+    {
+      /* TODO: Ignore all the elements checked in 
+         trim_spaces_comment_from_content. */
+
+      if (contents_child_by_index(arg, i)->type
+            == ET_empty_spaces_after_command
+          || contents_child_by_index(arg, i)->type == ET_spaces_at_end)
+        {
+          i++;
+          continue;
+        }
+      if (!argarg)
+        {
+          argarg = contents_child_by_index(arg, i);
+          i++;
+          continue;
+        }
+      else
+        {
+          /* Error - too many arguments. */
+          abort ();
+        }
+    }
+  if (!argarg)
+    {
+      abort();
+    }
+
+  if (argarg->text.end == 0)
+    abort ();
+
+  command = line_command->cmd;
+  line = argarg->text.text;
+
+  switch (command)
+    {
+    case CM_alias:
+    case CM_definfoenclose:
+    case CM_columnfractions:
+      {
+        ELEMENT *new;
+        char *p = line, *q;
+        while (1)
+          {
+            p += strspn (p, whitespace_chars);
+            if (!*p)
+              break;
+            q = strpbrk (p, whitespace_chars);
+            if (!q)
+              q = p + strlen (p);
+            new = new_element (ET_NONE);
+            text_append_n (&new->text, p, q - p);
+            p = q;
+            add_to_element_contents (line_args, new);
+          }
+
+      }
+    case CM_sp:
+    case CM_defindex:
+    case CM_defcodeindex:
+    case CM_synindex:
+    case CM_syncodeindex:
+    case CM_printindex:
+    case CM_everyheadingmarks:
+    case CM_everyfootingmarks:
+    case CM_evenheadingmarks:
+    case CM_oddheadingmarks:
+    case CM_evenfootingmarks:
+    case CM_oddfootingmarks:
+    case CM_fonttextsize:
+    case CM_footnotestyle:
+    case CM_setchapternewpage:
+    case CM_need:
+    case CM_paragraphindent:
+    case CM_firstparagraphindent:
+    case CM_exampleindent:
+      {
+      }
+    case CM_frenchspacing:
+    case CM_xrefautomaticsectiontitle:
+    case CM_codequoteundirected:
+    case CM_codequotebacktick:
+    case CM_deftypefnnewline:
+      {
+        /* Argument is either "on" or "off". */
+      }
+    case CM_kbdinputstyle:
+    case CM_allowcodebreaks:
+    case CM_urefbreakstyle:
+    case CM_headings:
+    default:
+      ;
+    }
+  return line_args;
+}
+
 // 2257
 /* NODE->contents is the Texinfo for the specification of a node.  This
    function sets three fields on the returned object:
@@ -286,8 +397,50 @@
       // 2881
       if (current->parent->cmd == CM_multitable)
         {
-          /* Parse prototype row */
-          // But not @columnfractions, I assume?
+          /* Parse prototype row for a @multitable.  Handling
+             of @columnfractions is done elsewhere. */
+
+          /* TODO: Need to set both 'prototypes' and 'prototypes_line' 
+             values.  */
+
+          int i;
+          ELEMENT *prototypes = new_element (ET_NONE);
+          prototypes->parent_type = route_not_in_tree;
+
+          for (i = 0; i < current->contents.number; i++)
+            {
+              ELEMENT *e = contents_child_by_index(current, i);
+
+              if (e->type == ET_bracketed)
+                {
+                  /* Copy and change the type of the element. */
+
+                  ELEMENT *new;
+                  new = malloc (sizeof (ELEMENT));
+                  memcpy (new, e, sizeof (ELEMENT));
+                  new->type = ET_bracketed_multitable_prototype;
+                  add_to_element_contents (prototypes, new);
+                }
+              else if (e->text.end > 0)
+                {
+                  /* TODO: Split the text up by whitespace. */
+
+                  if (e->text.text[strspn (e->text.text, whitespace_chars)])
+                    {
+                      ELEMENT *new;
+                      new = malloc (sizeof (ELEMENT));
+                      memcpy (new, e, sizeof (ELEMENT));
+                      new->type = ET_row_prototype;
+                      add_to_element_contents (prototypes, new);
+                    }
+                }
+              else
+                {
+                  abort (); /*TODO*/
+                }
+            }
+
+          add_extra_key_contents (current->parent, "prototypes", prototypes);
         }
 
       if (current->parent->cmd == CM_float) // 2943
@@ -312,6 +465,8 @@
         {
           if (current->cmd == CM_enumerate)
             {
+              /* TODO: Can have e.g. 7, "A", or "a". */
+              add_extra_string (current, "enumerate_specification", "1");
             }
           else if (item_line_command (current->cmd)) // 3002
             {
@@ -374,10 +529,12 @@
     {
       int cmd_id, arg_type;
       enum context c;
+      ELEMENT *misc_cmd;
 
       isolate_last_space (current, 0);
 
       current = current->parent;
+      misc_cmd = current;
       cmd_id = current->cmd;
       if (!cmd_id)
         abort ();
@@ -397,7 +554,8 @@
 
       if (arg_type > 0)
         {
-          //parse_line_command_args (current);
+          ELEMENT *args = parse_line_command_args (current);
+          add_extra_key_misc_args (current, "misc_args", args);
         }
       else if (arg_type == MISC_text) /* 3118 */
         {
@@ -592,11 +750,24 @@
       else if (cmd_id == CM_columnfractions)
         {
           ELEMENT *before_item;
-          // check if in multitable
+          KEY_PAIR *misc_args;
 
+          /* Check if in multitable. */
+          if (!current->parent || current->parent->cmd != CM_multitable)
+            {
+              abort ();
+            }
+
           // pop and check context stack
 
           current = current->parent;
+
+          if (misc_args = lookup_extra_key (misc_cmd, "misc_args"))
+            {
+              add_extra_key_misc_args (current, "columnfractions", 
+                                       misc_args->value);
+            }
+
           before_item = new_element (ET_before_item);
           add_to_element_contents (current, before_item);
           current = before_item;

Modified: trunk/parsetexi/extra.c
===================================================================
--- trunk/parsetexi/extra.c     2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/extra.c     2015-01-23 17:18:57 UTC (rev 6059)
@@ -90,6 +90,13 @@
   e->extra[e->extra_number - 1].type = extra_node_spec_array;
 }
 
+void
+add_extra_string (ELEMENT *e, char *key, char *value)
+{
+  add_extra_key (e, key, (ELEMENT *) value);
+  e->extra[e->extra_number - 1].type = extra_string;
+}
+
 KEY_PAIR *
 lookup_extra_key (ELEMENT *e, char *key)
 {

Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c   2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/handle_commands.c   2015-01-23 17:18:57 UTC (rev 6059)
@@ -182,6 +182,9 @@
                           add_to_element_contents (row, misc);
                           current = misc;
                           debug ("TAB");
+
+                          /* TODO: Keep count. */
+                          add_extra_string (current, "cell_number", "2");
                         }
                     }
                   else /* 4505 @item or @headitem */
@@ -195,6 +198,8 @@
                       misc->cmd = cmd_id;
                       add_to_element_contents (row, misc);
                       current = misc;
+
+                      add_extra_string (current, "cell_number", "1");
                     }
                 }
             } /* item_multitable_parent */

Modified: trunk/parsetexi/makeinfo
===================================================================
--- trunk/parsetexi/makeinfo    2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/makeinfo    2015-01-23 17:18:57 UTC (rev 6059)
@@ -1,7 +1,7 @@
 #! /usr/bin/env bash
 
 #DEBUG='perl -d'
-OPTIONS='-c DEBUG=1 --no-validate'
+#OPTIONS='-c DEBUG=1 --no-validate'
 COMMAND=${COMMAND:-./texi2any-C.pl}
 
 
PERL5LIB=../tp:../tp/maintain/lib/libintl-perl/lib:../tp/maintain/lib/Text-Unidecode/lib/:../tp/maintain/lib/Unicode-EastAsianWidth/lib:./Parsetexi/lib:./Parsetexi/blib/lib:./Parsetexi/blib/arch/auto/Parsetexi
 ${DEBUG} ${COMMAND} ${OPTIONS} "$@"

Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h    2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/parser.h    2015-01-23 17:18:57 UTC (rev 6059)
@@ -70,6 +70,7 @@
 void add_extra_key_misc_args (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_node_spec (ELEMENT *e, char *key, NODE_SPEC_EXTRA *value);
 void add_extra_node_spec_array (ELEMENT *, char *, NODE_SPEC_EXTRA **value);
+void add_extra_string (ELEMENT *e, char *key, char *value);
 KEY_PAIR *lookup_extra_key (ELEMENT *e, char *key);
 
 /* In menus.c */

Modified: trunk/parsetexi/tree_types.h
===================================================================
--- trunk/parsetexi/tree_types.h        2015-01-23 01:35:09 UTC (rev 6058)
+++ trunk/parsetexi/tree_types.h        2015-01-23 17:18:57 UTC (rev 6059)
@@ -31,7 +31,8 @@
     extra_index_entry,
     extra_misc_args,
     extra_node_spec,
-    extra_node_spec_array
+    extra_node_spec_array,
+    extra_string
 };
 
 typedef struct KEY_PAIR {




reply via email to

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