1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
/*
*
* Copyright (C) 2009-2011 Colomban Wendling <ban@herbesfolles.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef H_CTPL_LEXER_PRIVATE_H
#define H_CTPL_LEXER_PRIVATE_H
#include <glib.h>
#include "ctpl-token-private.h"
G_BEGIN_DECLS
/*
* SECTION: lexer-private
* @short_description: Private lexer API
* @include: ctpl/lexer.h
* @include: ctpl/lexer-private.h
*
* Provides a few character categorization macros and functions.
*/
/*
* CTPL_BLANK_CHARS:
*
* Characters treated as blank, commonly used as separator.
*/
#define CTPL_BLANK_CHARS " \t\v\r\n"
/* number of bytes in %CTPL_BLANK_CHARS */
#define CTPL_BLANK_CHARS_LEN ((sizeof CTPL_BLANK_CHARS) - 1)
/*
* ctpl_is_blank:
* @c: A character
*
* Checks whether a character is one from %CTPL_BLANK_CHARS, but can be more
* optimized than a simple search in the string.
*
* Returns: %TRUE is @c is a blank character, %FALSE otherwise.
*
* Since: 0.2
*/
#define ctpl_is_blank(c) ((c) == ' ' || \
(c) == '\t' || \
(c) == '\v' || \
(c) == '\r' || \
(c) == '\n')
/*
* CTPL_SYMBOL_CHARS:
*
* Characters that are valid for a symbol.
*/
#define CTPL_SYMBOL_CHARS "abcdefghijklmnopqrstuvwxyz" \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
"0123456789" \
"_"
/* number of bytes in %CTPL_SYMBOL_CHARS */
#define CTPL_SYMBOL_CHARS_LEN ((sizeof CTPL_SYMBOL_CHARS) - 1)
/*
* ctpl_is_symbol:
* @c: A character
*
* Checks whether a character is one from %CTPL_SYMBOL_CHARS, but can be more
* optimized than a simple search in the string.
*
* Returns: %TRUE is @c is a symbol character, %FALSE otherwise.
*
* Since: 0.2
*/
#define ctpl_is_symbol(c) (((c) >= 'a' && (c) <= 'z') || \
((c) >= 'A' && (c) <= 'Z') || \
((c) >= '0' && (c) <= '9') || \
(c) == '_')
/*
* CTPL_ESCAPE_CHAR:
*
* Character used to escape a special character.
*/
#define CTPL_ESCAPE_CHAR '\\'
/*
* CTPL_STRING_DELIMITER_CHAR:
*
* Character surrounding string literals.
*/
#define CTPL_STRING_DELIMITER_CHAR '"'
/*
* CTPL_OPERATOR_CHARS:
*
* Characters valid for an operator.
*/
#define CTPL_OPERATOR_CHARS "+-/*=><%!&|"
/*
* CTPL_OPERAND_CHARS:
*
* Characters valid for an operand
*/
#define CTPL_OPERAND_CHARS "." /* for floating point values */ \
"+-" /* for signs */ \
CTPL_BLANK_CHARS \
CTPL_SYMBOL_CHARS
/*
* CTPL_EXPR_CHARS:
*
* Characters valid inside an expression
*/
#define CTPL_EXPR_CHARS "()" \
CTPL_OPERATOR_CHARS \
CTPL_OPERAND_CHARS
/*
* CTPL_START_CHAR:
*
* Character delimiting the start of language tokens from raw data.
*/
#define CTPL_START_CHAR '{'
/*
* CTPL_END_CHAR:
*
* Character delimiting the end of language tokens from raw data.
*/
#define CTPL_END_CHAR '}'
G_GNUC_INTERNAL
const gchar *ctpl_operator_to_string (CtplOperator op);
G_GNUC_INTERNAL
CtplOperator ctpl_operator_from_string (const gchar *str,
gssize len,
gsize *operator_len);
G_END_DECLS
#endif /* guard */
|