org.erights.e.elang.evm
Class NounPattern

java.lang.Object
  |
  +--org.erights.e.elang.evm.ParseNode
        |
        +--org.erights.e.elang.evm.ENode
              |
              +--org.erights.e.elang.evm.Pattern
                    |
                    +--org.erights.e.elang.evm.NounPattern
All Implemented Interfaces:
Cloneable, EPrintable, MatchMaker
Direct Known Subclasses:
FinalPattern, VarPattern

public abstract class NounPattern
extends Pattern

Safe: BNF: ID ':' expr

The identifier on the left is the defining occurrence of a variable name. The expression on the right is a "value guard expression". The object it evaluates to will be treated as a ValueGuard, and asked to make a value initialized from a specimen, as if:


      def value := valueGuard coerce(specimen, XXX)

 

This value is then defined as the value for a variable of this name in the scope starting immediately after this name.

But wait! That scope includes the value guard expression?!? As with the def-expression, this circularity is indeed allowed and correct in the user-level language, but the kernel-level language (ie, the parse node FinalPattern) imposes a well-formedness criterea that allows us to evaluate in the wrong order without effect. A circular user-level final-pattern must be translated into a well-formed kernel-level FinalPattern.

Author:
Mark S. Miller
See Also:
org.erights.e.elang.evm.DefineExpr, org.erights.e.elang.evm.FinalPattern, org.erights.e.elang.evm.VarPattern

Field Summary
private  AtomicExpr myNoun
           
private  String myVarName
           
 
Fields inherited from class org.erights.e.elang.evm.ENode
 
Fields inherited from class org.erights.e.elang.evm.ParseNode
NUM_PR, PR_ASSIGN, PR_CALL, PR_COMP, PR_EEXPR, PR_LISTPATT, PR_ORDER, PR_PATTERN, PR_PRIM, PR_START
 
Constructor Summary
(package private) NounPattern(SourceSpan optSpan, String varName, AtomicExpr noun)
          If 'varName' would shadow a non-shadowable, throw a (XXX to be defined) exception instead.
 
Method Summary
(package private)  void ensureWellFormed(EExpr guardExpr)
           
 NounExpr getNoun()
          Enabled:
(package private) abstract  EExpr guardExpr()
           
 boolean matchBind(ConstList args, Object specimen, FlexList bindings)
          Enabled:
 String optName()
          Enabled: A Definer will never return null for this.
 void subPrintOn(TextWriter out, int priority)
          Enabled:
 
Methods inherited from class org.erights.e.elang.evm.Pattern
__printOn, substitute, testMatch
 
Methods inherited from class org.erights.e.elang.evm.ENode
cleanCopy, computeStaticScope, copy, getOptPatternMap, getOptScopeMap, getPatternMap, getScopeMap, qbuild, setPatternMap, setScopeMap, staticScope, synEnv, welcome
 
Methods inherited from class org.erights.e.elang.evm.ParseNode
asText, getOptSpan, lnPrintOn, lnPrintOn, matchBind, matchBind, matchBind, printListOn, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myVarName

private final String myVarName

myNoun

private final AtomicExpr myNoun
Constructor Detail

NounPattern

NounPattern(SourceSpan optSpan,
            String varName,
            AtomicExpr noun)
If 'varName' would shadow a non-shadowable, throw a (XXX to be defined) exception instead.

If the FinalPattern would not be well-formed, throw a (XXX to be defined) exception instead.

Method Detail

ensureWellFormed

void ensureWellFormed(EExpr guardExpr)

getNoun

public NounExpr getNoun()
Enabled:


optName

public String optName()
Enabled: A Definer will never return null for this. It is named 'optName' because it is polymorphic with IgnorePattern

Specified by:
optName in class Pattern

guardExpr

abstract EExpr guardExpr()

matchBind

public boolean matchBind(ConstList args,
                         Object specimen,
                         FlexList bindings)
Enabled:

Specified by:
matchBind in interface MatchMaker
Specified by:
matchBind in class ParseNode

subPrintOn

public void subPrintOn(TextWriter out,
                       int priority)
                throws IOException
Enabled:

Specified by:
subPrintOn in class ParseNode
IOException


comments?