Beispiel #1
0
/* iterate until we detect an input token that identifies the user's language
 * @return the detected language
 */
static Language detect_user_language(char *tok)
{
  Language result = LanguageCount;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%s",tok);
  TraceFunctionParamListEnd();

  {
    Language candidate;
    for (candidate = 0; candidate<LanguageCount; ++candidate)
    {
      TraceValue("%u",candidate);TraceEOL();
      if (GetUniqIndex(GlobalTokenCount,GlobalTokenString[candidate],tok)==BeginProblem)
      {
        result = candidate;
        break;
      }
    }
  }

  TraceFunctionExit(__func__);
  TraceFunctionResult("%u",result);
  TraceFunctionResultEnd();
  return result;
}
Beispiel #2
0
Flags ParseColour(char *tok, boolean colour_is_mandatory)
{
    Colour const colour = GetUniqIndex(nr_colours,ColourTab,tok);
    if (colour==nr_colours)
    {
        if (colour_is_mandatory)
            output_plaintext_input_error_message(NoColourSpec,0);
        return 0;
    }
    else if (colour>nr_colours)
    {
        output_plaintext_input_error_message(PieSpecNotUniq,0);
        return 0;
    }
    else if (colour==colour_neutral)
        return NeutralMask;
    else
        return BIT(colour);
}
Beispiel #3
0
char *ParsePieceFlags(Flags *flags)
{
    char *tok;

    while (true)
    {
        tok = ReadNextTokStr();

        {
            piece_flag_type const ps = GetUniqIndex(nr_piece_flags-nr_sides,PieSpTab,tok);
            if (ps==nr_piece_flags-nr_sides)
                break;
            else if (ps>nr_piece_flags-nr_sides)
                output_plaintext_input_error_message(PieSpecNotUniq,0);
            else
                SETFLAG(*flags,ps+nr_sides);
        }
    }

    return tok;
}
Beispiel #4
0
/* Parse starter of stipulation
 * @param tok input token
 * @return starter; no_side if starter couldn't be parsed
 */
static Side ParseStructuredStip_starter(char *tok)
{
  Side result = no_side;
  Side ps;

  TraceFunctionEntry(__func__);
  TraceFunctionParam("%s",tok);
  TraceFunctionParamListEnd();

  /* We don't make any unsafe assumptions here; PieSpec enumerators
   * are initialised in terms of nr_sides */
  ps = GetUniqIndex(nr_sides,ColourTab,tok);
  if (ps>nr_sides)
    output_plaintext_input_error_message(PieSpecNotUniq,0);
  else if (ps<nr_sides)
    result = ps;

  TraceFunctionExit(__func__);
  TraceEnumerator(Side,result,"");
  TraceFunctionResultEnd();
  return result;
}
Beispiel #5
0
void input_plaintext_iterate_problems(slice_index si)
{
  boolean halt = false;

  do
  {
    pipe_solve_delegate(si);

    switch (GetUniqIndex(ProblemTokenCount,ProblemTokenTab,TokenLine))
    {
      case ProblemTokenCount:
      case EndProblem:
        halt = true;
        break;

      case NextProblem:
        break;

      default:
        output_plaintext_input_error_message(ComNotUniq,0);
        break;
    }
  } while (!halt);
}