view anagram/agcore/coreinst.cpp @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1997-1999 Parsifal Software. All Rights Reserved.
 * Copyright 2006 David A. Holland. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * coreinst.cpp - template instantiation
 */

#include "agarray.h"
#include "agbaltree.h"
#include "agstring.h"
#include "checksum.h"
#include "csexp.h"
#include "error.h"
#include "ftpar.h"
#include "keyword.h"
#include "minmax.h"
#include "mrule.h"
#include "register.h"
#include "rproc.h"
#include "rule.h"
#include "symbol.h"
#include "token.h"
#include "tree.h"

//#define INCLUDE_LOGGING
#include "log.h"

#include "agarray-imp.h"
#include "agbaltree-imp.h"
#include "agstack-imp.h"
#include "register-imp.h"


////////////////////////////////////////////////////////////

#ifdef __IBMCPP__
/* last pruned who-knows-when */
/* last tested 20061022 */

// data.h
#pragma define(Triple<int>)
#pragma define(OrderedPair<int>)

// array
#pragma define(AgArray< AgBalancedTree <int> >)
#pragma define(AgArray< AgBalancedTree<MarkedRule> >)
#pragma define(AgArray<MarkedRule>)
#pragma define(AgArray<Rule>)
#pragma define(AgArray<Token>)
#pragma define(AgArray<int>)
#pragma define(AgArray<unsigned char>)
#pragma define(AgArray<unsigned>)

// stack
#pragma define(AgStack< AgStack<RuleElement> >)
#pragma define(AgStack<CastDescriptor>)
#pragma define(AgStack<CSegment>)
#pragma define(AgStack<CharSetExpression *>)
#pragma define(AgStack<Error>)
#pragma define(AgStack<FtParser::State>)
#pragma define(AgStack<FtParser::Transaction>)
#pragma define(AgStack<Keyword>)
#pragma define(AgStack<KeywordDescriptor>)
#pragma define(AgStack<MarkedRule>)
#pragma define(AgStack<Procedure>)
#pragma define(AgStack<ProcedureDescriptor>)
#pragma define(AgStack<Rule>)
#pragma define(AgStack<RuleDescriptor>)
#pragma define(AgStack<RuleElement>)
//#pragma define(AgStack<StateDescriptor>)
#pragma define(AgStack<Token>)
#pragma define(AgStack<VpRuleDescriptor>)
#pragma define(AgStack<int>)
#pragma define(AgStack<parse_tree_map>)
#pragma define(AgStack<sumentry>)
#pragma define(AgStack<token_name_map>)
#pragma define(AgStack<token_number_map>)
#pragma define(AgStack<unsigned int>)

// register
#pragma define(ObjectRegister<Procedure>)
#pragma define(ObjectRegister<RuleDescriptor>)
#pragma define(ObjectRegister<token_number_map>)
#pragma define(KeyedObjectRegister<parse_tree_map>)
#pragma define(KeyedObjectRegister<CastDescriptor>)
#pragma define(KeyedObjectRegister<KeywordDescriptor>)
//#pragma define(KeyedObjectRegister<StateDescriptor>)
#pragma define(KeyedObjectRegister<SymbolDescriptor>)
#pragma define(KeyedObjectRegister<VpRuleDescriptor>)
#pragma define(Each<Rule>)
#pragma define(Each<Token>)
#pragma define(Each<Cast>)
#pragma define(Each<Keyword>)
#pragma define(Each<Procedure>)

#endif /* __IBMCPP__ */

////////////////////////////////////////////////////////////

#ifdef __WATCOM_CPLUSPLUS__
/* last pruned who-knows-when */
/* last tested who-knows-when */

// Watcom 10.6 doesn't seem to have any mechanism for forcing template
// expansions.

// data.h
typedef Triple<int> tripleJunk;
typedef OrderedPair<int> pairJunk;

// array
typedef AgArray< AgBalancedTree <int> >        junk1;
typedef AgArray< AgBalancedTree<MarkedRule> >  junk2;
typedef AgArray<MarkedRule>                    junk3;
typedef AgArray<Rule>                          junk4;
typedef AgArray<Token>                         junk5;
typedef AgArray<int>                           junk6;
typedef AgArray<unsigned char>                 junk7;
typedef AgArray<unsigned>                      junk8;

