本文整理汇总了C++中TokenInfo类的典型用法代码示例。如果您正苦于以下问题:C++ TokenInfo类的具体用法?C++ TokenInfo怎么用?C++ TokenInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TokenInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:26,代码来源:cfparser.cpp
示例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;
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:26,代码来源:ecassembler.cpp
示例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;
}
开发者ID:bschramke,项目名称:oauth2cpp,代码行数:25,代码来源:TokenFactory.cpp
示例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);
}
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:9,代码来源:cfparser.cpp
示例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);
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例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);
}
开发者ID:,项目名称:,代码行数:34,代码来源:
示例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)");
}
开发者ID:,项目名称:,代码行数:29,代码来源:
示例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);
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例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;
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:16,代码来源:cfparser.cpp
示例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);
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例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);
}
开发者ID:,项目名称:,代码行数:20,代码来源:
示例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);
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:41,代码来源:ecassembler.cpp
示例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);
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:22,代码来源:ecassembler.cpp
示例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);
}
开发者ID:,项目名称:,代码行数:46,代码来源:
示例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);
}
开发者ID:sanyaade-teachings,项目名称:elena-lang,代码行数:24,代码来源:ecassembler.cpp
示例16: 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,代码来源:
示例17: 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,代码来源:
示例18: compileMCommand
void ECodesAssembler :: compileMCommand(ByteCode code, TokenInfo& token, MemoryWriter& writer, _Module* binary)
{
ident_t word = token.read();
if (token.terminal.state == dfaInteger || constants.exist(word)) {
int m = 0;
if(token.getInteger(m, constants)) {
writeCommand(ByteCommand(code, m), writer);
}
else token.raiseErr("Invalid number (%d)\n");
}
else if (word.compare("subject")) {
token.read(":", "Invalid operand (%d)");
token.read();
int paramCount = 0; // NOTE: paramCount might be not equal to stackCount (the actual stack size) in the case if variables are used for virtual methods
int stackCount = 0;
int verbId = mapVerb(token.value);
if (verbId == 0) {
verbId = EVAL_MESSAGE_ID;
}
IdentifierString subject;
token.read();
bool first = true;
while(token.value[0] == '&') {
if (first) {
first = false;
}
else subject.append(token.value);
token.read();
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)");
ref_t subj = binary->mapSubject(subject, false);
writeCommand(ByteCommand(code, encodeMessage(subj, verbId, paramCount)), writer);
}
else throw AssemblerException("Invalid operand (%d)\n", token.terminal.row);
}
开发者ID:,项目名称:,代码行数:47,代码来源:
示例19: defineGrammarRule
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
示例20: compileICommand
void ECodesAssembler :: compileICommand(ByteCode code, TokenInfo& token, MemoryWriter& writer)
{
int offset = token.readSignedInteger(constants);
writeCommand(ByteCommand(code, offset), writer);
}
开发者ID:,项目名称:,代码行数:6,代码来源:
注:本文中的TokenInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论