> If I understand correctly, you would like the format line to be > optional,
Yes. > but if specified to be preceded by the work "col". Yes. > As an option, the second format statement above might also be used > (col "ll"). Mhm, perhaps it is better to use just one the formats. I don't see a need to have two syntax forms. Perhaps we should do a poll which syntax form is preferable. Any opinions out there? I now think that my proposed `col' keyword is redundant. The following should do just fine: rmatrix { "ll" { a b } { c d } } Have a look at the attached diff of eqn.y which is a first try to implement my syntax. > > BTW, could you integrate the rmatrix stuff directly into eqn.y? > > How much work is it? > > This might be a LOT more work. I specifically chose to minimize the > impact of my code on James' work for two reasons: > > My C++ is somewhere past novice, but not yet at an > intermediate stage. So I thought 'tacking' my code on would > ensure that I didn't muck up his. My C++ isn't that good either :-) Basically, it shouldn't be that hard, and I'll assist you if questions arise. > If you insist, then I'll spend some time on James' code to see how > it might be done. Please do so -- and thanks in advance! There is no need to hurry. BTW, I see a problem with your proposed `#' comment token: It doesn't work in in-line equations like $x$. We have two possibilities: 1. Disallow `#' in in-line equations. 2. Use, say, `#{' and `#}' to start and end a comment. (Are there better suggestions for the comment delimiters?) For item 1 I suggest to handle it directly in function get_token (in lex.cpp) -- have a look at the similar code in the pic preprocessor for comparison. For item 2 (which I prefer) it is very simple to add a rule to eqn.y since we no longer are limited to a single line. Werner ====================================================================== --- eqn.y 2004-04-08 22:43:23.000000000 +0200 +++ eqn.y.new 2005-02-22 10:37:21.115271536 +0100 @@ -1,4 +1,5 @@ -/* Copyright (C) 1989, 1990, 1991, 1992, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2004, 2005 + Free Software Foundation, Inc. Written by James Clark ([EMAIL PROTECTED]) This file is part of groff. @@ -33,8 +34,10 @@ box *b; pile_box *pb; matrix_box *mb; + rmatrix_box *rb; int n; column *col; + row *row; } %token OVER @@ -67,6 +70,7 @@ %token DOWN %token UP %token MATRIX +%token RMATRIX %token COL %token LCOL %token RCOL @@ -103,7 +107,7 @@ %right LEFT %left RIGHT -%right LPILE RPILE CPILE PILE TEXT QUOTED_TEXT MATRIX MARK LINEUP '^' '~' '\t' '{' SPLIT NOSPLIT +%right LPILE RPILE CPILE PILE TEXT QUOTED_TEXT MATRIX RMATRIX MARK LINEUP '^' '~' '\t' '{' SPLIT NOSPLIT %right FROM TO %left SQRT OVER SMALLOVER %right SUB SUP @@ -117,6 +121,8 @@ %type <pb> pile_element_list pile_arg %type <mb> column_list %type <col> column column_arg column_element_list +%type <rb> row_list +%type <row> row row_element_list %% top: @@ -214,6 +220,10 @@ { $2->set_alignment(CENTER_ALIGN); $$ = $2; } | MATRIX '{' column_list '}' { $$ = $3; } + | RMATRIX '{' QUOTED_TEXT row_list '}' + { $$ = convert_rmatrix($3, $4); } + | RMATRIX '{' row_list '}' + { $$ = convert_rmatrix(0, $3); } | LEFT delim equation RIGHT delim { $$ = make_delim_box($2, $3, $5); } | LEFT delim equation @@ -312,6 +322,25 @@ { $2->set_alignment(CENTER_ALIGN); $$ = $2; } ; +row_list: + row + { $$ = new rmatrix_box($1); } + | row_list row + { $1->append($2); $$ = $1; } + ; + +row_element_list: + equation + { $$ = new row($1); } + | row_element_list equation + { $1->append($2); $$ = $1; } + ; + +row: + '{' row_element_list '}' + { $$ = $2; } + ; + text: TEXT { $$ = $1; } | QUOTED_TEXT _______________________________________________ Groff mailing list Groff@gnu.org http://lists.gnu.org/mailman/listinfo/groff