Synopsis - Cross-Reference
File: src/Synopsis/Token.hh1// 2// Copyright (C) 2004 Stefan Seefeld 3// All rights reserved. 4// Licensed to the public under the terms of the GNU LGPL (>= 2), 5// see the file COPYING for details. 6// 7#ifndef Synopsis_Token_hh_ 8#define Synopsis_Token_hh_ 9 10#include <cstring> 11 12namespace Synopsis 13{ 14 15//. A Token is what the Lexer splits an input stream into. 16//. It refers to a region in the underlaying buffer and it 17//. has a type. 18//. 19//. - line directive: `^"#"{blank}*{digit}+({blank}+.*)?\n` 20//. - pragma directive: `^"#"{blank}*"pragma".*\n` 21//. - Constant: 22//. 23//. - `{digit}+{int_suffix}*` 24//. - `"0"{xletter}{hexdigit}+{int_suffix}*` 25//. - `{digit}*\.{digit}+{float_suffix}*` 26//. - `{digit}+\.{float_suffix}*` 27//. - `{digit}*\.{digit}+"e"("+"|"-")*{digit}+{float_suffix}*` 28//. - `{digit}+\."e"("+"|"-")*{digit}+{float_suffix}*` 29//. - `{digit}+"e"("+"|"-")*{digit}+{float_suffix}*` 30//. 31//. - CharConst: `\'([^'\n]|\\[^\n])\'` 32//. - WideCharConst: `L\'([^'\n]|\\[^\n])\'` 33//. - StringL: `\"([^"\n]|\\["\n])*\"` 34//. - WideStringL: `L\"([^"\n]|\\["\n])*\"` 35//. - Identifier: `{letter}+({letter}|{digit})*` 36//. - AssignOp: `*= /= %= += -= &= ^= <<= >>=` 37//. - EqualOp: `== !=` 38//. - RelOp: `<= >=` 39//. - ShiftOp: `<< >>` 40//. - LogOrOp: `||` 41//. - LogAndOp: `&&` 42//. - IncOp: `++ --` 43//. - Scope: `::` 44//. - Ellipsis: `...` 45//. - PmOp: `.* ->*` 46//. - ArrowOp: `->` 47//. - others: `!%^&*()-+={}|~[];:<>?,./` 48//. - BadToken: `others` 49//. 50struct Token 51{ 52 typedef int Type; 53 enum 54 { 55 Identifier = 258, //.< The first 256 are representing character literals. 56 Constant, 57 CharConst, 58 StringL, 59 AssignOp, 60 EqualOp, 61 RelOp, 62 ShiftOp, 63 LogOrOp, 64 LogAndOp, 65 IncOp, 66 Scope, 67 Ellipsis, 68 PmOp, 69 ArrowOp, 70 BadToken, 71 AUTO, 72 CHAR, 73 CLASS, 74 CONST, 75 DELETE, 76 DOUBLE, 77 ENUM, 78 EXTERN, 79 FLOAT, 80 FRIEND, 81 INLINE, 82 INT, 83 LONG, 84 NEW, 85 OPERATOR, 86 PRIVATE, 87 PROTECTED, 88 PUBLIC, 89 REGISTER, 90 SHORT, 91 SIGNED, 92 STATIC, 93 STRUCT, 94 TYPEDEF, 95 TYPENAME, 96 UNION, 97 UNSIGNED, 98 VIRTUAL, 99 VOID, 100 VOLATILE, 101 TEMPLATE, 102 MUTABLE, 103 BREAK, 104 CASE, 105 CONTINUE, 106 DEFAULT, 107 DO, 108 ELSE, 109 FOR, 110 GOTO, 111 IF, 112 OFFSETOF, 113 RETURN, 114 SIZEOF, 115 SWITCH, 116 THIS, 117 WHILE, 118 ATTRIBUTE, //=g++, 119 METACLASS, //=opencxx 120 UserKeyword, 121 UserKeyword2, 122 UserKeyword3, 123 UserKeyword4, 124 BOOLEAN, 125 EXTENSION, //=g++, 126 TRY, 127 CATCH, 128 THROW, 129 UserKeyword5, 130 NAMESPACE, 131 USING, 132 TYPEID, 133 TYPEOF, 134 WideStringL, 135 WideCharConst, 136 WCHAR, 137 138 //=non terminals, 139 140 ntDeclarator = 400, 141 ntName, 142 ntFstyleCast, 143 ntClassSpec, 144 ntEnumSpec, 145 ntDeclaration, 146 ntTypedef, 147 ntTemplateDecl, 148 ntMetaclassDecl, 149 ntParameterDecl, 150 ntLinkageSpec, 151 ntAccessSpec, 152 ntUserAccessSpec, 153 ntUserdefKeyword, 154 ntExternTemplate, 155 ntAccessDecl, 156 ntNamespaceSpec, 157 ntUsing, 158 ntTemplateInstantiation, 159 ntNamespaceAlias, 160 ntIfStatement, 161 ntSwitchStatement, 162 ntWhileStatement, 163 ntDoStatement, 164 ntForStatement, 165 ntBreakStatement, 166 ntContinueStatement, 167 ntReturnStatement, 168 ntGotoStatement, 169 ntCaseStatement, 170 ntDefaultStatement, 171 ntLabelStatement, 172 ntExprStatement, 173 ntTryStatement, 174 175 ntCommaExpr, 176 ntAssignExpr, 177 ntCondExpr, 178 ntInfixExpr, 179 ntPmExpr, 180 ntCastExpr, 181 ntUnaryExpr, 182 ntSizeofExpr, 183 ntNewExpr, 184 ntDeleteExpr, 185 ntArrayExpr, 186 ntFuncallExpr, 187 ntPostfixExpr, 188 ntUserStatementExpr, 189 ntDotMemberExpr, 190 ntArrowMemberExpr, 191 ntParenExpr, 192 ntStaticUserStatementExpr, 193 ntThrowExpr, 194 ntTypeidExpr, 195 ntTypeofExpr, 196 197 Ignore = 500, 198 ASM, 199 DECLSPEC, 200 PRAGMA, 201 INT64, 202 Comment // This could eventually be used to report all comments. 203 }; 204 205 Token() : ptr(0), length(0), type(BadToken) {} 206 Token(const char *s, size_t l, Type t) : ptr(s), length(l), type(t) {} 207 bool operator == (char c) const { return *ptr == c && length == 1;} 208 const char *ptr; 209 size_t length; 210 Type type; 211}; 212 213} 214 215#endif
Generated on Tue May 13 02:39:41 2008 by
synopsis (version 0.10)
synopsis (version 0.10)