public class Symbol
extends java.lang.Object
Symbol objects are made of two pieces: origin of the variable definition and its value as a string.
The origin field tells the source of the variable definition. Builtin preprocessor variables are also presented. That allows for an unified implementation of redefinitions of the builtins.
This class provides all methods needed for backing up the Progress
references like {&name}
, include file references like
{file &name=value}
and DEFINED(name)
preprocessor
built-in function.
Modifier and Type | Field and Description |
---|---|
static int |
ARGUMENT
origin definition constant for symbols defined with includes
|
static int |
BUILTIN
origin definition constant for built-in preprocessor symbols
|
static int |
GLOBAL
origin definition constant for symbols defined with &GLOBAL-DEFINE
|
private static int |
MAXIMUM
mamximum origin definition constant
|
private static int |
MINIMUM
minimum origin definition constant
|
private static java.lang.String[] |
orig
textual origin definition constants
|
private int |
origin
keeps the origin of this symbol
|
static int |
SCOPED
origin definition constant for symbols defined with &SCOPED-DEFINE
|
static int |
UNDEFINED
origin definition constant for undefined symbols
|
private java.lang.String |
value
keeps the value string of this symbol
|
Constructor and Description |
---|
Symbol(int origin,
java.lang.String value)
Constructor taking a
String . |
Symbol(int origin,
java.lang.StringBuilder value)
Constructor taking a
StringBuilder . |
Modifier and Type | Method and Description |
---|---|
static integer |
builtinVariable()
Fails the attempt to get the symbol origin of built-in variables
for
DEFINED() . |
static integer |
defined()
Gets the symbol origin of undefined variables for
DEFINED()
using the "hack" that an undefined variable (represented in an
expression by a token or AST node) will disappear during expression
processing, all usage of DEFINED() on an undefined
variable will match this and only this method signature. |
static integer |
defined(decimal origin)
Returns the symbol origin of a preprocessor variable specified as
the parameter.
|
static integer |
defined(integer origin)
Returns the symbol origin of a preprocessor variable specified as
the parameter.
|
int |
getOrigin()
Gets the symbol origin.
|
java.lang.String |
getOriginText()
Gets the symbol origin as a string.
|
java.lang.String |
getValue()
Gets the symbol value
|
static integer |
globalVariable()
Gets the symbol origin of global preprocessor variables for
DEFINED() . |
static integer |
includeFileArgument()
Gets the symbol origin of include file arguments for
DEFINED() . |
static integer |
scopedVariable()
Gets the symbol origin of scoped preprocessor variables for
DEFINED() . |
java.lang.String |
toString()
Converts the symbol into a string.
|
public static final int UNDEFINED
public static final int GLOBAL
public static final int ARGUMENT
public static final int SCOPED
public static final int BUILTIN
private static final int MINIMUM
private static final int MAXIMUM
private static final java.lang.String[] orig
private final int origin
private final java.lang.String value
public Symbol(int origin, java.lang.String value)
String
.origin
- symbol's origin expressed as a definition constant.value
- a string representing symbol's value as a
String
public Symbol(int origin, java.lang.StringBuilder value)
StringBuilder
.origin
- symbol's origin expressed as a definition constant.value
- a string representing symbol's valuepublic static integer globalVariable()
DEFINED()
.GLOBAL
.public static integer scopedVariable()
DEFINED()
.SCOPED
.public static integer includeFileArgument()
DEFINED()
.ARGUMENT
.public static integer builtinVariable()
DEFINED()
. In the Progress 4GL preprocessor, using
DEFINED()
on a built-in variable causes a fatal error
so this implementation duplicates the same result (although it is
not displayed as a Progress style error message).DEFINED()
against a built-in preprocessor variable.public static integer defined()
DEFINED()
using the "hack" that an undefined variable (represented in an
expression by a token or AST node) will disappear during expression
processing, all usage of DEFINED()
on an undefined
variable will match this and only this method signature.UNDEFINED
.public static integer defined(integer origin)
origin
parameter through.public static integer defined(decimal origin)
origin
parameter through.public int getOrigin()
Symbol.GLOBAL
for symbols defined with
&GLOBAL-DEFINE
;
Symbol.ARGUMENT
for symbols defined with
include file references;
Symbol.SCOPED
for symbols defined with
&SCOPED-DEFINE
;
Symbol.BUILTIN
for built-in preprocessor
symbols.
public java.lang.String getOriginText()
"global"
for symbols defined with
&GLOBAL-DEFINE
;
"argument"
for symbols defined with
include file references;
"scoped"
for symbols defined with
&SCOPED-DEFINE
;
"builtin"
for built-in preprocessor
symbols.
public java.lang.String getValue()
public java.lang.String toString()
toString
in class java.lang.Object