aboutsummaryrefslogtreecommitdiff
path: root/src/html.lex.l
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-07-11 22:45:37 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2008-07-11 22:45:37 +0000
commiteb79907f63b7985751849d7a13e13879b6b8da9e (patch)
treeeefbe4fc827242cb32f18a1ef0a4ffb4772630cd /src/html.lex.l
parent156b2a34fbc4dd3215c5b8cc2cc326f56dfb7df8 (diff)
downloadtagr-eb79907f63b7985751849d7a13e13879b6b8da9e.tar.gz
tagr-eb79907f63b7985751849d7a13e13879b6b8da9e.tar.bz2
Reorganize project directory layout.
* README-hacking: New file. * src: New directory * src/Makefile.am: New file. * graph.c, readconfig.c, tagr.h, log.c, report.h, queue.c: Move to src * main.c: Move to src, fix a minor bug in main. * html.l: Move to src/html.lex.l. * html.y: Move to src/html.gram.y. * lib/argcv.c, lib/argcv.h: Move to src. * config, INSTALL: Remove * README_hacking: New file. * configure.ac, Makefile.am: Update for new gnulib and new directory structure. * bootstrap: Update from gnulib. * gnulib.modules: New file. * bootstrap.conf: New file. git-svn-id: file:///svnroot/tagr/trunk@89 7c378d0d-a4e4-4a64-9229-dfce8bfd23d4
Diffstat (limited to 'src/html.lex.l')
-rw-r--r--src/html.lex.l140
1 files changed, 140 insertions, 0 deletions
diff --git a/src/html.lex.l b/src/html.lex.l
new file mode 100644
index 0000000..879c669
--- /dev/null
+++ b/src/html.lex.l
@@ -0,0 +1,140 @@
+%{
+/* This file is part of tagr.
+ Copyright (C) 2000, 2005, 2006, Max Bouglacoff, Sergey Poznyakoff
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <tagr.h>
+#include <html.gram.h>
+
+char *html_input_file;
+int html_input_line;
+%}
+
+%s EVAL
+
+NAME [A-Za-z_][A-Za-z0-9_]*
+N [0-9]+
+
+%%
+\$\$ {
+ yylval.character = '$';
+ return CHAR;
+}
+\${NAME} {
+ if (find_value (yytext+1, &yylval.value))
+ {
+ yyerror ("unknown identifier");
+ yylval.value.type = unspecified_value;
+ }
+ return IDENT;
+}
+\$\({NAME}\) {
+ yytext[yyleng-1] = 0;
+ if (find_value (yytext+2, &yylval.value))
+ {
+ yyerror ("unknown identifier");
+ yylval.value.type = unspecified_value;
+ }
+ return IDENT;
+}
+\$\({NAME}:{N}\) {
+ char *p = strchr (yytext, ':');
+ *p = 0;
+ if (find_value (yytext+2, &yylval.value))
+ {
+ yyerror ("unknown identifier");
+ yylval.value.type = unspecified_value;
+ }
+ else
+ {
+ yylval.value.prec = strtoul (p+1, NULL, 10);
+ }
+ return IDENT;
+}
+\$\{ return OBRACE;
+\$\} return CBRACE;
+<EVAL>[ \t]+ ;
+<EVAL>"("|")"|"+"|"-"|"*"|"/" return yytext[0];
+<EVAL>{N}\.?([eE][-+]?{N}+)? {
+ yylval.number = strtod (yytext, NULL);
+ return NUMBER;
+}
+\n {
+ html_input_line++;
+ yylval.character = yytext[0];
+ return CHAR;
+}
+. {
+ yylval.character = yytext[0];
+ return CHAR;
+}
+
+%%
+
+void
+begin_eval ()
+{
+ BEGIN (EVAL);
+}
+
+void
+end_eval ()
+{
+ BEGIN (INITIAL);
+}
+
+int
+html_open (char *file)
+{
+ yyin = fopen (file, "r");
+ if (!yyin)
+ {
+ logmsg (L_ERR, "cannot open input file `%s': %s",
+ file, strerror (errno));
+ return 1;
+ }
+ html_input_file = file;
+ html_input_line = 1;
+ return 0;
+}
+
+void
+html_close ()
+{
+ if (yyin)
+ {
+ fclose (yyin);
+ yyin = NULL;
+ }
+}
+
+int
+yywrap ()
+{
+ html_close ();
+ return 1;
+}
+
+

Return to:

Send suggestions and report system problems to the System administrator.