{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

tokenizingmachine

tokenizingmachine - | Concrete Template Body...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
// /*----------------------------------------------------------------------*\ // | Concrete Template Body : Tokenizing_Machine_Kernel_1_Body // \*----------------------------------------------------------------------*/ #ifndef CT_TOKENIZING_MACHINE_KERNEL_1_BODY #define CT_TOKENIZING_MACHINE_KERNEL_1_BODY 1 ///------------------------------------------------------------------------ /// Global Context -------------------------------------------------------- ///------------------------------------------------------------------------ #include "CT/Tokenizing_Machine/Kernel_1.h" ///------------------------------------------------------------------------ /// Public Operations ----------------------------------------------------- ///------------------------------------------------------------------------ concrete_template < concrete_instance class Rep > procedure_body Tokenizing_Machine_Kernel_1 < Rep > :: Insert ( preserves Character ch ) { select (self[buffer_type]) { case EMPTY_STRING : // entire content of buffer will be ch { Set_Buffer_And_Buffer_Type (ch, self[buffer], self[buffer_type]); } break; case QUESTION_MARK : { if (Is_Id_Var_Character (ch)) // building a variable token { self[buffer].Add (self[buffer].Length (), ch); self[buffer_type] = VARIABLE; } else if (Can_Start_Token (ch)) // buffer holds error token, restarting new token { Prepare_To_Dispense (ERROR, self[buffer], self[buffer_type], self[text_for_token], self[kind_of_token], self[token_ready] ); Set_Buffer_And_Buffer_Type (ch, self[buffer], self[buffer_type]); } else // continuing to build an error token {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
self[buffer].Add (self[buffer].Length (), ch); self[buffer_type] = ERROR; } } break; case VARIABLE : { if (Is_Id_Var_Character (ch)) // continuing to build a variable token { self[buffer].Add (self[buffer].Length (), ch); } else // buffer holds complete variable token { Prepare_To_Dispense (VARIABLE, self[buffer], self[buffer_type], self[text_for_token], self[kind_of_token], self[token_ready]); Set_Buffer_And_Buffer_Type (ch, self[buffer], self[buffer_type]); } } break; case ID_OR_OPRTR : { if (Is_Id_Var_Character (ch)) // continuing to build identifier or operator token { self[buffer].Add (self[buffer].Length (), ch); } else // buffer holds complete identifier or operator token { object Integer token_kind; token_kind = Id_Or_Operator (self[buffer]); Prepare_To_Dispense (token_kind, self[buffer], self[buffer_type], self[text_for_token], self[kind_of_token], self[token_ready]); Set_Buffer_And_Buffer_Type (ch, self[buffer], self[buffer_type]); } } break; case WHITE_SPACE : { if (Is_White_Space_Character (ch)) // continuing to build a white space token {
Background image of page 2
self[buffer].Add (self[buffer].Length (), ch);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}