~ubuntu-branches/ubuntu/wily/gperiodic/wily

« back to all changes in this revision

Viewing changes to src/gparser.y

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2004-05-13 20:46:09 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040513204609-2ymqncvzfrqx8a7i
Tags: 2.0.7-4
Removed the DEPRECATED flags to build fine with GTK+2.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%{
2
 
 
3
 
#include <glib.h>
4
 
 
5
 
extern int  debug;
6
 
int         num = 0;
7
 
char        command[1024];
8
 
GList       *args;
9
 
extern char *yytext;
10
 
 
11
 
void add_argument(const char*);
12
 
int gpparser_execute_command(const char*,GList*);
13
 
extern void gpparser_reinit_parser(void);
14
 
 
15
 
 
16
 
%}
17
 
 
18
 
%token WORD INT_NUMBER COMMAND_SEPERATOR
19
 
 
20
 
%%
21
 
 
22
 
statements:
23
 
        statement
24
 
|       statement statements
25
 
;
26
 
 
27
 
statement:
28
 
        command arguments COMMAND_SEPERATOR
29
 
        { gpparser_execute_command(command,args); gpparser_reinit_parser(); }
30
 
|       command arguments 
31
 
        { gpparser_execute_command(command,args); gpparser_reinit_parser(); }
32
 
;
33
 
 
34
 
command:
35
 
        WORD
36
 
        { if(debug)printf("parse: command\n"); strncpy(command,yytext,1024); }
37
 
|       '?'
38
 
        { if(debug)printf("parse: command\n"); strncpy(command,"help",1024); }
39
 
|       { command[0] = '\0'; }
40
 
;
41
 
 
42
 
arguments:
43
 
|       argument
44
 
|       argument ',' arguments
45
 
|       argument arguments
46
 
;
47
 
 
48
 
argument:
49
 
        WORD
50
 
        { if(debug)printf("parse: word\n"); add_argument(yytext); }
51
 
|       INT_NUMBER
52
 
        { if(debug)printf("parse: number\n"); add_argument(yytext); }
53
 
;
54
 
 
55
 
%%
56
 
 
57
 
int yyerror(char*s)
58
 
{
59
 
  printf("parser error: %s\n",s);
60
 
}
61
 
 
62
 
void init_parser(void)
63
 
{
64
 
  args = g_list_alloc();
65
 
}
66
 
 
67
 
void arg_reaper(gpointer data, gpointer nothing)
68
 
{
69
 
  g_free(data);
70
 
}
71
 
 
72
 
void cleanup_parser(void)
73
 
{
74
 
  g_list_foreach(args,arg_reaper,NULL);
75
 
  g_list_free(args);
76
 
}
77
 
 
78
 
void add_argument(const char*arg)
79
 
{
80
 
  char *s = g_strdup(arg);
81
 
  g_list_append(args,s);
82
 
}
83