diff options
author | Adrian Thurston <thurston@colm.net> | 2019-09-08 20:50:12 -0600 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2019-09-08 20:50:12 -0600 |
commit | a90aad94da641125a47de44a3f7552df8d861bee (patch) | |
tree | 243b8259f0f1338af21b1666cf4fd9b7be5f81b7 | |
parent | cf1179fca1bf8c3454730918f149c17c13f49cdc (diff) | |
download | colm-a90aad94da641125a47de44a3f7552df8d861bee.tar.gz |
merging aapl src dirs: added CmpStr and CmpString to colm/aapl
CmpStr is defined in colm/*.h so we need to also move it aside when we add it to aapl.
With this commit there are no more diffs between the aapl src dirs, with the
exception of a three files added to the aapl-repos package. Will use this as
the definitive version.
-rw-r--r-- | aapl/compare.h | 22 | ||||
-rw-r--r-- | src/compiler.h | 6 | ||||
-rw-r--r-- | src/cstring.h | 2 | ||||
-rw-r--r-- | src/parser.h | 2 | ||||
-rw-r--r-- | src/parsetree.h | 12 |
5 files changed, 33 insertions, 11 deletions
diff --git a/aapl/compare.h b/aapl/compare.h index 464e73e0..bbfa2136 100644 --- a/aapl/compare.h +++ b/aapl/compare.h @@ -24,6 +24,7 @@ #define _AAPL_COMPARE_H #include <string.h> +#include <string> #include "table.h" #ifdef AAPL_NAMESPACE @@ -51,6 +52,27 @@ namespace Aapl { */ /** + * \brief Compare two null terminated character sequences. + * + * This comparision class is a wrapper for strcmp. + */ +struct CmpStr +{ + /** + * \brief Compare two null terminated string types. + */ + static inline long compare(const char *k1, const char *k2) + { return strcmp(k1, k2); } +}; + +struct CmpString +{ + static inline long compare(const std::string &k1, const std::string &k2) + { return k1.compare( k2 ); } +}; + + +/** * \brief Compare a type for which < and > are implemented. * * CmpOrd is suitable for simple types such as integers and pointers that by diff --git a/src/compiler.h b/src/compiler.h index ac4a67e6..1b03504f 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -118,7 +118,7 @@ struct LelDefListEl { Production *prev, *next; }; typedef Vector< LangEl* > LangElVect; typedef Vector< ProdEl* > FactorVect; -typedef AvlMap<String, long, CmpStr> StringMap; +typedef AvlMap<String, long, ColmCmpStr> StringMap; typedef AvlMapEl<String, long> StringMapEl; enum PredType { @@ -488,7 +488,7 @@ struct TokenRegion; /* tree_t of instantiated names. */ typedef BstMapEl<String, NameInst*> NameMapEl; -typedef BstMap<String, NameInst*, CmpStr> NameMap; +typedef BstMap<String, NameInst*, ColmCmpStr> NameMap; typedef Vector<NameInst*> NameVect; typedef BstSet<NameInst*> NameSet; @@ -1104,7 +1104,7 @@ void errorStateLabels( const NameSet &locations ); struct ColmParser; -typedef AvlMap<String, ColmParser *, CmpStr> ParserDict; +typedef AvlMap<String, ColmParser *, ColmCmpStr> ParserDict; typedef AvlMapEl<String, ColmParser *> ParserDictEl; LangEl *declareLangEl( Compiler *pd, Namespace *nspace, diff --git a/src/cstring.h b/src/cstring.h index e2fc64e9..3c285153 100644 --- a/src/cstring.h +++ b/src/cstring.h @@ -852,7 +852,7 @@ template<class T> struct CmpStrTmpl } }; -typedef CmpStrTmpl<char> CmpStr; +typedef CmpStrTmpl<char> ColmCmpStr; #ifdef AAPL_NAMESPACE } diff --git a/src/parser.h b/src/parser.h index 97f2ede0..aafa3f2b 100644 --- a/src/parser.h +++ b/src/parser.h @@ -184,7 +184,7 @@ struct BaseParser virtual void go( long activeRealm ) = 0; - BstSet<String, CmpStr> genericElDefined; + BstSet<String, ColmCmpStr> genericElDefined; NamespaceQual *emptyNspaceQual() { diff --git a/src/parsetree.h b/src/parsetree.h index 4bf657d7..eea94454 100644 --- a/src/parsetree.h +++ b/src/parsetree.h @@ -285,7 +285,7 @@ void prepareLitString( String &result, bool &caseInsensitive, std::ostream &operator<<(std::ostream &out, const Token &token ); -typedef AvlMap< String, TokenInstance*, CmpStr > LiteralDict; +typedef AvlMap< String, TokenInstance*, ColmCmpStr > LiteralDict; typedef AvlMapEl< String, TokenInstance* > LiteralDictEl; /* Store the value and type of a priority augmentation. */ @@ -316,7 +316,7 @@ struct LexDefinition }; typedef Vector<String> StringVect; -typedef CmpTable<String, CmpStr> CmpStrVect; +typedef CmpTable<String, ColmCmpStr> CmpStrVect; struct NamespaceQual { @@ -623,7 +623,7 @@ struct TypeMapEl }; /* Symbol Map. */ -typedef AvlTree< TypeMapEl, String, CmpStr > TypeMap; +typedef AvlTree< TypeMapEl, String, ColmCmpStr > TypeMap; typedef Vector<TokenRegion*> RegionVect; @@ -793,7 +793,7 @@ struct GraphDictEl InputLoc loc; }; -typedef AvlTree<GraphDictEl, String, CmpStr> GraphDict; +typedef AvlTree<GraphDictEl, String, ColmCmpStr> GraphDict; typedef DList<GraphDictEl> GraphList; struct TypeAlias @@ -817,10 +817,10 @@ struct TypeAlias typedef DList<TypeAlias> TypeAliasList; -typedef AvlMap<String, ObjectField*, CmpStr> FieldMap; +typedef AvlMap<String, ObjectField*, ColmCmpStr> FieldMap; typedef AvlMapEl<String, ObjectField*> FieldMapEl; -typedef AvlMap<String, ObjectMethod*, CmpStr> MethodMap; +typedef AvlMap<String, ObjectMethod*, ColmCmpStr> MethodMap; typedef AvlMapEl<String, ObjectMethod*> MethodMapEl; /* tree_t of name scopes for an object def. All of the object fields inside this |