// register
typedef ObjectRegister<Procedure>                   rjunk1;
typedef ObjectRegister<RuleDescriptor>              rjunk2;
typedef ObjectRegister<token_number_map>            rjunk3;
typedef KeyedObjectRegister<parse_tree_map>         rjunk4;
typedef KeyedObjectRegister<CastDescriptor>         rjunk5;
typedef KeyedObjectRegister<KeywordDescriptor>      rjunk6;
//typedef KeyedObjectRegister<StateDescriptor>        rjunk8;
typedef KeyedObjectRegister<SymbolDescriptor>       rjunk7;
typedef KeyedObjectRegister<VpRuleDescriptor>       rjunk9;
typedef Each<Rule>                               fake9;
typedef Each<Token>                              fake10;
typedef Each<Procedure>                          fake11;
typedef Each<Cast>                               fake12;
typedef Each<Keyword>                            fake13;

#endif /* __WATCOM_CPLUSPLUS__ */

////////////////////////////////////////////////////////////

#ifdef _MSC_VER
/* last pruned who-knows-when */
/* last tested who-knows-when */

// data.h
template class OrderedPair<int>;
template class Triple<int>;

// array
template class AgArray< AgBalancedTree <int> >;
template class AgArray< AgBalancedTree<MarkedRule> >;
template class AgArray<MarkedRule>;
template class AgArray<Rule>;
template class AgArray<Token>;
template class AgArray<int>;
template class AgArray<unsigned char>;
template class AgArray<unsigned>;

// stack
template class AgStack< AgStack<RuleElement> >;
template class AgStack<CastDescriptor>;
template class AgStack<CSegment>;
template class AgStack<CharSetExpression *>;
template class AgStack<Error>;
template class AgStack<FtParser::State>;
template class AgStack<FtParser::Transaction>;
template class AgStack<Keyword>;
template class AgStack<KeywordDescriptor>;
template class AgStack<MarkedRule>;
template class AgStack<Procedure>;
template class AgStack<ProcedureDescriptor>;
template class AgStack<Rule>;
template class AgStack<RuleDescriptor>;
template class AgStack<RuleElement>;
//template class AgStack<StateDescriptor>;
template class AgStack<Token>;
template class AgStack<VpRuleDescriptor>;
template class AgStack<int>;
template class AgStack<parse_tree_map>;
template class AgStack<token_name_map>;
template class AgStack<token_number_map>;
template class AgStack<unsigned int>;

// register
template class ObjectRegister<Procedure>;
template class ObjectRegister<RuleDescriptor>;
template class ObjectRegister<token_number_map>;
template class KeyedObjectRegister<parse_tree_map>;
template class KeyedObjectRegister<CastDescriptor>;
template class KeyedObjectRegister<KeywordDescriptor>;
//template class KeyedObjectRegister<StateDescriptor>;
template class KeyedObjectRegister<SymbolDescriptor>;
template class KeyedObjectRegister<VpRuleDescriptor>;

#endif /* _MSC_VER */

////////////////////////////////////////////////////////////

#ifdef __GNUC__
/* last pruned 20061022 */
/* last tested 20061022 */

// array
template class AgArray< AgBalancedTree <int> >;
template class AgArray<Rule>;
template class AgArray<RuleElement>;
template class AgArray<Token>;
template class AgArray<int>;
template class AgArray<unsigned>;

// balanced tree
template class AgBalancedTree<AgArray<int> >;
template class AgBalancedTree<OrderedPair<int> >;
template class AgBalancedTree<Triple<int> >;

// stack
template class AgStack< AgStack<RuleElement> >;
template class AgStack<CSegment>;
template class AgStack<Error>;
template class AgStack<FtParser::State>;
template class AgStack<FtParser::Transaction>;
template class AgStack<KeywordDescriptor>;
template class AgStack< Listener<FtParser::StackChanged> *>;
template class AgStack<ProcedureDescriptor>;
template class AgStack<Rule>;
template class AgStack<RuleDescriptor>;
template class AgStack<RuleElement>;
template class AgStack<SymbolDescriptor>;
template class AgStack<Token>;
template class AgStack<int>;
template class AgStack<parse_tree_map>;
template class AgStack<sumentry>;
template class AgStack<token_number_map>;

