public class Cnst extends Sym
The class Cnst contains more than just a symbol sequence. Cnst is a very important class in mmj as it is presently used to store information about Type Codes. Although the idea of creating a separate class to store Type Codes has been considered, the convenience and efficiency of hoarding the attributes here has proven irresistable.
The downside of storing grammatical attributes in Cnst is that changing mmj.verify.Grammar may mean changes in mmj.lang.Cnst. Also, these attributes are not loaded until the grammar is initialized.
The upside, of course, is that once a symbol is in hand, all information about that symbol is at hand, without an extra table look-up.
chapterNbr, description, isTempObject, SECTION_AND_MOBJ_NBR, sectionMObjNbr, sectionNbr, seq, SEQ
Modifier | Constructor and Description |
---|---|
|
Cnst(int seq,
java.util.Map<java.lang.String,Sym> symTbl,
java.util.Map<java.lang.String,Stmt> stmtTbl,
java.lang.String id)
Construct using sequence number and id string.
|
protected |
Cnst(int seq,
java.lang.String id)
Construct using sequence number and id string.
|
Modifier and Type | Method and Description |
---|---|
int |
convFromTypGRArrayAdd(TypeConversionRule r)
Add a TypeConversionRule to the constant's convFromTypGRArray.
|
boolean |
earleyFIRSTContainsSymbol(Cnst exprFIRST)
Convenient lookup routine used by mmj.verify.EarleyParse "Predictor" to
find out whether the next parse symbol in the ruleFormatExpr is the first
symbol of any grammar rule with this Type Code.
|
TypeConversionRule |
findFromTypConversionRule(Cnst typ)
Convenient lookup function to find a TypeConversionRule that will convert
the input Type Code to this Type Code.
|
TypeConversionRule[] |
getConvFromTypGRArray()
get convFromTypGRArray -- null or an array.
|
java.util.Set<Cnst> |
getEarleyFIRST()
Get earleyFIRST.
|
java.util.List<NotationRule> |
getEarleyRules()
Get earleyRules.
|
GRNode |
getGRRoot()
get gRRoot, , the grammar rule forest root for this Cnst.
|
NotationRule |
getLen1CnstNotationRule()
Get Len1CnstNotationRule.
|
int |
getNbrOccInCnstSyntaxAxioms()
get nbrOccInCnstSyntaxAxioms.
|
int |
getNbrOccInSyntaxAxioms()
get nbrOccInSyntaxAxioms.
|
NullsPermittedRule |
getNullsPermittedGR()
get nullsPermittedGR.
|
void |
incNbrOccInCnstSyntaxAxioms()
Increment nbrOccInCnstSyntaxAxioms by 1.
|
void |
incNbrOccInSyntaxAxioms()
Increment nbrOccInCnstSyntaxAxioms by 1.
|
boolean |
isActive()
Is Sym active?
|
boolean |
isGrammaticalTyp()
get isGrammaticalTyp.
|
boolean |
isLogicStmtTyp()
get isLogicStmtTyp.
|
boolean |
isProvableLogicStmtTyp()
get isProvableLogicStmtTyp.
|
boolean |
isSetTyp() |
boolean |
isSyntaxAxiomTyp()
get isSyntaxAxiomTyp.
|
boolean |
isVarTyp()
get isVarTyp.
|
void |
setConvFromTypGRArray(TypeConversionRule[] convFromTypGRArray)
Set convFromTypGRArray -- null or an array.
|
void |
setEarleyFIRST(java.util.Set<Cnst> earleyFIRST)
Set earleyFIRST.
|
void |
setEarleyRules(java.util.List<NotationRule> earleyRules)
Set earleyRules.
|
void |
setGrammaticalTyp(boolean isGrammaticalTyp)
set isGrammaticalTyp, true or false.
|
void |
setGRRoot(GRNode gRRoot)
set gRRoot to null or the grammar rule forest root for this Cnst.
|
void |
setLen1CnstNotationRule(NotationRule len1CnstNotationRule)
Set Len1CnstNotationRule.
|
void |
setLogicStmtTyp(boolean isLogicStmtTyp)
set isLogicStmtTyp, true or false.
|
void |
setNbrOccInCnstSyntaxAxioms(int nbrOccInCnstSyntaxAxioms)
set nbrOccInCnstSyntaxAxioms.
|
void |
setNbrOccInSyntaxAxioms(int nbrOccInSyntaxAxioms)
Set nbrOccInSyntaxAxioms.
|
void |
setNullsPermittedGR(NullsPermittedRule nullsPermittedRule)
Set nullsPermittedGR.
|
void |
setProvableLogicStmtTyp(boolean isProvableLogicStmtTyp)
set isProvableLogicStmtTyp, true or false.
|
void |
setSyntaxAxiomTyp(boolean isSyntaxAxiomTyp)
set isSyntaxAxiomTyp, true or false.
|
void |
setVarTyp(boolean isVarTyp)
set isVarTyp, true or false.
|
getChapterNbr, getDescription, getDescriptionForSearch, getIsTempObject, getOrigSectionNbr, getSectionMObjNbr, getSectionNbr, getSeq, setChapterNbr, setDescription, setIsTempObject, setSectionMObjNbr, setSectionNbr
protected Cnst(int seq, java.lang.String id) throws LangException
seq
- MObj.seq numberid
- Sym id stringLangException
- if id string is emptypublic Cnst(int seq, java.util.Map<java.lang.String,Sym> symTbl, java.util.Map<java.lang.String,Stmt> stmtTbl, java.lang.String id) throws LangException
seq
- MObj.seq numbersymTbl
- Symbol TablestmtTbl
- Symbol Tableid
- Sym id stringLangException
- if Sym.id duplicates the id of another Sym (Cnst or
Var) or Stmt label.public boolean isActive()
Cnst
s are always active as they cannot be defined inside a scope
level and must be defined at the global level.
public TypeConversionRule findFromTypConversionRule(Cnst typ)
typ
- Type Code to convert from.public boolean isVarTyp()
IsVarTyp says that this Cnst is used in a $f VarHyp statement as the Type Code of a variable (i.e. "wff" or "set").
public boolean isSetTyp()
public void setVarTyp(boolean isVarTyp)
IsVarTyp says that this Cnst is used in a $f VarHyp statement as the Type Code of a variable (i.e. "wff" or "set").
isVarTyp
- true or falsepublic boolean isProvableLogicStmtTyp()
isProvableLogicStmtTyp says that this Cnst is defined by the user, perhaps by default, as a Type Code used on Provable Logic Statments (and by extension, Logical Axioms.)
public void setProvableLogicStmtTyp(boolean isProvableLogicStmtTyp)
isProvableLogicStmtTyp says that this Cnst is defined by the user, perhaps by default, as a Type Code used on Provable Logic Statments (and by extension, Logical Axioms.)
isProvableLogicStmtTyp
- the new valuepublic boolean isLogicStmtTyp()
isLogicStmtTyp says that this Cnst is defined by the user, perhaps by default, as a Type Code used on Logic Statments (i.e. "wff"s)
public void setLogicStmtTyp(boolean isLogicStmtTyp)
isLogicStmtTyp says that this Cnst is defined by the user, perhaps by default, as a Type Code used on Logic Statments (i.e. "wff"s)
isLogicStmtTyp
- the new valuepublic boolean isSyntaxAxiomTyp()
isSyntaxAxiomTyp says that this Cnst is used as the Type Code of at least one Syntax Axiom.
public void setSyntaxAxiomTyp(boolean isSyntaxAxiomTyp)
isSyntaxAxiomTyp says that this Cnst is used as the Type Code of at least one Syntax Axiom.
isSyntaxAxiomTyp
- the new valuepublic boolean isGrammaticalTyp()
isGrammaticalTyp says that this Cnst is a Type Code used on at least one VarHyp or Syntax Axiom, or isLogicStmtTyp() == true or isProvableLogicStmtTyp() == true.
public void setGrammaticalTyp(boolean isGrammaticalTyp)
isGrammaticalTyp says that this Cnst is a Type Code used on at least one VarHyp or Syntax Axiom, or isLogicStmtTyp() == true or isProvableLogicStmtTyp() == true.
isGrammaticalTyp
- the new valuepublic GRNode getGRRoot()
GrammarRule Tree (forest) root node for Grammar rules whose Expression's "ruleFormatExpr" first symbol is this Cnst object. Null if no such tree exists or Grammar is not yet initialized.
public void setGRRoot(GRNode gRRoot)
GrammarRule Tree (forest) root node for Grammar rules whose Expression's "ruleFormatExpr" first symbol is this Cnst object. Null if no such tree exists or Grammar is not yet initialized.
gRRoot
- the grammar rule forest root for this Cnst. Null if there
is no forest for this Cnst.public int getNbrOccInCnstSyntaxAxioms()
nbrOccInCnstSyntaxAxioms counts how many times the constant symbol appears in the expression portion of Syntax Axioms having no variables (i.e. Named Typed Constants, which have expression length = 1 -- or, the much less popular "Literal" variety, which have expression length > 1.)
Note: the term "expression" refers to the portion of a Formula following the Type Code, which is always the first symbol of a Formula.
public void incNbrOccInCnstSyntaxAxioms()
public void setNbrOccInCnstSyntaxAxioms(int nbrOccInCnstSyntaxAxioms)
nbrOccInCnstSyntaxAxioms counts how many times the constant symbol appears in Syntax Axioms that contain no variables (i.e. Named Typed Constants, which have expression length = 1 -- or, the much less popular "Literal" variety, which have expression length > 1.)
nbrOccInCnstSyntaxAxioms
- the new valuepublic int getNbrOccInSyntaxAxioms()
nbrOccInSyntaxAxioms counts how many times a constant appears in the expression portion of Syntax Axioms. If this number equals 1 then the Syntax Axiom in which it appears has special grammatical parsing properties (i.e. the uniqueness is a strong hint to the parser :)
If this number is equal to zero that means the constant is defined but is not part of the grammar, and its usage in any other statement is in error. Constants with a value in this field greater than 1 are most likely just punctuation, like "(" and ")"; however, in set.mm the constant "/" is used as punctuation and as a Named Type Constant (see "cdiv", "wsb" and "wsbc".)
Note: the term "expression" refers to the portion of a Formula following the Type Code, which is always the first symbol of a Formula.
public void incNbrOccInSyntaxAxioms()
public void setNbrOccInSyntaxAxioms(int nbrOccInSyntaxAxioms)
nbrOccInSyntaxAxioms
- the new valuepublic TypeConversionRule[] getConvFromTypGRArray()
convFromTypGRArray - Array of Type Conversion GrammarRules, one for each Type Code that can be converted to *this* Type code. Array is null if no Type Conversions exist for the Cnst object (which may or may not be a Type Code), or if the grammar has not yet been (successfully) initialized.
public void setConvFromTypGRArray(TypeConversionRule[] convFromTypGRArray)
convFromTypGRArray
- (may be null).public int convFromTypGRArrayAdd(TypeConversionRule r)
Attempts to add a new TypeConversionRule.
Rejects duplicates with extreme prejudice (IllegalStateException).
Will create the necessary array if needed. Has an unfortunate habit of resizing the array every time a new rule is added. If there were tons of Type Conversion Rules this would be coded differently, but in that case, bigger problems would surface in mmj.verify.Grammar having to do with multitudes of Grammar Rule generated in a combinatorial explosion...sigh.
r
- TypeConversionRule to be added.java.lang.IllegalStateException
- is new rule is a duplicate in the
Cnst.convFromTypGRArray.public NullsPermittedRule getNullsPermittedGR()
nullsPermittedGR - set to Nulls Permitted GrammarRule if null values are permitted for variables/expressions with this Type Code, otherwise, if nulls are not permitted, nullsPermittedGR is set to null :0)
public void setNullsPermittedGR(NullsPermittedRule nullsPermittedRule)
nullsPermittedGR - set to Nulls Permitted GrammarRule if null values are permitted for variables/expressions with this Type Code, otherwise, if nulls are not permitted, nullsPermittedGR is set to null :0)
nullsPermittedRule
- or null if nulls are not permitted for this
Type Code.public NotationRule getLen1CnstNotationRule()
len1CnstNotationRule -- Notation Rule for Syntax Axiom with Formula Expression length of 1 consisting of just a Cnst (example, Cnst "c0" from set.mm would have a reference to c0's NotationRule in the "c0" Cnst, here.)
public void setLen1CnstNotationRule(NotationRule len1CnstNotationRule)
len1CnstNotationRule -- Notation Rule for Syntax Axiom with Formula Expression length of 1 consisting of just a Cnst (example, Cnst "c0" from set.mm would have a reference to c0's NotationRule in the "c0" Cnst, here.)
len1CnstNotationRule
- or null if there is not a
len1CnstNotationRule for this Cnst.public java.util.List<NotationRule> getEarleyRules()
earleyRules -- a list of the Grammar Rules with Type Code equal to this Cnst, sorted by GrammarRule.MAX_SEQ_NBR for mmj.verify.earleyParser.
public void setEarleyRules(java.util.List<NotationRule> earleyRules)
earleyRules -- a list of the Grammar Rules with Type Code equal to this Cnst, sorted by GrammarRule.MAX_SEQ_NBR for mmj.verify.earleyParser.
earleyRules
- List for this Type Code or null.public java.util.Set<Cnst> getEarleyFIRST()
earleyFIRST -- a Set of Cnst
s that can possibly begin a
"ruleFormatExpr" of this (Cnst) Type.
For example, the earleyFIRST set for "wff" contains "(" because there is a grammar rule with Type Code "wff" whose Formula ruleFormatExpr begins with "(".
Used by mmj.verify.earleyParser for Prediction Lookahead. Sorted by sym.ID.
public void setEarleyFIRST(java.util.Set<Cnst> earleyFIRST)
earleyFIRST -- a Set of Cnst
s that can possibly begin a
"ruleFormatExpr" of this (Cnst) Type.
For example, the earleyFIRST set for "wff" contains "(" because there is a grammar rule with Type Code "wff" whose Formula ruleFormatExpr begins with "(".
Used by mmj.verify.earleyParser for Prediction Lookahead. Sorted by sym.ID.
earleyFIRST
- (or null).public boolean earleyFIRSTContainsSymbol(Cnst exprFIRST)
exprFIRST
- the lookup CnstearleyFIRST.contains(exprFIRST)