Ejemplo n.º 1
0
 private static void ParseDeclaration(ParseState state, QuipCompiler Compiler)
 {
     var Type = QuipType.Questioning;
     bool Repeatable = false;
     bool Restrictive = false;
     while (!state.AtEnd() && (state.Next() == '@' || state.Next() == '+' || state.Next() == '?' || state.Next() == '*'))
     {
         if (state.Next() == '+') Repeatable = true;
         if (state.Next() == '?') Restrictive = true;
         if (state.Next() == '*') Type = QuipType.NpcDirected;
         state.Advance(1);
     }
     var ID = "";
     var Name = "";
     if (!IsWhitespace(state.Next()))
         ParseToken(out ID, state);
     ParseRestOfLine(out Name, state);
     Name = Name.Trim();
     if (String.IsNullOrEmpty(Name)) throw new InvalidOperationException("Quip declared with no name");
     if (Type != QuipType.NpcDirected)
     {
         var lastChar = Name[Name.Length - 1];
         if (lastChar == '?') { Name = Name.Substring(0, Name.Length - 1); Type = QuipType.Questioning; }
         else if (lastChar == '.') { Name = Name.Substring(0, Name.Length - 1); Type = QuipType.Informative; }
         else if (lastChar == '!') { Name = Name.Substring(0, Name.Length - 1); Type = QuipType.Performative; }
         else if (lastChar == '$') { Name = Name.Substring(0, Name.Length - 1); Type = QuipType.NpcDirected; }
     }
     Compiler.BeginQuip(ID, Name, Type, Repeatable, Restrictive);
 }