summaryrefslogtreecommitdiff
path: root/gram.y
diff options
context:
space:
mode:
Diffstat (limited to 'gram.y')
-rw-r--r--gram.y195
1 files changed, 0 insertions, 195 deletions
diff --git a/gram.y b/gram.y
deleted file mode 100644
index fb03f5d..0000000
--- a/gram.y
+++ /dev/null
@@ -1,195 +0,0 @@
-%{
-
-/*
- *
- * IRBOX, an Ivy driver for infra-red remote controls
- *
- * Copyright 1998-1999
- * Centre d'Etudes de la Navigation Aerienne
- *
- * This is the grammar for reading tables
- *
- * Authors: Stephane Chatty <chatty@cenatoulouse.dgac.fr>
- *
- * $Id$
- *
- * Please refer to file version.h for the
- * copyright notice regarding this software
- */
-
-
-extern const char* const ResWords;
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "irtable.h"
-
-extern int yyparse ();
-extern int yylex ();
-extern int LineNo;
-
-
-static char id_buf [1024]; /* Yeech */
-static char id_list_buf [4096]; /* Barf */
-
-static const char* filename = 0;
-static IrTable* cur_table;
-
-%}
-
-%union {
- const char *name;
- int integer;
-}
-
-%token Y_NAME Y_TYPE Y_BRAND Y_EOL
-%token <name> Y_ID Y_STRING
-%token <integer> Y_INT
-
-
-%type <name> id id_list
-
-%%
-
-instr_list:
- /* empty */
- | instr_list instr
- ;
-
-id:
- Y_ID
- {
- strcpy (id_buf, $1);
- free ((char*) $1); /* was allocated by strdup in lex file */
- $$ = id_buf;
- }
- | Y_INT
- {
- sprintf (id_buf, "%d", $1);
- $$ = id_buf;
- }
- ;
-
-id_list:
- id
- {
- strcpy (id_list_buf, $1);
- $$ = $1;
- }
- | id_list id
- {
- strcat (id_list_buf, " ");
- strcat (id_list_buf, $2);
- $$ = id_list_buf;
- }
- ;
-
-instr:
- Y_EOL
-
- | Y_NAME Y_ID Y_EOL
- {
- IrTableName (cur_table, $2);
- }
-
- | Y_TYPE ':' Y_ID Y_EOL
- {
- IrTableType (cur_table, $3);
- }
-
- | Y_BRAND ':' id_list Y_EOL
- {
- IrTableAddBrand (cur_table, $3);
- }
-
- | id_list ':' Y_INT Y_INT Y_INT Y_INT Y_INT Y_INT Y_EOL
- {
- IrTableAddKey (cur_table, $1, $3, $4, $5, $6, $7, $8);
- }
- ;
-
-
-%%
-#include <stdio.h>
-
-int _DoTee = 0;
-
-int
-tee (int x)
-{
- if (_DoTee) {
- char *s;
- switch (x) {
- case ':':
- s = ":";
- break;
- case Y_EOL:
- s = "Y_EOL\n";
- break;
- case Y_STRING:
- s = "STRING";
- break;
- case Y_INT:
- s = "INT";
- break;
- case Y_ID:
- s = "ID";
- break;
- case Y_TYPE:
- s = "TYPE";
- break;
- case Y_BRAND:
- s = "BRAND";
- break;
-/* case Y_:
- s = "";
- break;
-*/
- default :
- s = "???";
- break;
- }
- printf ("%s ", s);
- }
- return x;
-}
-
-
-int
-yyerror (const char *s)
-{
- fprintf (stderr, "%s in %s, line %d\n", s, filename, LineNo);
- return (0);
-}
-
-int
-yywrap ()
-{
- return 1;
-}
-
-
-IrTable*
-IrTableReadFile (const char* file)
-{
- extern void LexInit ();
- extern FILE *yyin;
- int result;
-
- LexInit ();
- filename = file;
- if (!(yyin = fopen (file,"r"))) {
- char err [1024];
- fprintf (stderr, "Cannot open %s\n", file);
- return 0;
- }
- cur_table = IrCreateTable ();
- if (yyparse ()) {
- result = 0;
- }
- fclose (yyin);
- return cur_table;
-}
-