Exemplo n.º 1
0
void Checker::else_check()
{
    ExtendedBoolean& at_newline(settings.ext_bool_options["else_at_newline"]);
    int depth_by_fact = lines[token->line_index].depth_by_fact;
    if(at_newline == EB_CONSISTENT)
    {
        at_newline = token->start == depth_by_fact ? EB_TRUE : EB_FALSE;
    }
    else if(at_newline == EB_TRUE && token->start != depth_by_fact)
    {
        add_result("else is not at new line");
    }
    else if(at_newline == EB_FALSE && token->start == depth_by_fact)
    {
        add_result("else is at new line");
    }
}
Exemplo n.º 2
0
	Variant JSONReader::parse_string()
	{
		if (!skip_char('"'))
			throw Exception(position(), "expected start of string");

		std::string string;

		while (!skip_char('\"'))
		{
			if (at_newline())
				throw Exception(position(), "missing string termination");

			if (skip_char('\\'))
			{
				if (skip_char('b'))
					string += '\b';
				else if (skip_char('t'))
					string += '\t';
				else if (skip_char('n'))
					string += '\n';
				else if (skip_char('f'))
					string += '\f';
				else if (skip_char('r'))
					string += '\r';
				else if (skip_char('\"'))
					string += '\"';
				else if (skip_char('/'))
					string += '/';
				else if (skip_char('\\'))
					string += '\\';
				else if (skip_char('u'))
					throw Exception(position(), "escaped code points currently not supported");
				else
					throw Exception(position(), "invalid escape char");
			}
			else
				string += next_get();
		}

		return Variant(std::move(string));
	}