Created
April 9, 2017 16:12
-
-
Save Sleeplessy/e1d9ecc71e8e768805312f90d9295c0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| std::string Bit8RegTable[] = | |
| { /* "V1" to "VF" */ | |
| } | |
| std::string InstructionTable[] = | |
| { /* like "ADD","MOV","SUB" */ | |
| } | |
| std::vector < std::string > libc8Lexer(std::string ProgLine) | |
| { | |
| // lexer for an asm Line | |
| std::vector < std::string > LexerOutput; | |
| std::string Token; | |
| std::stringstream LogStream; | |
| std::string LogType(""); | |
| for (auto CharInLine:ProgLine) | |
| { | |
| if (CharInLine != ' ' && CharInLine != ',') | |
| Token += CharInLine; | |
| else | |
| { | |
| if (std::find(InstructionTable.begin(), InstructionTable.end(), Token)) | |
| { | |
| LogType = "Instruction"; | |
| } | |
| else if (if (std::find(Bit8RegTable.begin(), Bit8RegTable.end(), Token)) | |
| { | |
| LogType = "8 Bit Register";} | |
| else | |
| if (Token == "I") | |
| { | |
| LogType = "Address Register";} | |
| else | |
| { | |
| LogType = "Var";} | |
| /* else { LogStream<<"Error token excepted."; | |
| throw LEXER_ET; } */ | |
| if (!LogType.empty()) | |
| { | |
| LogStream << LogType << " found: " << Token << std::endl; | |
| LexerOutput.push_back(Token);} | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment