aboutsummaryrefslogtreecommitdiff
path: root/lib/forlanlex.l
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-09-25 17:31:24 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2012-09-25 17:45:23 +0300
commit455e12faaf5efd997ff74ad04c0fcc62608477a5 (patch)
tree46d24aba487fb2ea76078ef4da60357ff0a340e4 /lib/forlanlex.l
parent2f5d961c798802f1e467de1cd310f661e0a45fa7 (diff)
downloadeclat-455e12faaf5efd997ff74ad04c0fcc62608477a5.tar.gz
eclat-455e12faaf5efd997ff74ad04c0fcc62608477a5.tar.bz2
Use forlan to format the output.
* lib/forlan.h (forlan_lex_begin): Remove (forlan_lex_from_buffer) (forlan_lex_from_file): New protos. (forlan_parse): Remove. (forlan_parse_bufferm,forlan_parse_file): New protos. * lib/forlangrm.y (forlan_parse): Remove. (forlan_parse_bufferm,forlan_parse_file): New functions. * lib/forlanlex.l (YY_INPUT): Optionally, read input from file. (forlan_lex_begin): Remove (forlan_lex_from_buffer) (forlan_lex_from_file): New functions. * src/cmdline.opt: New options: --format, --sort * src/config.c: New statement: format. * src/eclat.c: Use output format scripts, if provided. * src/eclat.conf: Define output format for DescribeTags. * src/eclat.h: Include forlan.h (define_format): New proto. * tests/tforlan.c: New option: -s
Diffstat (limited to 'lib/forlanlex.l')
-rw-r--r--lib/forlanlex.l34
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/forlanlex.l b/lib/forlanlex.l
index e3f9f26..c3797dd 100644
--- a/lib/forlanlex.l
+++ b/lib/forlanlex.l
@@ -16,6 +16,7 @@
16 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ 16 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
17 17
18#include "libeclat.h" 18#include "libeclat.h"
19#include <sysexits.h>
19#include <grecs.h> 20#include <grecs.h>
20#include <grecs-locus.h> 21#include <grecs-locus.h>
21#include "forlangrm.h" 22#include "forlangrm.h"
@@ -28,14 +29,17 @@ static size_t forlan_input_pos;
28#undef YY_INPUT 29#undef YY_INPUT
29#define YY_INPUT(buf,result,max_size) \ 30#define YY_INPUT(buf,result,max_size) \
30 do { \ 31 do { \
31 size_t __s = forlan_input_len - forlan_input_pos; \ 32 if (forlan_input_base) { \
32 if (__s > max_size) \ 33 size_t __s = forlan_input_len - forlan_input_pos; \
33 __s = max_size; \ 34 if (__s > max_size) \
34 if (__s > 0) { \ 35 __s = max_size; \
35 memcpy(buf, forlan_input_base, __s); \ 36 if (__s > 0) { \
36 forlan_input_pos += __s; \ 37 memcpy(buf, forlan_input_base, __s); \
37 } \ 38 forlan_input_pos += __s; \
38 result = __s; \ 39 } \
40 result = __s; \
41 } else \
42 result = fread(buf, 1, max_size, yyin); \
39 } while(0) 43 } while(0)
40 44
41#define YY_USER_ACTION do { \ 45#define YY_USER_ACTION do { \
@@ -120,8 +124,8 @@ yywrap()
120} 124}
121 125
122void 126void
123forlan_lex_begin(const char *input, size_t length, 127forlan_lex_from_buffer(const char *input, size_t length,
124 struct grecs_locus_point *pt) 128 struct grecs_locus_point *pt)
125{ 129{
126 forlan_input_base = input; 130 forlan_input_base = input;
127 forlan_input_len = length; 131 forlan_input_len = length;
@@ -131,6 +135,16 @@ forlan_lex_begin(const char *input, size_t length,
131} 135}
132 136
133void 137void
138forlan_lex_from_file(FILE *fp, struct grecs_locus_point *pt)
139{
140 yyin = fp;
141 forlan_input_base = NULL;
142 grecs_current_locus_point = *pt;
143 yy_flex_debug = debug_level(forlan_dbg) >= FORLAN_DBG_LEX;
144 grecs_line_acc_create();
145}
146
147void
134forlan_lex_end() 148forlan_lex_end()
135{ 149{
136 grecs_line_acc_free(); 150 grecs_line_acc_free();

Return to:

Send suggestions and report system problems to the System administrator.