![JAR search and dependency download from the Maven repository](/logo.png)
com.creativewidgetworks.goldparser.parser.Scope Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of goldengine Show documentation
Show all versions of goldengine Show documentation
Java implementation of Devin Cook's GOLD Parser engine
package com.creativewidgetworks.goldparser.parser;
import java.util.Map;
import java.util.TreeMap;
/**
* Scope
*
* Represents a scope of a program including variables local to the
* scope and the parent that contains this scope.
*
* Dependencies:
* @Variable
*
* @author Ralph Iden (http://www.creativewidgetworks.com)
* @version 5.0.0
*/
public class Scope {
private final String name;
private Scope parent;
private Map variables;
public static final String GLOBAL_SCOPE = "GLOBAL";
public Scope() {
this(GLOBAL_SCOPE);
}
public Scope(String scopeName) {
name = scopeName;
}
public Scope(String scopeName, Scope parentScope) {
this(scopeName);
parent = parentScope;
}
/**
* Get the scope's name
* @return the name of the scope
*/
public String getName() {
return name;
}
/**
* Get the parent scope
* @return the parent scope or null if the root (GLOBAL) scope has been reached
*/
public Scope getParent() {
return parent;
}
/**
* Retrieve the map containing the variables in use by the scope.
* @return Map of all the variables in use.
*/
public Map getVariables() {
if (variables == null) {
variables = new TreeMap();
}
return variables;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy