Beispiel #1
0
 public SourceObject(string text, TokenRef.Type type)
 {
     OfType   = type;
     Text     = text;
     Sequence = null;
     Previous = null;
 }
Beispiel #2
0
        public static NextStateRec CreateTokenRef(string name, TokenRef.Type type, ParseResponse response)
        {
            NextStateRec nsRec;

            switch (type)
            {
            case TokenRef.Type.Null:
                throw new FormatException($"SourceObject Type {type.ToString()} is valid BUT NOT in the context as a Next State Token Ref!");

            case TokenRef.Type.Empty:
                nsRec = new NextStateRec(Type.TokenRef, TokenRef.CreateEmpty(), null, response);
                break;

            case TokenRef.Type.Identifier:
                if (!(name is null))
                {
                    throw new ArgumentNullException(nameof(name), $"NextStateRecords can not contain Identifier Tokens with predefined names -{nameof(name)} must be set to 'null', not '{name}'!");
                }

                nsRec = new NextStateRec(Type.TokenRef, TokenRef.CreateIdentifier(), response);
                break;

            case TokenRef.Type.Keyword:
                nsRec = new NextStateRec(Type.TokenRef, TokenRef.CreateKeyword(name), name, response);
                break;

            case TokenRef.Type.Operator:
                nsRec = new NextStateRec(Type.TokenRef, TokenRef.CreateOperator(name), name, response);
                break;

            case TokenRef.Type.Error:
                throw new NotImplementedException("Error types yet to be implemented!");

            default:
                throw InvalidEnumValueException.InvalidArgument(typeof(TokenRef.Type), type, nameof(name));
            }

            return(nsRec);
        }
Beispiel #3
0
 public static NextStateRec CreateTokenRef(TokenRef.Type type, ParseResponse response)
 {
     return(CreateTokenRef(null, type, response));
 }
Beispiel #4
0
 public static NextStateRec CreateTokenRef(string name, TokenRef.Type type)
 {
     return(CreateTokenRef(name, type, ParseResponse.Next));
 }
Beispiel #5
0
 private SymbolRecord CreateSymbol(string token, TokenRef.Type type)
 {
     return(new SymbolRecord(token, type));
 }
Beispiel #6
0
 public SymbolRecord(string token, TokenRef.Type type) : this()
 {
     Token = token ?? throw new ArgumentNullException(nameof(token));
     Type  = type;
 }