// register
template class ObjectRegister<CastDescriptor>;
template class ObjectRegister<KeywordDescriptor>;
template class ObjectRegister<ProcedureDescriptor>;
template class ObjectRegister<RuleDescriptor>;
template class ObjectRegister<SymbolDescriptor>;
template class ObjectRegister<VpRuleDescriptor>;
template class ObjectRegister<parse_tree_map>;
template class ObjectRegister<token_number_map>;
template class KeyedObjectRegister<CastDescriptor>;
template class KeyedObjectRegister<KeywordDescriptor>;
template class KeyedObjectRegister<SymbolDescriptor>;
template class KeyedObjectRegister<VpRuleDescriptor>;
template class KeyedObjectRegister<parse_tree_map>;

template class Each<Cast>;
template class Each<Keyword>;
template class Each<Procedure>;
template class Each<Rule>;
template class Each<Token>;

#endif /* __GNUC__ */

////////////////////////////////////////////////////////////

#ifdef __BCPLUSPLUS__
/* last pruned who-knows-when */
/* last tested who-knows-when */

#pragma option -Jgd

// data.h
typedef Triple<int> tripleJunk;
typedef OrderedPair<int> pairJunk;

// array
typedef AgArray< AgBalancedTree <int> >       fake1;
typedef AgArray< AgBalancedTree<MarkedRule> > fake2;
typedef AgArray<MarkedRule>                   fake3;
typedef AgArray<Rule>                         fake4;
typedef AgArray<Token>                        fake5;
typedef AgArray<int>                          fake6;
typedef AgArray<unsigned char>                fake7;
typedef AgArray<unsigned>                     fake8;

// stack
typedef AgStack< AgStack<RuleElement> > fake1;
typedef AgStack<CastDescriptor>         fake2a;
typedef AgStack<CSegment>               fake3;
typedef AgStack<CharSetExpression *>    fake4;
typedef AgStack<Error>                  fake5;
typedef AgStack<FtParser::State>        fake6;
typedef AgStack<FtParser::Transaction>  fake7;
typedef AgStack<Keyword>                fake8;
typedef AgStack<KeywordDescriptor>      fake8d;
typedef AgStack<MarkedRule>             fake9;
typedef AgStack<Procedure>              fake10;
typedef AgStack<ProcedureDescriptor>    fake11;
typedef AgStack<Rule>                   fake12;
typedef AgStack<RuleDescriptor>         fake13;
typedef AgStack<RuleElement>            fake14;
//typedef AgStack<StateDescriptor>        fake15;
typedef AgStack<Token>                  fake16;
typedef AgStack<VpRuleDescriptor>       fake17;
typedef AgStack<int>                    fake19;
typedef AgStack<parse_tree_map>         fake20;
typedef AgStack<token_name_map>         fake21;
typedef AgStack<token_number_map>       fake22;
typedef AgStack<unsigned int>           fake23;

// register
typedef ObjectRegister<Procedure>                fake1;
typedef ObjectRegister<RuleDescriptor>           fake2;
typedef ObjectRegister<token_number_map>         fake3;
typedef KeyedObjectRegister<parse_tree_map>      fake4;
typedef KeyedObjectRegister<CastDescriptor>      fake5;
typedef KeyedObjectRegister<KeywordDescriptor>   fake6;
//typedef KeyedObjectRegister<StateDescriptor>     fake8;
typedef KeyedObjectRegister<SymbolDescriptor>    fake7;
typedef KeyedObjectRegister<VpRuleDescriptor>    fake8;
typedef Each<Rule>                               fake9;
typedef Each<Token>                              fake10;
typedef Each<Procedure>                          fake11;
typedef Each<Cast>                               fake12;
typedef Each<Keyword>                            fake13;

#endif /* __BCPLUSPLUS__ */