openscad/src/scadlexer.cpp

64 lines
1.5 KiB
C++

#include <boost/algorithm/string.hpp>
#include "scadlexer.h"
ScadLexer::ScadLexer(QObject *parent) : QsciLexerCPP(parent)
{
// -> Style: Keyword (lexer.l)
keywordSet[0] =
"if else let for module function true false undef "
"include use";
// -> Style: KeywordSet2 (func.cc)
keywordSet[1] =
"abs sign rands min max sin cos asin acos tan atan atan2 "
"round ceil floor pow sqrt exp len log ln str chr concat "
"lookup search version version_num norm cross parent_module "
"dxf_dim dxf_cross";
// -> used in comments only like /*! \cube */
keywordSet[2] =
"struct union enum fn var def typedef file namespace package "
"interface param see return class brief";
// -> Style: GlobalClass
keywordSet[3] =
"cube sphere cylinder polyhedron square circle polygon text "
"minkowski hull resize child echo union difference "
"intersection linear_extrude rotate_extrude import group "
"projection render surface scale rotate mirror translate "
"multmatrix color offset ";
}
ScadLexer::~ScadLexer()
{
}
const char *ScadLexer::language() const
{
return "SCAD";
}
void ScadLexer::setKeywords(int set, const std::string& keywords)
{
if ((set < 1) || (set > 4)) {
return;
}
std::string trimmedKeywords(keywords);
boost::algorithm::trim(trimmedKeywords);
if (trimmedKeywords.empty()) {
return;
}
keywordSet[set - 1] = trimmedKeywords;
}
const char *ScadLexer::keywords(int set) const
{
if ((set < 1) || (set > 4)) {
return 0;
}
return keywordSet[set - 1].c_str();
}