本文整理汇总了C++中TokenInfo类的典型用法代码示例。如果您正苦于以下问题:C++ TokenInfo类的具体用法?C++ TokenInfo怎么用?C++ TokenInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TokenInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyRule
bool CFParser :: applyRule(size_t ruleId, TokenInfo& token, _ScriptReader& reader)
{
ident_t name = retrieveKey(_names.start(), ruleId, DEFAULT_STR);
size_t readerRollback = reader.Position();
size_t coderRollback = token.LogPosition();
RuleMap::Iterator it = _rules.getIt(ruleId);
while(!it.Eof()) {
CFParser::TokenInfo tokenCopy(token);
if ((*it).apply(*it, tokenCopy, reader)) {
tokenCopy.save(token);
return true;
}
// roll back
reader.seek(readerRollback);
token.trimLog(coderRollback);
it = _rules.getNextIt(ruleId, it);
}
return false;
}
示例2: compileProcedure
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;
}
示例3: assert
TokenInfo* TokenFactory::fromJson(const std::string jsonStr)
{
jsonxx::Object jsonRoot;
assert(jsonRoot.parse(jsonStr));
//check that json object has all needed information
assert(jsonRoot.has<jsonxx::String>("refresh_token"));
assert(jsonRoot.has<jsonxx::String>("access_token"));
assert(jsonRoot.has<jsonxx::String>("token_type"));
assert(jsonRoot.has<jsonxx::Number>("expires_in"));
TokenInfo* tokenInfo = nullptr;
std::string tokenType = jsonRoot.get<jsonxx::String>("token_type");
if(tokenType == "Bearer")
{
tokenInfo = new BearerToken();
tokenInfo->setAccessToken(jsonRoot.get<jsonxx::String>("access_token"));
tokenInfo->expiresIn(jsonRoot.get<jsonxx::Number>("expires_in"));
tokenInfo->setRefreshToken(jsonRoot.get<jsonxx::String>("refresh_token"));
}
return tokenInfo;
}
示例4: saveScript
void CFParser :: saveScript(TokenInfo& token, _ScriptReader& reader, Rule& rule)
{
token.read(reader);
while (!token.compare("=>") || token.state == dfaQuote) {
token.writeLog();
token.read(reader);
}
}
示例5: 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);
}
示例6: compileRArg
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);
}
示例7: 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)");
}
示例8: compileCreateCommand
void ECodesAssembler :: compileCreateCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer, _Module* binary)
{
ref_t reference = compileRArg(token, binary);
int n = token.readInteger(constants);
writeCommand(ByteCommand(code, reference, n), writer);
}
示例9: defineDSARule
size_t CFParser :: defineDSARule(TokenInfo& token, _ScriptReader& reader)
{
ident_t s = token.getLog();
if (!emptystr(s)) {
MemoryWriter writer(&_body);
size_t ptr = writer.Position();
writer.writeLiteral(s);
token.clearLog();
return ptr;
}
else return 0;
}
示例10: compileNNCommand
void ECodesAssembler :: compileNNCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer)
{
int n1 = token.readInteger(constants);
int n2 = token.readInteger(constants);
writeCommand(ByteCommand(code, n1, n2), writer);
}
示例11: 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);
}
示例12: compileRArg
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);
}
示例13: compileExtCommand
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);
}
示例14: compileExtCommand
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);
}
示例15: compileRCommand
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);
}