Keywords is a simple utility, which generate a text string recognizer from the given text string set. It is useful for the language development.
CCore-Keywords.exe <input-file> <output-file>
Keywords takes the required string set from the input file and place the generated code to the output file. The input file is a DDL file. It looks like this:
text[] Keywords= { "int", "sint", "uint", "ulen", "sint8", "sint16", "sint32", "sint64", "uint8", "uint16", "uint32", "uint64", "text", "ip", "struct", "type", "null", "scope", "include", "const" };
And the recognition code looks like this:
AtomClass Atom::GetWordClass(StrLen str) { if( !str ) return Atom_Name; switch( str[0] ) { case 'c' : { ++str; if( str.len==4 && str[0]=='o' && str[1]=='n' && str[2]=='s' && str[3]=='t' ) return Atom_const; else return Atom_Name; } case 'i' : { ++str; if( !str ) return Atom_Name; .... } default: return Atom_Name; } }
It is the method body, with the argument of the type StrLen and the return value of the type AtomClass, which must be declared in your code as an enum. If the given string is not from the set, the value Atom_Name is returned. Otherwise some Atom_<string> is returned, if the argument equals <string>.