;
enum: T_ENUM T_ID T_BRACE_OPEN fields T_BRACE_CLOSE {
- $$ = new tidl::Enum($2->ToString(), $4, $1->GetComments(),
- @1.begin.line);
+ if (ps->GetVersion() < 2) {
+ ps->ReportError("syntax error. \"enum is supported from protocol version 2\".", @1.begin.line);
+ ps->ReportError("try to use protocol version 2.", @1.begin.line);
+ } else {
+ $$ = new tidl::Enum($2->ToString(), $4, $1->GetComments(),
+ @1.begin.line);
+ }
delete $2;
}
;
delete $1;
}
| T_ID {
- bool found = false;
- tidl::BaseType::UserType type;
- if (currentInterfaceEnums) {
- for (auto& e : *currentInterfaceEnums) {
- if (e->GetID() == $1->ToString()) {
- type = tidl::BaseType::UserType::ENUM;
- found = true;
- break;
+ if (ps->GetVersion() < 2) {
+ $$ = new tidl::BaseType($1->ToString(), $1->GetComments(), true);
+ } else {
+ bool found = false;
+ tidl::BaseType::UserType type;
+ if (currentInterfaceEnums) {
+ for (auto& e : *currentInterfaceEnums) {
+ if (e->GetID() == $1->ToString()) {
+ type = tidl::BaseType::UserType::ENUM;
+ found = true;
+ break;
+ }
}
}
- }
- if (!found && document) {
- for (auto& b : document->GetBlocks()) {
- if (b->GetType() == tidl::Block::TYPE_STRUCTURE
- && b->GetID() == $1->ToString()) {
- type = tidl::BaseType::UserType::STRUCTURE;
- found = true;
- break;
+ if (!found && document) {
+ for (auto& b : document->GetBlocks()) {
+ if (b->GetType() == tidl::Block::TYPE_STRUCTURE
+ && b->GetID() == $1->ToString()) {
+ type = tidl::BaseType::UserType::STRUCTURE;
+ found = true;
+ break;
+ }
}
}
- }
- if(!found && currentDeclarations) {
- for (auto& d : *currentDeclarations) {
- if (d->GetMethodType() == tidl::Declaration::MethodType::DELEGATE) {
- if (d->GetID() == $1->ToString()) {
- type = tidl::BaseType::UserType::DELEGATE;
- found = true;
- break;
+ if(!found && currentDeclarations) {
+ for (auto& d : *currentDeclarations) {
+ if (d->GetMethodType() == tidl::Declaration::MethodType::DELEGATE) {
+ if (d->GetID() == $1->ToString()) {
+ type = tidl::BaseType::UserType::DELEGATE;
+ found = true;
+ break;
+ }
}
}
}
- }
- if (found) {
- $$ = new tidl::BaseType($1->ToString(), $1->GetComments(), type);
- } else {
- ps->ReportError("Unknown type : " + $1->ToString(), @1.begin.line);
- $$ = NULL;
+ if (found) {
+ $$ = new tidl::BaseType($1->ToString(), $1->GetComments(), type);
+ } else {
+ ps->ReportError("Unknown type : " + $1->ToString(), @1.begin.line);
+ $$ = NULL;
+ }
}
delete $1;
}