Macaulay2 Engine
Loading...
Searching...
No Matches

◆ readIdentifier()

int readIdentifier ( const std::string_view & str,
const IdentifierHash & map,
size_t & begin_loc,
size_t end_loc )

Definition at line 96 of file BasicPolyListParser.cpp.

97{
98 /*
99 std::cout << str << "(begin=" << begin_loc << ", end=" << end_loc << " )" << std::endl;
100 */
101 // if str[0] is a character, find the identifier, and increment str past that,
102 if (begin_loc >= end_loc or not isalpha(str[begin_loc])) return -1; // TODO: throw an error here?
103 size_t loc = begin_loc;
104 while (loc < end_loc and (isdigit(str[loc]) or isalpha(str[loc]) or str[loc] == '_'))
105 {
106 loc++;
107 }
108 std::string_view iden = str.substr(begin_loc, loc-begin_loc);
109 begin_loc = loc;
110 return map.find(iden);
111}
auto find(std::string_view s) const -> int

References IdentifierHash::find().

Referenced by parseBasicPoly().