PostgreSQL Source Code: src/test/isolation/specscanner.l Source File (original) (raw)

1%top{

2

3

4

5

6

7

8

9

10

11

13

14

15

16

17

19#include "specparse.h"

20}

21

22%{

23static int yyline = 1;

24

25#define LITBUF_INIT 1024

29

31

32

33

static void addlitchar(char c)

34%}

35

36%option 8bit

37%option never-interactive

38%option nodefault

39%option noinput

40%option nounput

41%option noyywrap

42%option warn

43%option prefix="spec_yy"

44

45

46%x sql

47%x qident

48

49non_newline [^\n\r]

50space [ \t\r\f]

51

52comment ("#"{non_newline}*)

53

54digit [0-9]

55ident_start [A-Za-z\200-\377_]

56ident_cont [A-Za-z\200-\377_0-9\$]

57

58identifier {ident_start}{ident_cont}*

59

60self [,()*]

61

63

64%{

65

67 {

void * pg_malloc(size_t size)

70 }

71%}

72

73

74notices { return NOTICES; }

75permutation { return PERMUTATION; }

76session { return SESSION; }

77setup { return SETUP; }

78step { return STEP; }

79teardown { return TEARDOWN; }

80

81

83{comment} { }

84{space} { }

85

86

87{identifier} {

88 spec_yylval.str = pg_strdup(yytext);

89 return(identifier);

90 }

char * pg_strdup(const char *in)

91

92

93\" {

95 BEGIN(qident);

96 }

97\"\" { addlitchar(yytext[0]); }

98\" {

101 BEGIN(INITIAL);

102 return(identifier);

103 }

105\n { spec_yyerror("unexpected newline in quoted identifier"); }

void spec_yyerror(const char *message)

106<> { spec_yyerror("unterminated quoted identifier"); }

107

108

109

110"{"{space}* {

111

113 BEGIN(sql);

114 }

115{space}*"}" {

118 BEGIN(INITIAL);

119 return(sqlblock);

120 }

121. {

123 }

124\n {

127 }

128<> {

130 }

131

132

133{digit}+ {

134 spec_yylval.integer = atoi(yytext);

135 return INTEGER;

136 }

137

138{self} { return yytext[0]; }

139

140

  1. {

142 fprintf(stderr, "syntax error at line %d: unexpected character \"%s\"\n", yyline, yytext);

143 exit(1);

144 }

#define fprintf(file, fmt, msg)

145%%

146

147

148

149static void

151{

152

154 {

155

158 }

160}

161

162void

164{

165 fprintf(stderr, "%s at line %d\n", message, yyline);

166 exit(1);

167}

void * pg_realloc(void *ptr, size_t size)