Skip to content

Commit

Permalink
implemented rem command and added new test
Browse files Browse the repository at this point in the history
implement rem command handler
set rem table entry with command token mode (not important, but can't
  null token mode) and rem command handler pointer
added translator test #15 for rem commands
  • Loading branch information
thunder422 committed Apr 6, 2013
1 parent 2a19163 commit 258f3a9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
12 changes: 12 additions & 0 deletions commandhandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,16 @@ TokenStatus Input_CmdHandler(Translator &t, CmdItem *cmdItem, Token *token)
}


//*******************************
//** REM COMMAND HANDLER **
//*******************************

TokenStatus Rem_CmdHandler(Translator &t, CmdItem *cmdItem, Token *token)
{
// just add rem command token with remark string to output
t.m_output->append(new RpnItem(cmdItem->token));
return Good_TokenStatus;
}


// end: commandhandlers.cpp
2 changes: 2 additions & 0 deletions commandhandlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ extern TokenStatus Let_CmdHandler(Translator &t, CmdItem *cmdItem,
Token *token);
extern TokenStatus Input_CmdHandler(Translator &t, CmdItem *cmdItem,
Token *token);
extern TokenStatus Rem_CmdHandler(Translator &t, CmdItem *cmdItem,
Token *token);


#endif // COMMANDHANDLER_H
3 changes: 2 additions & 1 deletion table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ static TableEntry tableEntries[] =
},
{ // Rem_Code
Command_TokenType, OneWord_Multiple,
"REM", NULL, Null_Flag, 4, None_DataType
"REM", NULL, Null_Flag, 4, None_DataType, NULL, NULL,
Command_TokenMode, Rem_CmdHandler
},
{ // If_Code
Command_TokenType, OneWord_Multiple,
Expand Down
8 changes: 8 additions & 0 deletions test/translator15.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
###############################################
# Translator Test #15: REMARKS (2013-04-05) #
###############################################

REM This is a comment
REM"Space not required if followed by non-alpha numeric"
REM+Same here
REM'and here
13 changes: 13 additions & 0 deletions test/translator15.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Input: REM This is a comment
Output: REM| This is a comment|

Input: REM"Space not required if followed by non-alpha numeric"
Output: REM|"Space not required if followed by non-alpha numeric"|

Input: REM+Same here
Output: REM|+Same here|

Input: REM'and here
Output: REM|'and here|

2 changes: 2 additions & 0 deletions translator.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ class Translator
Token *token);
friend TokenStatus Input_CmdHandler(Translator &t, CmdItem *cmdItem,
Token *token);
friend TokenStatus Rem_CmdHandler(Translator &t, CmdItem *cmdItem,
Token *token);
};


Expand Down

0 comments on commit 258f3a9

Please sign in to comment.