bool Expression::is_expr_primary() const
{
  return 
     is_constant()
  || is_string_literal()
  || is_identifier();
}
 //------------------------------------------------------------------
 void code_colorer::color_code(const char_type* p)
 {
     while(*p)
     {
         unsigned len;
         if(is_block_comment(p, &len))
         {
             m_result.add(keyword_rem, p, len, true);
             p += len;
         }
         else if(is_line_comment(p, &len))
         {
             m_result.add(keyword_rem, p, len, true);
             p += len;
         }
         else if(is_string_literal(p, &len))
         {
             m_result.add(keyword_str, p, len, true);
             p += len;
         }
         else if(is_number(p, &len))
         {
             m_result.add(keyword_num, p, len, true);
             p += len;
         }
         else if(is_operator(p, &len))
         {
             m_result.add(keyword_op, p, len, true);
             p += len;
         }
         else if(is_identifier(p, &len))
         {
             const keyword* kw = 0;
             if     (is_keyword(keyword_kw1_suffix, p, len)) kw = &keyword_kw1;
             else if(is_keyword(keyword_kw2_suffix, p, len)) kw = &keyword_kw2;
             else if(is_keyword(keyword_kw3_suffix, p, len)) kw = &keyword_kw3;
             else if(is_keyword(keyword_kw4_suffix, p, len)) kw = &keyword_kw4;
             if(kw)
             {
                 m_result.add(backslash);
                 m_result.add(kw->name, kw->len);
                 m_result.add(open_brace);
             }
             m_result.add(p, len, true);
             if(kw)
             {
                 m_result.add(close_brace);
             }
             p += len;
         }
         else
         {
             m_result.add(*p++);
         }
     }
 }
Exemple #3
0
void StringsTest::testNonStringLiteral() {
	const char *nonStringLiteral = "unimportend";

	QVERIFY( !is_string_literal( nonStringLiteral ));
}
Exemple #4
0
void StringsTest::testStringLiteral() {
	const char stringLiteral[] = "unimportend";

	QVERIFY( is_string_literal( stringLiteral ));
}