当前位置: 首页>>代码示例>>C++>>正文


C++ TokenInfo::read方法代码示例

本文整理汇总了C++中TokenInfo::read方法的典型用法代码示例。如果您正苦于以下问题:C++ TokenInfo::read方法的具体用法?C++ TokenInfo::read怎么用?C++ TokenInfo::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TokenInfo的用法示例。


在下文中一共展示了TokenInfo::read方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readMessage

void ECodesAssembler :: readMessage(TokenInfo& token, int& verbId, IdentifierString& subject, int& paramCount)
{
   verbId = mapVerb(token.value);
   if (verbId == 0) {
      if (token.check("dispatch")) {
         verbId = DISPATCH_MESSAGE_ID;
      }
      else verbId = EVAL_MESSAGE_ID;
   }

   token.read();
   while (token.value[0] == '&') {
      subject.append(token.value);

      token.read();
      subject.append(token.value);
      token.read();
      if (token.value[0] == '$') {
         subject.append(token.value);
         token.read();
      }
   }
   if (token.value[0] == '[') {
      paramCount = token.readInteger(constants);
   }
   else token.raiseErr("Invalid operand (%d)");

   token.read("]", "Invalid operand (%d)");
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: refName

void ECodesAssembler :: compileProcedure(TokenInfo& token, _Module* binary, bool inlineMode, bool aligned)
{
   LabelInfo info;

   token.read();
   ReferenceNs refName(binary->Name(), token.value);

   ref_t reference = binary->mapReference(refName) | mskCodeRef;

	if (binary->mapSection(reference, true)!=NULL) {
		throw AssemblerException("Procedure already exists (%d)\n", token.terminal.row);
	}

   _Memory* code = binary->mapSection(reference, false);
	MemoryWriter writer(code);
   writer.writeDWord(0);

   token.read();

	while (!token.check("end")) {
      compileCommand(token, writer, info, binary);
	}

   (*code)[0] = writer.Position() - 4;

}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:26,代码来源:ecassembler.cpp

示例3: saveScript

void CFParser :: saveScript(TokenInfo& token, _ScriptReader& reader, Rule& rule)
{
   token.read(reader);
   while (!token.compare("=>") || token.state == dfaQuote) {
      token.writeLog();

      token.read(reader);
   }
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:9,代码来源:cfparser.cpp

示例4: compileRMCommand

void ECodesAssembler::compileRMCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer, _Module* binary)
{
   size_t reference1 = compileRArg(token, binary);

   token.read("%", "Invalid operand (%d)");
   token.read();
   size_t reference2 = compileMessageArg(token, binary);

   writeCommand(ByteCommand(code, reference1 & ~mskAnyRef, reference2), writer);
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例5: if

ref_t ECodesAssembler :: compileRArg(TokenInfo& token, _Module* binary)
{
   ident_t word = token.read();

   if (token.terminal.state == dfaFullIdentifier) {
      return binary->mapReference(token.value) | mskSymbolRelRef;
   }
   else if (word.compare("0")) {
      return 0;
   }
   else if (word.compare("const")) {
      token.read(":", "Invalid operand (%d)");
      token.read();

      if (word.compare("%")) {
         token.read();

         return compileRMessageArg(token, binary);
      }
      else return binary->mapReference(token.value) | mskConstantRef;
   }
   else if (word.compare("class")) {
      token.read(":", "Invalid operand (%d)");
      token.read();
      return binary->mapReference(token.value) | mskVMTRef;
   }
   else if (word.compare("intern")) {
      token.read(":", "Invalid operand (%d)");
      token.read();

      return binary->mapReference(token.value) | mskInternalRef;
   }
   else throw AssemblerException("Invalid operand (%d)\n", token.terminal.row);
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例6: if

ref_t ECodesAssembler :: compileRArg(TokenInfo& token, _Module* binary)
{
   ident_t word = token.read();

   if (token.terminal.state == dfaFullIdentifier) {
      return binary->mapReference(token.value) | mskSymbolRelRef;
   }
   else if (StringHelper::compare(word, "0")) {
      return 0;
   }
   else if (StringHelper::compare(word, "const")) {
      token.read(":", "Invalid operand");
      token.read();

      if (StringHelper::compare(word, "%")) {
         token.read();

         return compileRMessageArg(token, binary);
      }
      else return binary->mapReference(token.value) | mskConstantRef;
   }
   else if (StringHelper::compare(word, "class")) {
      token.read(":", "Invalid operand");
      token.read();
      return binary->mapReference(token.value) | mskVMTRef;
   }
   else if (StringHelper::compare(word, "api")) {
      token.read(":", "Invalid operand");
      token.read();

      ReferenceNs functionName(NATIVE_MODULE, token.value);
      return binary->mapReference(functionName) | mskNativeCodeRef;
   }
   else if (StringHelper::compare(word, "intern")) {
      token.read(":", "Invalid operand");
      token.read();

      return binary->mapReference(token.value) | mskInternalRef;
   }
   else throw AssemblerException("Invalid operand (%d)\n", token.terminal.row);
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:41,代码来源:ecassembler.cpp

示例7: function

void ECodesAssembler :: compileExtCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer, _Module* binary)
{
   ident_t word = token.read();
   if (StringHelper::compare(word, "extern")) {
      token.read(":", "Invalid operand");
      token.read();
      if (StringHelper::compare(token.value, "'dlls'", 6)) {
         ReferenceNs function(DLL_NAMESPACE, token.value + 6);

	      token.read(".", "dot expected (%d)\n");
	      function.append(".");
	      function.append(token.read());

         size_t reference = binary->mapReference(function) | mskImportRef;

         writeCommand(ByteCommand(code, reference), writer);

         return;
      }
   }
   throw AssemblerException("Invalid operand (%d)\n", token.terminal.row);
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:22,代码来源:ecassembler.cpp

示例8: if

void ECodesAssembler :: compileRCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer, _Module* binary)
{
   const wchar16_t* word = token.read();
   if (token.terminal.state == dfaFullIdentifier) {
      size_t reference = binary->mapReference(token.value) | mskSymbolRelRef;

      writeCommand(ByteCommand(code, reference), writer);
   }
   else if (ConstantIdentifier::compare(word, "const")) {
      token.read(_T(":"), _T("Invalid operand"));
      token.read();
      size_t reference = binary->mapReference(token.value) | mskConstantRef;

      writeCommand(ByteCommand(code, reference), writer);
   }
   else if (ConstantIdentifier::compare(word, "class")) {
      token.read(_T(":"), _T("Invalid operand"));
      token.read();
      size_t reference = binary->mapReference(token.value) | mskVMTRef;

      writeCommand(ByteCommand(code, reference), writer);
   }
   else throw AssemblerException(_T("Invalid operand (%d)\n"), token.terminal.row);
}
开发者ID:sanyaade-teachings,项目名称:elena-lang,代码行数:24,代码来源:ecassembler.cpp

示例9: compileJump

void ECodesAssembler :: compileJump(ByteCode code, TokenInfo& token, MemoryWriter& writer, LabelInfo& info)
{
   writer.writeByte(code);

   int label = 0;

   token.read();

   if (info.labels.exist(token.value)) {
      label = info.labels.get(token.value) - writer.Position() - 4;
   }
   else {
      info.fwdJumps.add(token.value, writer.Position());
   }

   writer.writeDWord(label);
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例10: function

void ECodesAssembler :: compileExtCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer, _Module* binary)
{
   ident_t word = token.read();
   if (word.compare("extern")) {
      token.read(":", "Invalid operand (%d)");
      token.read();
      if (token.check("'dlls'", 6)) {
         ReferenceNs function(DLL_NAMESPACE, token.value + 6);

	      token.read(".", "dot expected (%d)\n");
	      function.append(".");
	      function.append(token.read());

         size_t reference = binary->mapReference(function) | mskImportRef;

         writeCommand(ByteCommand(code, reference), writer);

         return;
      }
      else {
         ReferenceNs function(DLL_NAMESPACE, RTDLL_FORWARD);
         function.append(".");
         function.append(token.value);

         size_t reference = binary->mapReference(function) | mskImportRef;

         writeCommand(ByteCommand(code, reference), writer);

         return;
      }
   }
   else if (word.compare("api")) {
      token.read(":", "Invalid operand (%d)");
      token.read();

      ReferenceNs functionName(NATIVE_MODULE, CORE_MODULE);
      functionName.combine(token.value);

      size_t reference = binary->mapReference(functionName) | mskNativeCodeRef;

      writeCommand(ByteCommand(code, reference), writer);

      return;
   }
   throw AssemblerException("Invalid operand (%d)\n", token.terminal.row);
}
开发者ID:,项目名称:,代码行数:46,代码来源:

示例11: compileRJump

void ECodesAssembler :: compileRJump(ByteCode code, TokenInfo& token, MemoryWriter& writer, LabelInfo& info, _Module* binary)
{
   writer.writeByte(code);

   int label = 0;

   token.read();

   if (info.labels.exist(token.value)) {
      label = info.labels.get(token.value) - writer.Position() - 8;
   }
   else {
      info.fwdJumps.add(token.value, writer.Position() + 4);
   }
   size_t reference = compileRArg(token, binary);

   writer.writeDWord(reference);
   writer.writeDWord(label);
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例12: compileMccJump

void ECodesAssembler :: compileMccJump(ByteCode code, TokenInfo& token, MemoryWriter& writer, LabelInfo& info)
{
   writer.writeByte(code);

   int label = 0;

   token.read();

   if (info.labels.exist(token.value)) {
      label = info.labels.get(token.value) - writer.Position() - 8;
   }
   else {
      info.fwdJumps.add(token.value, 4 + writer.Position());
   }

   int message = token.readInteger(constants);

   writer.writeDWord(message);
   writer.writeDWord(label);
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例13: compileCommand


//.........这里部分代码省略.........
         case bcBCopyF:
         case bcALoadAI:
         case bcALoadFI:
         case bcPushAI:
         case bcOpen:
         case bcAddN:
         case bcMulN:
         case bcDLoadFI:
         case bcDLoadSI:
         case bcDSaveFI:
         case bcDSaveSI:
         case bcRestore:
         case bcReserve:
         case bcALoadBI:
         case bcASaveSI:
         case bcASaveFI:
         case bcNSaveI:
         case bcNLoadI:
         case bcESwapSI:
         case bcBSwapSI:
         case bcAXSaveBI:
         case bcELoadFI:
         case bcELoadSI:
         case bcESaveSI:
         case bcESaveFI:
         case bcShiftN:
         case bcEAddN:
         case bcDSwapSI:
         case bcAJumpI:
         case bcACallI:
         case bcNReadI:
         case bcNWriteI:
            compileICommand(opcode, token, writer);
            break;
         case bcQuitN:
         case bcPopI:
         case bcDCopy:
         case bcECopy:
         case bcSetVerb:
         case bcSetSubj:
         case bcAndN:
         case bcOrN:
         case bcPushN:
            compileNCommand(opcode, token, writer);
            break;
         case bcCopyM:
            compileMCommand(opcode, token, writer, binary);
            break;
         case bcIfB:
         case bcElseB:
         case bcIf:
         case bcElse:
         case bcLess:
         case bcNotLess:
         case bcNext:
         case bcJump:
         case bcHook:
         case bcAddress:
            compileJump(opcode, token, writer, info);
            break;
         case bcIfM:
         case bcElseM:
            compileMccJump(opcode, token, writer, info);
            break;
         case bcIfN:
         case bcElseN:
         case bcLessN:
            compileNJump(opcode, token, writer, info);
            break;
         case bcIfR:
         case bcElseR:
            compileRJump(opcode, token, writer, info, binary);
            break;
         case bcNewN:
            compileCreateCommand(opcode, token, writer, binary);
            break;
         case bcSelectR:
            compileRRCommand(opcode, token, writer, binary);
            break;
         case bcXIndexRM:
            compileRMCommand(opcode, token, writer, binary);
            break;
         default:
            writeCommand(ByteCommand(opcode), writer);
            break;
      }
   }
   else recognized = false;

   if (!recognized) {
      info.labels.add(token.value, writer.Position());

      fixJump(token.value, writer, info);

      writeCommand(ByteCommand(bcNop), writer);

      token.read(":", "':' expected (%d)\n");
   }
   token.read();
}
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: if

void CFParser :: defineGrammarRule(TokenInfo& token, _ScriptReader& reader, Rule& rule)
{
   // read: terminal [nonterminal] ;
   // read: nonterminal [nonterminal2] ;

   RuleType type = rtNormal;

   while (token.value[0] != ';' || token.state == dfaQuote) {

      if (token.state == dfaQuote) {
         if (rule.terminal) {
            rule.nonterminal = defineGrammarRule(token, reader);
            break;
         }
         else rule.terminal = writeBodyText(token.value);
      }
      else if (token.compare("<=")) {
         saveScript(token, reader, rule);
      }
      else if (token.state == dfaPrivate) {
         if (rule.terminal) {
            rule.nonterminal = defineGrammarRule(token, reader);
            break;
         }
         else {
            rule.prefixPtr = defineDSARule(token, reader);

            if (StringHelper::compare(token.value, LITERAL_KEYWORD)) {
               type = rtLiteral;
            }
            else if (StringHelper::compare(token.value, NUMERIC_KEYWORD)) {
               type = rtNumeric;
            }
            else if (StringHelper::compare(token.value, EPS_KEYWORD)) {
               type = rtEps;
            }
            else if (StringHelper::compare(token.value, EOF_KEYWORD)) {
               type = rtEof;
            }
            else if (StringHelper::compare(token.value, REFERENCE_KEYWORD)) {
               type = rtReference;
            }
            else if (StringHelper::compare(token.value, SCOPE_KEYWORD)) {
               type = rtScope;
            }
            else if (StringHelper::compare(token.value, IDLE_MAPPING_KEYWORD)) {
               type = rtNewIdleVariable;
            }
            else if (StringHelper::compare(token.value, VAR_KEYWORD)) {
               type = rtVariable;
            }
            else if (StringHelper::compare(token.value, MAPPING_KEYWORD)) {
               type = rtNewVariable;
            }
            //      else if (ConstantIdentifier::compare(token.value, ANY_KEYWORD)) {
      //         type = rtAny;
      //      }
            else if (StringHelper::compare(token.value, IDENTIFIER_KEYWORD)) {
               type = rtIdentifier;
            }
         }
      }
      else if (token.state == dfaIdentifier) {
         if (rule.nonterminal == 0) {
            rule.prefixPtr = defineDSARule(token, reader);

            rule.nonterminal = mapRuleId(token.value);
         }
         else if (rule.terminal == 0) {
            type = rtChomski;

            rule.terminal = mapRuleId(token.value);
         }
         else {
            if (type == rtChomski) {
               rule.terminal = defineGrammarRule(token, reader, rule.terminal);
            }
            else rule.nonterminal = defineGrammarRule(token, reader, rule.nonterminal);
            break;
         }
      }

      token.read(reader);
   }

   rule.postfixPtr = defineDSARule(token, reader);

   defineApplyRule(rule, type);
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:89,代码来源:cfparser.cpp


注:本文中的TokenInfo::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。