Green refactoring: Introduced CommentParser namespace, moved private functions to comments.cpp, minor coding style fixes
This commit is contained in:
parent
7f8c969886
commit
1fe45d659a
9 changed files with 239 additions and 300 deletions
475
src/comment.cpp
475
src/comment.cpp
|
|
@ -1,291 +1,244 @@
|
||||||
#include "comment.h"
|
#include "comment.h"
|
||||||
|
#include "expression.h"
|
||||||
|
|
||||||
/*
|
#include <string>
|
||||||
Insert Parameters in AST of given scad file
|
#include <vector>
|
||||||
in form of annotations
|
|
||||||
*/
|
|
||||||
void addParameter(const char *fulltext, class FileModule *root_module){
|
|
||||||
|
|
||||||
//Getting list of all group names in the file
|
|
||||||
GroupList groupList = collectGroups(std::string(fulltext));
|
|
||||||
|
|
||||||
for (AssignmentList::iterator it = root_module->scope.assignments.begin();it != root_module->scope.assignments.end();it++) {
|
struct GroupInfo {
|
||||||
|
std::string commentString;
|
||||||
|
int lineNo;
|
||||||
|
};
|
||||||
|
|
||||||
//get loaction of assignment node
|
typedef std::vector <GroupInfo> GroupList;
|
||||||
const Location locate=(*it).location();
|
|
||||||
int loc =locate.firstLine();
|
|
||||||
if(!it->expr.get()->isLiteral()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// makeing list to add annotations
|
|
||||||
AnnotationList *annotationList = new AnnotationList();
|
|
||||||
AssignmentList *assignmentList;
|
|
||||||
|
|
||||||
//extracting the parameter
|
|
||||||
string name = getParameter(std::string(fulltext),loc);
|
|
||||||
//getting the node for parameter annnotataion
|
|
||||||
assignmentList=parser(name.c_str());
|
|
||||||
if(assignmentList==NULL){
|
|
||||||
assignmentList=new AssignmentList();
|
|
||||||
Expression *expr;
|
|
||||||
expr=new Literal(ValuePtr(std::string("")));
|
|
||||||
Assignment *assignment;
|
|
||||||
assignment=new Assignment("", shared_ptr<Expression>(expr));
|
|
||||||
assignmentList->push_back(*assignment);
|
|
||||||
}
|
|
||||||
const Annotation *Parameter;
|
|
||||||
Parameter=Annotation::create("Parameter",*assignmentList);
|
|
||||||
|
|
||||||
// adding parameter to the list
|
|
||||||
annotationList->push_back(*Parameter);
|
/*!
|
||||||
|
gives the string parameter for given
|
||||||
|
Assignment
|
||||||
//extracting the description
|
|
||||||
name = getDescription(std::string(fulltext),loc-1);
|
|
||||||
if(name!= ""){
|
|
||||||
|
|
||||||
//creating node for description
|
|
||||||
assignmentList=new AssignmentList();
|
|
||||||
Expression *expr;
|
|
||||||
|
|
||||||
expr=new Literal(ValuePtr(std::string(name.c_str())));
|
|
||||||
|
|
||||||
Assignment *assignment;
|
|
||||||
|
|
||||||
assignment=new Assignment("", shared_ptr<Expression>(expr));
|
|
||||||
assignmentList->push_back(*assignment);
|
|
||||||
|
|
||||||
const Annotation * Description;
|
|
||||||
Description=Annotation::create("Description", *assignmentList);
|
|
||||||
annotationList->push_back(*Description);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for the group to which the given assignment belong
|
|
||||||
int i=0;
|
|
||||||
for( ;i<groupList.size() && groupList[i].lineNo<loc;i++){
|
|
||||||
}
|
|
||||||
i--;
|
|
||||||
|
|
||||||
if(i>=0){
|
|
||||||
//creating node for description
|
|
||||||
assignmentList=new AssignmentList();
|
|
||||||
Expression *expr;
|
|
||||||
|
|
||||||
expr=new Literal(ValuePtr(groupList[i].commentString));
|
|
||||||
|
|
||||||
Assignment *assignment;
|
|
||||||
|
|
||||||
assignment=new Assignment("", shared_ptr<Expression>(expr));
|
|
||||||
assignmentList->push_back(*assignment);
|
|
||||||
|
|
||||||
const Annotation * Description;
|
|
||||||
Description=Annotation::create("Group", *assignmentList);
|
|
||||||
annotationList->push_back(*Description);
|
|
||||||
}
|
|
||||||
|
|
||||||
(*it).add_annotations(annotationList);
|
Finds the given line in the given source code text, and
|
||||||
|
extracts the comment (excluding the "//" prefix)
|
||||||
}
|
*/
|
||||||
}
|
static std::string getParameter(std::string fulltext, int line)
|
||||||
|
{
|
||||||
/*
|
if (line < 1) return "";
|
||||||
gives the string parameter for given
|
|
||||||
Assignment
|
|
||||||
*/
|
|
||||||
string getParameter(string fulltext, int loc){
|
|
||||||
|
|
||||||
unsigned int start = 0;
|
|
||||||
if( loc<1){
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
for(; start<fulltext.length() ; start++){
|
|
||||||
|
|
||||||
if(fulltext[start]=='\n')
|
|
||||||
loc--;
|
|
||||||
|
|
||||||
if(loc<=1)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int end=start+1;
|
|
||||||
while(fulltext[end]!='\n'){
|
|
||||||
end++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
string comment = fulltext.substr(start,end-start);
|
|
||||||
|
|
||||||
unsigned int startText=0;
|
// Locate line
|
||||||
int noOfSemicolon=0;
|
unsigned int start = 0;
|
||||||
bool isComment=true;
|
for (; start<fulltext.length() ; start++) {
|
||||||
for(;startText<comment.length()-1;startText++){
|
if (fulltext[start] == '\n') line--;
|
||||||
|
if (line <= 1) break;
|
||||||
if(comment[startText]=='\"'){
|
}
|
||||||
isComment=!isComment;
|
|
||||||
}
|
int end = start + 1;
|
||||||
if( comment[startText]== '/' && comment[startText+1]=='/' && isComment){
|
while (fulltext[end] != '\n') end++;
|
||||||
break;
|
|
||||||
}
|
std::string comment = fulltext.substr(start, end - start);
|
||||||
if(comment[startText]== ';' && isComment && noOfSemicolon>0){
|
|
||||||
|
// Locate comment
|
||||||
return "";
|
unsigned int startText = 0;
|
||||||
}
|
int noOfSemicolon = 0;
|
||||||
if(comment[startText]== ';' && isComment){
|
bool isComment = true;
|
||||||
|
for (;startText < comment.length() - 1 ; startText++) {
|
||||||
noOfSemicolon++;
|
if (comment[startText] == '"') isComment = !isComment;
|
||||||
}
|
if (isComment) {
|
||||||
|
if (comment.compare(startText, 2, "//") == 0) break;
|
||||||
|
if (comment[startText] == ';' && noOfSemicolon > 0) return "";
|
||||||
|
if (comment[startText] == ';') noOfSemicolon++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startText + 2 > comment.length()) return "";
|
||||||
if(startText+2>comment.length()){
|
|
||||||
return "";
|
return comment.substr(startText + 2);
|
||||||
}
|
|
||||||
return comment.substr(startText+2);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Gives the string of Description for given
|
Gives the string of Description for given
|
||||||
Assignment
|
Assignment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
string getDescription(string fulltext, int loc){
|
static std::string getDescription(std::string fulltext, int loc)
|
||||||
|
{
|
||||||
unsigned int start = 0;
|
if (loc < 1) return "";
|
||||||
if( loc<1){
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
for(; start<fulltext.length() ; start++){
|
|
||||||
|
|
||||||
if(loc<=1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if(fulltext[start]=='\n')
|
|
||||||
loc--;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//not a valid description
|
unsigned int start = 0;
|
||||||
if(fulltext[start] != '/' || fulltext[start+1] != '/'){
|
for (; start<fulltext.length() ; start++) {
|
||||||
return "";
|
if (loc <= 1) break;
|
||||||
}
|
if (fulltext[start] == '\n') loc--;
|
||||||
|
}
|
||||||
|
|
||||||
|
// not a valid description
|
||||||
|
if (fulltext.compare(start, 2, "//") != 0) return "";
|
||||||
|
|
||||||
//Jump over the two forward slashes
|
// Jump over the two forward slashes
|
||||||
start=start+2;
|
start = start+2;
|
||||||
|
|
||||||
//Jump over all the spaces
|
//Jump over all the spaces
|
||||||
while(fulltext[start]==' ' || fulltext[start]=='\t'){
|
while (fulltext[start] == ' ' || fulltext[start] == '\t') start++;
|
||||||
start++;
|
std::string retString = "";
|
||||||
}
|
|
||||||
string retString = "";
|
|
||||||
|
|
||||||
//go till the end of the line
|
// go till the end of the line
|
||||||
while(fulltext[start]!='\n'){
|
while (fulltext[start] != '\n') {
|
||||||
|
// replace // with space
|
||||||
//replace // with space
|
if (fulltext.compare(start, 2, "//") == 0) {
|
||||||
if(fulltext[start] == '/' && fulltext[start+1] == '/'){
|
retString += " ";
|
||||||
|
start++;
|
||||||
retString += " ";
|
} else {
|
||||||
start++;
|
retString += fulltext[start];
|
||||||
}else{
|
|
||||||
|
|
||||||
retString += fulltext[start];
|
|
||||||
}
|
|
||||||
|
|
||||||
start++;
|
|
||||||
}
|
}
|
||||||
return retString;
|
start++;
|
||||||
|
}
|
||||||
|
return retString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This function collect the list of groups of Parameter decsibred in
|
This function collect the list of groups of Parameter decsibred in
|
||||||
scad file
|
scad file
|
||||||
*/
|
*/
|
||||||
GroupList collectGroups(string fulltext){
|
static GroupList collectGroups(std::string fulltext)
|
||||||
|
{
|
||||||
|
GroupList groupList; //container of all group names
|
||||||
|
int lineNo = 1; // tracks line number
|
||||||
|
bool isComment = true; //check if its string or comment
|
||||||
|
|
||||||
GroupList groupList; //container of all group names
|
//iterate through whole scad file
|
||||||
int lineNo=1; // tracks line number
|
for (unsigned int i=0; i<fulltext.length(); i++) {
|
||||||
bool isComment=true; //check if its string or comment
|
//increase line number
|
||||||
|
if (fulltext[i] == '\n') {
|
||||||
//iterate through whole scad file
|
lineNo++;
|
||||||
for(unsigned int i=0; i<fulltext.length(); i++){
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//increase line number
|
//start or end of string negate the checkpoint
|
||||||
if(fulltext[i]=='\n'){
|
if (fulltext[i] == '"') {
|
||||||
lineNo++;
|
isComment = !isComment;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fulltext.compare(i, 2, "//") == 0) {
|
||||||
|
i++;
|
||||||
|
while (fulltext[i] != '\n') i++;
|
||||||
|
lineNo++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//start of multi line comment if check is true
|
||||||
|
if (isComment && fulltext.compare(i, 2, "/*") == 0) {
|
||||||
|
//store comment
|
||||||
|
std::string comment;
|
||||||
|
i += 2;
|
||||||
|
// till */ every character is comment
|
||||||
|
while (fulltext.compare(i, 2, "*/") != 0) {
|
||||||
|
comment += fulltext[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//store info related to group
|
||||||
|
GroupInfo groupInfo;
|
||||||
|
std::string finalGroupName; //Final group name
|
||||||
|
std::string groupName; //group name
|
||||||
|
bool isGroupName = false;
|
||||||
|
for (unsigned int it = 0; it < comment.length();it++) {
|
||||||
|
|
||||||
|
//Start of Group Name
|
||||||
|
if (comment[it] == '[') {
|
||||||
|
isGroupName = true;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//start or end of string negate the checkpoint
|
|
||||||
if(fulltext[i]=='\"'){
|
|
||||||
isComment=!isComment;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fulltext[i]=='/' && fulltext[i+1]=='/'){
|
|
||||||
i++;
|
|
||||||
while(fulltext[i]!='\n'){
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
lineNo++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//start of multi line comment if check is true
|
|
||||||
if(fulltext[i]=='/' && fulltext[i+1]=='*' && isComment){
|
|
||||||
|
|
||||||
//store comment
|
|
||||||
string comment;
|
|
||||||
i=i+2;
|
|
||||||
|
|
||||||
// till */ every character is comment
|
|
||||||
while(fulltext[i]!='*' && fulltext[i+1]!='/'){
|
|
||||||
comment+=fulltext[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
//store info related to group
|
|
||||||
GroupInfo groupInfo;
|
|
||||||
string finalGroupName; //Final group name
|
|
||||||
string groupName; //group name
|
|
||||||
bool isGroupName=false;
|
|
||||||
for(unsigned int it=0; it<comment.length();it++){
|
|
||||||
|
|
||||||
//Start of Group Name
|
|
||||||
if(comment[it]=='[' ){
|
|
||||||
isGroupName=true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//End of Group Name
|
//End of Group Name
|
||||||
if(comment[it]==']' ){
|
if (comment[it] == ']') {
|
||||||
isGroupName=false;
|
isGroupName = false;
|
||||||
|
|
||||||
//Setting of group name
|
//Setting of group name
|
||||||
if(!finalGroupName.empty()){
|
if (!finalGroupName.empty()) {
|
||||||
finalGroupName=finalGroupName+"-"+groupName;
|
finalGroupName = finalGroupName + "-" + groupName;
|
||||||
}else{
|
} else {
|
||||||
finalGroupName=finalGroupName+groupName;
|
finalGroupName = finalGroupName + groupName;
|
||||||
}
|
}
|
||||||
groupName.clear();
|
groupName.clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
//collect characters if it belong to group name
|
|
||||||
if(isGroupName){
|
|
||||||
groupName+=comment[it];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
groupInfo.commentString=finalGroupName;
|
|
||||||
groupInfo.lineNo=lineNo;
|
|
||||||
groupList.push_back(groupInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//collect characters if it belong to group name
|
||||||
|
if (isGroupName) {
|
||||||
|
groupName += comment[it];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
groupInfo.commentString = finalGroupName;
|
||||||
|
groupInfo.lineNo = lineNo;
|
||||||
|
groupList.push_back(groupInfo);
|
||||||
}
|
}
|
||||||
return groupList;
|
}
|
||||||
|
return groupList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Insert Parameters in AST of given scad file
|
||||||
|
form of annotations
|
||||||
|
*/
|
||||||
|
void CommentParser::addParameter(const char *fulltext, FileModule *root_module)
|
||||||
|
{
|
||||||
|
// Getting list of all group names in the file
|
||||||
|
GroupList groupList = collectGroups(std::string(fulltext));
|
||||||
|
|
||||||
|
for (auto &assignment : root_module->scope.assignments) {
|
||||||
|
if (!assignment.expr.get()->isLiteral()) continue; // Only consider literals
|
||||||
|
|
||||||
|
// get location of assignment node
|
||||||
|
int firstLine = assignment.location().firstLine();
|
||||||
|
|
||||||
|
// making list to add annotations
|
||||||
|
AnnotationList *annotationList = new AnnotationList();
|
||||||
|
|
||||||
|
// extracting the parameter
|
||||||
|
std::string name = getParameter(std::string(fulltext), firstLine);
|
||||||
|
// getting the node for parameter annnotataion
|
||||||
|
AssignmentList *assignmentList = CommentParser::parser(name.c_str());
|
||||||
|
if (assignmentList == NULL) {
|
||||||
|
assignmentList = new AssignmentList();
|
||||||
|
Expression *expr = new Literal(ValuePtr(std::string("")));
|
||||||
|
Assignment *assignment = new Assignment("", shared_ptr<Expression>(expr));
|
||||||
|
assignmentList->push_back(*assignment);
|
||||||
|
}
|
||||||
|
const Annotation *parameter = Annotation::create("Parameter",*assignmentList);
|
||||||
|
|
||||||
|
// adding parameter to the list
|
||||||
|
annotationList->push_back(*parameter);
|
||||||
|
|
||||||
|
|
||||||
|
//extracting the description
|
||||||
|
name = getDescription(std::string(fulltext), firstLine-1);
|
||||||
|
if (name != "") {
|
||||||
|
//creating node for description
|
||||||
|
assignmentList = new AssignmentList();
|
||||||
|
Expression *expr = new Literal(ValuePtr(std::string(name.c_str())));
|
||||||
|
|
||||||
|
Assignment *assignment = new Assignment("", shared_ptr<Expression>(expr));
|
||||||
|
assignmentList->push_back(*assignment);
|
||||||
|
|
||||||
|
const Annotation *description = Annotation::create("Description", *assignmentList);
|
||||||
|
annotationList->push_back(*description);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for the group to which the given assignment belong
|
||||||
|
int i=0;
|
||||||
|
for (;i<groupList.size() && groupList[i].lineNo<firstLine;i++);
|
||||||
|
i--;
|
||||||
|
|
||||||
|
if (i >= 0) {
|
||||||
|
//creating node for description
|
||||||
|
assignmentList = new AssignmentList();
|
||||||
|
Expression *expr = new Literal(ValuePtr(groupList[i].commentString));
|
||||||
|
|
||||||
|
Assignment *assignment = new Assignment("", shared_ptr<Expression>(expr));
|
||||||
|
assignmentList->push_back(*assignment);
|
||||||
|
|
||||||
|
const Annotation * description = Annotation::create("Group", *assignmentList);
|
||||||
|
annotationList->push_back(*description);
|
||||||
|
}
|
||||||
|
assignment.add_annotations(annotationList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,14 @@
|
||||||
#ifndef COMMENT_H
|
#ifndef COMMENT_H
|
||||||
#define COMMENT_H
|
#define COMMENT_H
|
||||||
|
|
||||||
#include "expression.h"
|
|
||||||
#include"Assignment.h"
|
|
||||||
#include "FileModule.h"
|
#include "FileModule.h"
|
||||||
#include <string>
|
#include "Assignment.h"
|
||||||
#include<vector>
|
|
||||||
|
|
||||||
using namespace std;
|
namespace CommentParser {
|
||||||
|
|
||||||
extern AssignmentList * parser(const char *text);
|
AssignmentList *parser(const char *text);
|
||||||
|
void addParameter(const char *fulltext, FileModule *root_module);
|
||||||
|
|
||||||
struct GroupInfo{
|
}
|
||||||
string commentString;
|
|
||||||
int lineNo;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef vector <GroupInfo> GroupList;
|
|
||||||
|
|
||||||
GroupList collectGroups(string fulltext);
|
|
||||||
string getParameter(string fulltext, int loc);
|
|
||||||
string getDescription(string fulltext, int loc);
|
|
||||||
void addParameter(const char *fulltext, class FileModule *root_module);
|
|
||||||
|
|
||||||
#endif // COMMENT_H
|
#endif // COMMENT_H
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
%{
|
%{
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include<string.h>
|
#include <string.h>
|
||||||
using namespace std;
|
|
||||||
#include "Assignment.h"
|
#include "Assignment.h"
|
||||||
#include "expression.h"
|
#include "expression.h"
|
||||||
#include "printutils.h"
|
#include "printutils.h"
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
#include "comment.h"
|
||||||
void yyerror(char *);
|
void yyerror(char *);
|
||||||
int yylex(void);
|
int yylex(void);
|
||||||
AssignmentList *argument;
|
AssignmentList *argument;
|
||||||
|
|
@ -117,7 +117,7 @@ word:
|
||||||
}
|
}
|
||||||
| word NUM
|
| word NUM
|
||||||
{
|
{
|
||||||
string a;
|
std::string a;
|
||||||
a=$1;
|
a=$1;
|
||||||
a+=" ";
|
a+=" ";
|
||||||
double dbl=$2;
|
double dbl=$2;
|
||||||
|
|
@ -131,14 +131,14 @@ word:
|
||||||
double dbl=$1;
|
double dbl=$1;
|
||||||
std::ostringstream strs;
|
std::ostringstream strs;
|
||||||
strs<<dbl;
|
strs<<dbl;
|
||||||
string a=" ";
|
std::string a=" ";
|
||||||
a+=$2;
|
a+=$2;
|
||||||
a=strs.str()+a;
|
a=strs.str()+a;
|
||||||
$$=strdup(a.c_str());
|
$$=strdup(a.c_str());
|
||||||
}
|
}
|
||||||
| word WORD
|
| word WORD
|
||||||
{
|
{
|
||||||
string a;
|
std::string a;
|
||||||
a=$1;
|
a=$1;
|
||||||
a+=" ";
|
a+=" ";
|
||||||
a+=$2;
|
a+=$2;
|
||||||
|
|
@ -151,11 +151,10 @@ void yyerror(char *msg) {
|
||||||
argument=NULL;
|
argument=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssignmentList * parser(const char *text) {
|
AssignmentList *CommentParser::parser(const char *text)
|
||||||
|
{
|
||||||
yy_scan_string(text);
|
yy_scan_string(text);
|
||||||
int parserretval = yyparse();
|
int parserretval = yyparse();
|
||||||
if (parserretval != 0) return NULL;
|
if (parserretval != 0) return NULL;
|
||||||
return argument;
|
return argument;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1728,7 +1728,7 @@ void MainWindow::compileTopLevelDocument()
|
||||||
if (Feature::ExperimentalCustomizer.is_enabled()) {
|
if (Feature::ExperimentalCustomizer.is_enabled()) {
|
||||||
if (this->root_module!=NULL) {
|
if (this->root_module!=NULL) {
|
||||||
//add parameters as annotation in AST
|
//add parameters as annotation in AST
|
||||||
addParameter(fulltext.c_str(),this->root_module);
|
CommentParser::addParameter(fulltext.c_str(),this->root_module);
|
||||||
}
|
}
|
||||||
this->parameterWidget->setParameters(this->root_module);
|
this->parameterWidget->setParameters(this->root_module);
|
||||||
this->parameterWidget->applyParameters(this->root_module);
|
this->parameterWidget->applyParameters(this->root_module);
|
||||||
|
|
|
||||||
|
|
@ -404,7 +404,7 @@ int cmdline(const char *deps_output_file, const std::string &filename, Camera &c
|
||||||
|
|
||||||
if (Feature::ExperimentalCustomizer.is_enabled()) {
|
if (Feature::ExperimentalCustomizer.is_enabled()) {
|
||||||
// add parameter to AST
|
// add parameter to AST
|
||||||
addParameter(text.c_str(), root_module);
|
CommentParser::addParameter(text.c_str(), root_module);
|
||||||
if (!parameterFile.empty() && !setName.empty()) {
|
if (!parameterFile.empty() && !setName.empty()) {
|
||||||
ParameterSet param;
|
ParameterSet param;
|
||||||
param.getParameterSet(parameterFile);
|
param.getParameterSet(parameterFile);
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
||||||
#include "modcontext.h"
|
#include "modcontext.h"
|
||||||
extern AssignmentList * parser(const char *text);
|
#include "comment.h"
|
||||||
|
|
||||||
ParameterWidget::ParameterWidget(QWidget *parent) : QWidget(parent)
|
ParameterWidget::ParameterWidget(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
|
|
@ -304,7 +304,7 @@ void ParameterWidget::applyParameterSet(string setName){
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
AssignmentList *assignmentList;
|
AssignmentList *assignmentList;
|
||||||
assignmentList=parser(v.second.data().c_str());
|
assignmentList=CommentParser::parser(v.second.data().c_str());
|
||||||
if(assignmentList==NULL){
|
if(assignmentList==NULL){
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "parameterset.h"
|
#include "parameterset.h"
|
||||||
#include "modcontext.h"
|
#include "modcontext.h"
|
||||||
|
#include "comment.h"
|
||||||
|
|
||||||
ParameterSet::ParameterSet()
|
ParameterSet::ParameterSet()
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +71,7 @@ void ParameterSet::applyParameterSet(FileModule *fileModule,string setName)
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
AssignmentList *assignmentList;
|
AssignmentList *assignmentList;
|
||||||
assignmentList=parser(v.second.data().c_str());
|
assignmentList=CommentParser::parser(v.second.data().c_str());
|
||||||
if(assignmentList==NULL){
|
if(assignmentList==NULL){
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
#ifndef PARAMETERSET_H
|
#ifndef PARAMETERSET_H
|
||||||
#define PARAMETERSET_H
|
#define PARAMETERSET_H
|
||||||
|
|
||||||
#include"expression.h"
|
#include "expression.h"
|
||||||
#include "FileModule.h"
|
#include "FileModule.h"
|
||||||
#include "modcontext.h"
|
#include "modcontext.h"
|
||||||
extern AssignmentList * parser(const char *text);
|
|
||||||
|
|
||||||
#include<map>
|
#include<map>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#include "parametertext.h"
|
#include "parametertext.h"
|
||||||
|
|
||||||
#include "modcontext.h"
|
#include "modcontext.h"
|
||||||
extern AssignmentList * parser(const char *text);
|
#include "comment.h"
|
||||||
|
|
||||||
ParameterText::ParameterText(ParameterObject *parameterobject, bool showDescription)
|
ParameterText::ParameterText(ParameterObject *parameterobject, bool showDescription)
|
||||||
{
|
{
|
||||||
|
|
@ -26,7 +25,7 @@ void ParameterText::onChanged(QString)
|
||||||
else{
|
else{
|
||||||
ModuleContext ctx;
|
ModuleContext ctx;
|
||||||
AssignmentList *assignmentList;
|
AssignmentList *assignmentList;
|
||||||
assignmentList=parser(lineEdit->text().toStdString().c_str());
|
assignmentList=CommentParser::parser(lineEdit->text().toStdString().c_str());
|
||||||
if(assignmentList==NULL){
|
if(assignmentList==NULL){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue