~ubuntu-branches/ubuntu/raring/crash/raring

« back to all changes in this revision

Viewing changes to extensions/libsial/sialpp.l

  • Committer: Package Import Robot
  • Author(s): Stefan Bader
  • Date: 2012-10-25 16:29:52 UTC
  • mfrom: (0.1.17) (25.1.1 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20121025162952-e42hkuic0u4h94p0
Tags: 6.1.0-1ubuntu1
* Merge from Debian unstable (LP: #1064475). Remaining changes:
  - debian/patches/01_spu_commands.patch
    + Provides SPU extension support
    + Enable SPU extension only on PPC (using .mk logic)
  - debian/rules:
    + Always build extensions and package them.
    + Cleanup for extensions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%{
2
 
/*
3
 
 * Copyright 2001 Silicon Graphics, Inc. All rights reserved.
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 */
15
 
 
16
 
#define YY_NO_UNPUT
17
 
%}
18
 
 
19
 
%{
20
 
#include <string.h>
21
 
 
22
 
#ifdef linux
23
 
#define YY_INPUT(buf,result,max_size) \
24
 
{ \
25
 
        int c = sial_input(); \
26
 
        result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
27
 
}
28
 
#endif
29
 
 
30
 
#include        "sial.h"
31
 
#include        "sialpp.tab.h"
32
 
#if linux
33
 
#define yylval sialpplval
34
 
#endif
35
 
 
36
 
#define retok(t) return(t)
37
 
int nomacs=0;
38
 
extern int sial_chkmacvar(char *);
39
 
extern node_t *sial_newchar(void);
40
 
%}
41
 
 
42
 
ABC             [a-zA-Z_]
43
 
ABCN            [a-zA-Z0-9_]
44
 
N               [0-9]
45
 
X               [0-9a-fA-F]
46
 
 
47
 
%%
48
 
 
49
 
[ \t\n]+        { ; }
50
 
 
51
 
"defined"       { retok(P_DEFINED); }
52
 
"&&"            { retok(P_BAND); }
53
 
"||"            { retok(P_BOR); }
54
 
"<"             { retok(P_LT); }
55
 
"<="            { retok(P_LE); }
56
 
"=="            { retok(P_EQ); }
57
 
">="            { retok(P_GE); }
58
 
">"             { retok(P_GT); }
59
 
"!="            { retok(P_NE); }
60
 
"|"             { retok(P_OR); }
61
 
"!"             { retok(P_NOT); }
62
 
"^"             { retok(P_XOR); }
63
 
">>"            { retok(P_SHR); }
64
 
"<<"            { retok(P_SHL); }
65
 
"+"             { retok(P_ADD); }
66
 
"-"             { retok(P_SUB); }
67
 
"/"             { retok(P_DIV); }
68
 
"%"             { retok(P_MOD); }
69
 
"*"             { retok(P_MUL); }
70
 
 
71
 
(("0x"+){X}+[lL]*|{N}+[lL]*)    { yylval.n = sial_newnum(yytext); retok(P_NUMBER); }
72
 
 
73
 
{ABC}{ABCN}*    { 
74
 
                                if(strlen(yytext) > MAX_SYMNAMELEN) {
75
 
 
76
 
                                        sial_error("Symbol name too long");
77
 
                                }
78
 
                                if(nomacs || !sial_chkmacvar(yytext)) {
79
 
 
80
 
                                        yylval.n = sial_newvnode(yytext); 
81
 
                                        retok(P_VAR);
82
 
                                }
83
 
                }
84
 
 
85
 
\'.\'           { yylval.n = sial_makenum(B_SC, yytext[1]); retok(P_NUMBER); }
86
 
\'\\.\'         { yylval.n = sial_makenum(B_SC, sial_getseq(yytext[2])); retok(P_NUMBER); }
87
 
 
88
 
 
89
 
.               { retok(yylval.i = yytext[0]); }
90
 
 
91
 
%%
92
 
#undef input
93
 
#undef unput
94
 
#define input()       sial_input()
95
 
#define unput(c)      sial_unput(c)