lojix/logic/src/main/com/thesett/aima/logic/fol/isoprologparser/PrologParser.java
public Term variable() throws SourceCodeException
    {
        Token name = consumeToken(VAR);

        // Intern the variables name.
        int nameId = interner.internVariableName(name.image);

        // Check if the variable already exists in this scope, or create a new one if it does not.
        // If the variable is the unidentified anonymous variable '_', a fresh one will always be created.
        Variable var = null;

        if (!"_".equals(name.image))
        {
            var = variableContext.get(nameId);
        }

        if (var != null)
        {
            return var;
        }
        else
        {
            var = new Variable(nameId, null, name.image.equals("_"));
            variableContext.put(nameId, var);

            return var;
        }
    }
public Term variable() throws SourceCodeException
    {
        Token name = consumeToken(VAR);

        // Intern the variables name.
        int nameId = interner.internVariableName(name.image);

        // Check if the variable already exists in this scope, or create a new one if it does not.
        // If the variable is the unidentified anonymous variable '_', a fresh one will always be created.
        Variable var = null;

        if (!"_".equals(name.image))
        {
            var = variableContext.get(nameId);
        }

        if (var != null)
        {
            return var;
        }
        else
        {
            var = new Variable(nameId, null, name.image.equals("_"));
            variableContext.put(nameId, var);

            return var;
        }
    }
Parses a variable in first order logic. Variables are scoped within the current sentence being parsed, so if the
variable has been seen previously in the sentence it is returned rather than a new one being created.

@return A variable.

@throws SourceCodeException If the next token in the sequence is not a variable.