예제 #1
0
 public ForeignAction(int offset, int argumentCount, ForeignContextRef context = null)
 {
     this.ContextRef    = context ?? ForeignContextRef.None;
     this.Offset        = offset;
     this.ArgumentCount = argumentCount;
     this.Joint         = new Joint();
 }
예제 #2
0
        public bool Match(ForeignContextRef reference)
        {
            if (reference == null)
            {
                throw new ArgumentNullException("reference");
            }

            return(reference.UniqueName == this.UniqueName);
        }
예제 #3
0
 public Matcher(
     string pattern,
     SymbolBase outcome            = null,
     ForeignContextRef context     = null,
     Condition nextCondition       = null,
     Disambiguation disambiguation = Disambiguation.Undefined)
     : this(
         ScanPattern.CreateRegular(pattern),
         outcome,
         context,
         nextCondition,
         disambiguation)
 {
 }
        public ForeignContext Resolve(ForeignContextRef reference)
        {
            var matching = this.Where(c => c.Match(reference));
            int count    = matching.Count();

            switch (count)
            {
            case 0: return(null);

            case 1: return(matching.First());

            default:
                throw new InvalidOperationException(
                          "Ambiguous context reference: " + reference.UniqueName);
            }
        }
예제 #5
0
        public Matcher(
            ScanPattern pattern,
            SymbolBase outcome            = null,
            ForeignContextRef context     = null,
            Condition nextCondition       = null,
            Disambiguation disambiguation = Disambiguation.Undefined)
        {
            this.Pattern       = pattern;
            this.Outcome       = outcome;
            this.Context       = context;
            this.NextCondition = nextCondition;

            if (disambiguation == Disambiguation.Undefined)
            {
                this.Disambiguation = pattern.DefaultDisambiguation;
            }
            else
            {
                this.Disambiguation = disambiguation;
            }

            this.Joint = new Joint();
        }
예제 #6
0
 public ForeignAction(int argumentCount, ForeignContextRef context = null)
     : this(0, argumentCount, context)
 {
 }
예제 #7
0
 public bool Equals(ForeignContextRef other)
 {
     return(other != null && UniqueName == other.UniqueName);
 }
 public bool Provides(ForeignContextRef reference)
 {
     return(this.Any(c => c.Match(reference)));
 }