Added two functions which will be used for checking if we get an identifier that ia valid for being a path identifier and also one for normal identifiers.
parent
f92277e9e6
commit
467bdb6ff9
|
@ -59,6 +59,8 @@ public class Symbol
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* TODO: Later build classes specific to symbol */
|
||||
public bool isType(string tokenStr)
|
||||
{
|
||||
|
@ -157,6 +159,32 @@ public bool isAccessor(Token token)
|
|||
getSymbolType(token) == SymbolType.PROTECTED;
|
||||
}
|
||||
|
||||
public bool isIdentifier_NoDot(Token tokenIn)
|
||||
{
|
||||
/* Make sure it isn't any other type of symbol */
|
||||
if(getSymbolType(tokenIn) == SymbolType.UNKNOWN)
|
||||
{
|
||||
return isIdentifier(tokenIn.getToken());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isIdentifier_Dot(Token tokenIn)
|
||||
{
|
||||
/* Make sure it isn't any other type of symbol */
|
||||
if(getSymbolType(tokenIn) == SymbolType.UNKNOWN)
|
||||
{
|
||||
return isPathIdentifier(tokenIn.getToken()) || isIdentifier(tokenIn.getToken());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public SymbolType getSymbolType(Token tokenIn)
|
||||
{
|
||||
string token = tokenIn.getToken();
|
||||
|
@ -182,11 +210,6 @@ public SymbolType getSymbolType(Token tokenIn)
|
|||
{
|
||||
return SymbolType.NUMBER_LITERAL;
|
||||
}
|
||||
/* Type name (TODO: Track user-defined types) */
|
||||
else if (isType(token))
|
||||
{
|
||||
return SymbolType.TYPE;
|
||||
}
|
||||
/* `if` */
|
||||
else if(cmp(token, "if") == 0)
|
||||
{
|
||||
|
@ -277,11 +300,6 @@ public SymbolType getSymbolType(Token tokenIn)
|
|||
{
|
||||
return SymbolType.MODULE;
|
||||
}
|
||||
/* Identifier check (TODO: Track vars) */
|
||||
else if (isIdentifier(token))
|
||||
{
|
||||
return SymbolType.IDENTIFIER;
|
||||
}
|
||||
/* Semi-colon `;` check */
|
||||
else if (token[0] == ';')
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue