Mercurial > octave-nkf
comparison libinterp/corefcn/oct-tex-lexer.in.ll @ 20573:e3c0fee87493
style fixes for tex lexer and parser
* oct-tex-lexer.in.ll, oct-tex-parser.in.yy:
Eliminate tabs and reindent.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 02 Oct 2015 12:25:39 -0400 |
parents | a3577622952c |
children |
comparison
equal
deleted
inserted
replaced
20572:72cd24aa5f7a | 20573:e3c0fee87493 |
---|---|
34 #include <config.h> | 34 #include <config.h> |
35 #endif | 35 #endif |
36 | 36 |
37 } | 37 } |
38 | 38 |
39 %x NUM_MODE | 39 %x NUM_MODE |
40 %x MAYBE_NUM_MODE | 40 %x MAYBE_NUM_MODE |
41 | 41 |
42 %{ | 42 %{ |
43 | 43 |
44 // The generated code may include unistd.h. We need that to happen | 44 // The generated code may include unistd.h. We need that to happen |
45 // before defining isatty to be prefixed with the gnulib namespace | 45 // before defining isatty to be prefixed with the gnulib namespace |
51 #include "txt-eng.h" | 51 #include "txt-eng.h" |
52 #include "oct-tex-parser.h" | 52 #include "oct-tex-parser.h" |
53 | 53 |
54 // FIXME: with bison 3.x, OCTAVE_TEX_STYPE appears in the generated | 54 // FIXME: with bison 3.x, OCTAVE_TEX_STYPE appears in the generated |
55 // oct-parse.h file, but there is no definition for YYSTYPE, which is | 55 // oct-parse.h file, but there is no definition for YYSTYPE, which is |
56 // needed by the code that is generated by flex. I can't seem to find a | 56 // needed by the code that is generated by flex. I can't seem to find |
57 // way to tell flex to use OCTAVE_TEX_STYPE instead of YYSTYPE in the code | 57 // a way to tell flex to use OCTAVE_TEX_STYPE instead of YYSTYPE in |
58 // it generates, or to tell bison to provide the definition of YYSTYPE | 58 // the code it generates, or to tell bison to provide the definition |
59 // in the generated oct-parse.h file. | 59 // of YYSTYPE in the generated oct-parse.h file. |
60 | 60 |
61 #if defined (OCTAVE_TEX_STYPE_IS_DECLARED) && ! defined YYSTYPE | 61 #if defined (OCTAVE_TEX_STYPE_IS_DECLARED) && ! defined YYSTYPE |
62 #define YYSTYPE OCTAVE_TEX_STYPE | 62 #define YYSTYPE OCTAVE_TEX_STYPE |
63 #endif | 63 #endif |
64 | 64 |
65 #if defined (GNULIB_NAMESPACE) | 65 #if defined (GNULIB_NAMESPACE) |
66 // Calls to the following functions appear in the generated output from | 66 // Calls to the following functions appear in the generated output |
67 // flex without the namespace tag. Redefine them so we will use them | 67 // from flex without the namespace tag. Redefine them so we will use |
68 // via the gnulib namespace. | 68 // them via the gnulib namespace. |
69 #define fprintf GNULIB_NAMESPACE::fprintf | 69 #define fprintf GNULIB_NAMESPACE::fprintf |
70 #define fread GNULIB_NAMESPACE::fread | 70 #define fread GNULIB_NAMESPACE::fread |
71 #define fwrite GNULIB_NAMESPACE::fwrite | 71 #define fwrite GNULIB_NAMESPACE::fwrite |
72 #define getc GNULIB_NAMESPACE::getc | 72 #define getc GNULIB_NAMESPACE::getc |
73 #define isatty GNULIB_NAMESPACE::isatty | 73 #define isatty GNULIB_NAMESPACE::isatty |
75 #define realloc GNULIB_NAMESPACE::realloc | 75 #define realloc GNULIB_NAMESPACE::realloc |
76 #endif | 76 #endif |
77 | 77 |
78 %} | 78 %} |
79 | 79 |
80 D [0-9] | 80 D [0-9] |
81 NUM (({D}+\.?{D}*)|(\.{D}+)) | 81 NUM (({D}+\.?{D}*)|(\.{D}+)) |
82 | 82 |
83 %% | 83 %% |
84 | 84 |
85 %{ | 85 %{ |
86 // Numeric values | 86 // Numeric values. |
87 %} | 87 %} |
88 | 88 |
89 <NUM_MODE>{NUM} { | 89 <NUM_MODE>{NUM} { |
90 int nread; | 90 int nread = sscanf (yytext, "%lf", &(yylval->num)); |
91 | 91 |
92 nread = sscanf (yytext, "%lf", &(yylval->num)); | |
93 if (nread == 1) | 92 if (nread == 1) |
94 return NUM; | 93 return NUM; |
95 } | 94 } |
96 <NUM_MODE>[ \t]+ { } | 95 |
97 <NUM_MODE>"\n"|. { yyless (0); BEGIN (INITIAL); } | 96 <NUM_MODE>[ \t]+ { } |
98 | 97 |
99 <MAYBE_NUM_MODE>"{" { BEGIN (NUM_MODE); return START; } | 98 <NUM_MODE>"\n"|. { |
100 <MAYBE_NUM_MODE>"\n"|. { yyless (0); BEGIN (INITIAL); } | 99 yyless (0); |
101 | 100 BEGIN (INITIAL); |
102 %{ | 101 } |
103 // Simple commands | 102 |
104 %} | 103 <MAYBE_NUM_MODE>"{" { |
105 | 104 BEGIN (NUM_MODE); |
106 "\\bf" { return BF; } | 105 return START; |
107 "\\it" { return IT; } | 106 } |
108 "\\sl" { return SL; } | 107 |
109 "\\rm" { return RM; } | 108 <MAYBE_NUM_MODE>"\n"|. { |
110 | 109 yyless (0); |
111 %{ | 110 BEGIN (INITIAL); |
112 // Generic font commands | 111 } |
113 %} | 112 |
114 | 113 %{ |
115 "\\fontname" { return FONTNAME; } | 114 // Simple commands. |
116 "\\fontsize" { BEGIN (MAYBE_NUM_MODE); return FONTSIZE; } | 115 %} |
117 "\\color[rgb]" { BEGIN (MAYBE_NUM_MODE); return COLOR_RGB; } | 116 |
118 "\\color" { return COLOR; } | 117 "\\bf" { return BF; } |
119 | 118 "\\it" { return IT; } |
120 %{ | 119 "\\sl" { return SL; } |
121 // Special characters | 120 "\\rm" { return RM; } |
122 %} | 121 |
123 | 122 %{ |
124 "{" { return START; } | 123 // Generic font commands. |
125 "}" { return END; } | 124 %} |
126 "^" { return SUPER; } | 125 |
127 "_" { return SUB; } | 126 "\\fontname" { return FONTNAME; } |
128 | 127 |
129 "\\{" | | 128 "\\fontsize" { |
130 "\\}" | | 129 BEGIN (MAYBE_NUM_MODE); |
131 "\\^" | | 130 return FONTSIZE; |
132 "\\_" | | 131 } |
133 "\\\\" { yylval->ch = yytext[1]; return CH; } | 132 |
134 | 133 "\\color[rgb]" { |
135 %{ | 134 BEGIN (MAYBE_NUM_MODE); |
136 // Symbols | 135 return COLOR_RGB; |
136 } | |
137 | |
138 "\\color" { return COLOR; } | |
139 | |
140 %{ | |
141 // Special characters. | |
142 %} | |
143 | |
144 "{" { return START; } | |
145 "}" { return END; } | |
146 "^" { return SUPER; } | |
147 "_" { return SUB; } | |
148 | |
149 "\\{" | | |
150 "\\}" | | |
151 "\\^" | | |
152 "\\_" | | |
153 "\\\\" { | |
154 yylval->ch = yytext[1]; | |
155 return CH; | |
156 } | |
157 | |
158 %{ | |
159 // Symbols. | |
137 %} | 160 %} |
138 | 161 |
139 @SYMBOL_RULES@ | 162 @SYMBOL_RULES@ |
140 | 163 |
141 %{ | 164 %{ |
142 // Generic character | 165 // Generic character. |
143 %} | 166 %} |
144 | 167 |
145 "\n" | | 168 "\n" | |
146 . { yylval->ch = yytext[0]; return CH; } | 169 . { |
170 yylval->ch = yytext[0]; | |
171 return CH; | |
172 } | |
147 | 173 |
148 %% | 174 %% |
149 | 175 |
150 void * | 176 void * |
151 octave_tex_alloc (yy_size_t size, yyscan_t) | 177 octave_tex_alloc (yy_size_t size, yyscan_t) |