$ template make_typeinfo() $ $ // Generate the typeinfo.cpp file $ output $basedir + '/typeinfo.cpp' /* This file was generated by SableCC (http://www.sablecc.org/). */ #include "node.h" #include "token.h" #include "list.h" #include "prod.h" #include "analysis.h" bool $namespace::_TypeInfo::is (const _TypeInfo *inf) const { if ( inf->type_id == type_id ) return true; if ( !parent) return false; return parent->is(inf); } void $namespace::_TypeInfo::apply (Analysis& analysis, Node& node) const { (analysis.*apply_ptr) (node); } const $namespace::_TypeInfo $namespace::Node::type_info = { "Node", 0, 0, -1, false, 0, 0, _TypeInfo::is_other, 0 }; const $namespace::_TypeInfo $namespace::Token::type_info = { "Token", &Node::type_info, 1, -1, false, 0, 0, _TypeInfo::is_other, 0 }; const $namespace::_TypeInfo $namespace::TEOF::type_info = { "TEOF", &Token::type_info, 2, ${tokens/eof/@parser_index}, false, 0, 0, _TypeInfo::is_token, (_TypeInfo::apply_t)&Analysis::caseTEOF }; static int _type_elems_start[] = {0, 0}; const $namespace::_TypeInfo $namespace::Start::type_info = { "Start", &Node::type_info, 3, -1, false, 2, _type_elems_start, _TypeInfo::is_prod, (_TypeInfo::apply_t)&Analysis::caseStart }; $ foreach {//token} const $namespace::_TypeInfo $namespace::@ename::type_info = { "@ename", &Token::type_info, ${3 + position()}, $ if @parser_index @parser_index, $ else -1, $ end $ if @value false, $ else true, $ end 0, 0, _TypeInfo::is_token, (_TypeInfo::apply_t)&Analysis::case@ename }; $ end foreach $ foreach {//production} const $namespace::_TypeInfo $namespace::@ename::type_info = { "@ename", &Node::type_info, ${3 + count(/parser/tokens/token) + position()}, -1, false, 0, 0, _TypeInfo::is_prod, 0 }; $ end foreach $ foreach {//alt} static int _type_elems_${position()}[] = {[-foreach {elem}-][-if @is_list-]1[-else-]0[-end-][-sep ', '-][-end foreach-]}; const $namespace::_TypeInfo $namespace::@ename::type_info = { "@ename", &${../@ename}::type_info, ${3 + count(/parser/tokens/token) + count(/parser/productions/production) + position()}, -1, false, ${count(elem)}, _type_elems_${position()}, _TypeInfo::is_prod, (_TypeInfo::apply_t)&Analysis::case@ename }; $ end foreach $ end output $ end template