File indexing completed on 2025-02-09 04:11:06
0001 /* 0002 SPDX-FileCopyrightText: 2003-2009 Cies Breijs <cies AT kde DOT nl> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 0008 #include "token.h" 0009 0010 0011 Token::Token() 0012 : _type(Token::NotSet), 0013 _look(QLatin1String("")), 0014 _startRow(0), 0015 _startCol(0), 0016 _endRow(0), 0017 _endCol(0) 0018 { 0019 } 0020 0021 0022 Token::Token(int type, const QString& look, int startRow, int startCol, int endRow, int endCol) 0023 : _type(type), 0024 _look(look), 0025 _startRow(startRow), 0026 _startCol(startCol), 0027 _endRow(endRow), 0028 _endCol(endCol) 0029 { 0030 } 0031 0032 0033 bool Token::operator==(const Token& n) const 0034 { 0035 if (n.type() == _type || 0036 n.look() == _look || 0037 n.startRow() == _startRow || 0038 n.startCol() == _startCol || 0039 n.endRow() == _endRow || 0040 n.endCol() == _endCol) return true; 0041 return false; 0042 } 0043 0044 0045 int Token::typeToCategory(int type) 0046 { 0047 switch (type) { 0048 0049 //BEGIN GENERATED token_switch_cpp CODE 0050 0051 /* The code between the line that start with "//BEGIN GENERATED" and "//END GENERATED" 0052 * is generated by "generate.rb" according to the definitions specified in 0053 * "definitions.rb". Please make all changes in the "definitions.rb" file, since all 0054 * all change you make here will be overwritten the next time "generate.rb" is run. 0055 * Thanks for looking at the code! 0056 */ 0057 0058 case Mod: 0059 case Sin: 0060 case GoX: 0061 case GoY: 0062 case FontSize: 0063 case GetDirection: 0064 case Cos: 0065 case CanvasColor: 0066 case Tan: 0067 case Backward: 0068 case CanvasSize: 0069 case TurnRight: 0070 case Pi: 0071 case Forward: 0072 case Message: 0073 case Random: 0074 case Sqrt: 0075 case Go: 0076 case ArcSin: 0077 case Ask: 0078 case Assert: 0079 case PenUp: 0080 case Print: 0081 case Clear: 0082 case ArcCos: 0083 case SpriteHide: 0084 case TurnLeft: 0085 case PenWidth: 0086 case Direction: 0087 case ArcTan: 0088 case SpriteShow: 0089 case Center: 0090 case Round: 0091 case GetX: 0092 case GetY: 0093 case PenColor: 0094 case PenDown: 0095 case Reset: 0096 return CommandCategory; 0097 0098 case Else: 0099 case Break: 0100 case Return: 0101 case While: 0102 case Step: 0103 case For: 0104 case Wait: 0105 case ForTo: 0106 case Repeat: 0107 case To: 0108 case Exit: 0109 case If: 0110 return ControllerCommandCategory; 0111 0112 case Number: 0113 return NumberCategory; 0114 0115 case ParenthesisOpen: 0116 case ParenthesisClose: 0117 return ParenthesisCategory; 0118 0119 case True: 0120 case False: 0121 return TrueFalseCategory; 0122 0123 case FunctionCall: 0124 return FunctionCallCategory; 0125 0126 case GreaterThan: 0127 case LessOrEquals: 0128 case Equals: 0129 case LessThan: 0130 case GreaterOrEquals: 0131 case NotEquals: 0132 return ExpressionCategory; 0133 0134 case ArgumentSeparator: 0135 return ArgumentSeparatorCategory; 0136 0137 case Power: 0138 case Subtraction: 0139 case Multiplication: 0140 case Division: 0141 case Addition: 0142 return MathOperatorCategory; 0143 0144 case Comment: 0145 return CommentCategory; 0146 0147 case Assign: 0148 return AssignmentCategory; 0149 0150 case Or: 0151 case And: 0152 case Not: 0153 return BooleanOperatorCategory; 0154 0155 case Scope: 0156 case ScopeOpen: 0157 case ScopeClose: 0158 return ScopeCategory; 0159 0160 case Variable: 0161 return VariableCategory; 0162 0163 case StringDelimiter: 0164 case String: 0165 return StringCategory; 0166 0167 case Learn: 0168 return LearnCommandCategory; 0169 0170 0171 //END GENERATED token_switch_cpp CODE 0172 0173 } 0174 return UnknownCategory; 0175 } 0176 0177 0178 0179