5 * Created by Bryan Donlan on Thu 11 Aug 2005.
6 * Copyright (c) 2005 Bryan Donlan. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
33 extern int lex_lineno
;
37 extern bytestring_t bytestr
;
38 extern std::string temp_str
;
40 static inline int make_int(int v
) {
41 lasttok
.payload
= caosVar(v
);
45 static inline int make_bin(const char *str
) {
48 for (pos
= 0; pos
< 8; pos
++) {
50 temp
+= str
[pos
] - '0';
52 return make_int(temp
);
56 static inline int make_float(float f
) {
57 lasttok
.payload
= caosVar(f
);
61 static inline int make_word(const char *str
) {
62 std::string result
= str
;
63 std::transform(result
.begin(), result
.end(), result
.begin(), (int(*)(int))tolower
);
64 lasttok
.payload
= result
;
68 static inline void push_string_escape(char c
) {
85 static inline void push_string_lit(char c
) {
89 static inline int make_string() {
90 lasttok
.payload
= caosVar(temp_str
);
95 static inline int push_bytestr(unsigned int bs
) {
97 std::ostringstream oss
;
98 oss
<< "Byte string element out of range (0 <= " << bs
<< " < 256) at line " << lex_lineno
;
99 throw parseException(oss
.str());
101 bytestr
.push_back(bs
);
105 static inline int make_bytestr() {
106 lasttok
.payload
= bytestr
;
111 static inline void parse_error(const char *yytext
, int yylineno
) {
112 std::ostringstream oss
;
113 oss
<< "Parse error at line " << yylineno
<< ", near " << yytext
;
114 throw parseException(oss
.str());