Ejemplo n.º 1
0
BuiltInOperator::BuiltInOperator(EOperator a_eOperator)
    : NamedElement(OperatorName(a_eOperator))
    , m_eOperator(a_eOperator)
    , m_eType(OperatorType(a_eOperator))
{
    m_uiOperandCount = (m_eType == e_OperatorType_Binary) ? 2 : (m_eType == e_OperatorType_Ternary) ? 3 : 1; 
}
Ejemplo n.º 2
0
void
DataTranslationsWindow::_SetupViews()
{
	fConfigView = NULL;
	// This is NULL until a translator is
	// selected from the listview

	// Window box
	BView* mainView = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
	mainView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(mainView);

	// Add the translators list view
	fTranslatorListView = new TranslatorListView(BRect(0, 0, 1, 1), "TransList",
		B_SINGLE_SELECTION_LIST);
	fTranslatorListView->SetSelectionMessage(new BMessage(kMsgSelectedTranslator));

	BScrollView *scrollView = new BScrollView("scroll_trans", fTranslatorListView,
    		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS,
    		false, true, B_FANCY_BORDER);

	// Box around the config and info panels
	fRightBox = new BBox("Right_Side");

	// Add the translator icon view
	fIconView = new IconView(BRect(0, 0, 31, 31), "Icon",
		B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS);

	// Add the translator info button
	BButton *button = new BButton("STD", "Info" B_UTF8_ELLIPSIS,
		new BMessage(kMsgTranslatorInfo), B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);

	// Add the translator name view
	fTranslatorNameView = new BStringView("TranName", "None");

	// Populate the translators list view
	_PopulateListView();

	// Build the layout
	BALMLayout *layout = new BALMLayout();
	mainView->SetLayout(layout);

	XTab *x1 = layout->AddXTab();
	XTab *x2 = layout->AddXTab();
	XTab *x3 = layout->AddXTab();
	YTab *y1 = layout->AddYTab();

	Area *leftArea = layout->AddArea(layout->Left(), layout->Top(),
		x1, layout->Bottom(), scrollView);
	leftArea->SetLeftInset(10);
	leftArea->SetTopInset(10);
	leftArea->SetBottomInset(10);

	Area *rightArea = layout->AddArea(x1, layout->Top(), layout->Right(), y1, fRightBox);
	rightArea->SetLeftInset(10);
	rightArea->SetTopInset(10);
	rightArea->SetRightInset(10);
	rightArea->SetBottomInset(10);

	Area *iconArea = layout->AddArea(x1, y1, x2, layout->Bottom(), fIconView);
	iconArea->SetLeftInset(10);
	iconArea->SetBottomInset(10);

	Area *infoButtonArea = layout->AddArea(x3, y1, layout->Right(), layout->Bottom(), button);
	infoButtonArea->SetRightInset(10);
	infoButtonArea->SetBottomInset(10);

	layout->AddConstraint(3.0, x1, -1.0, layout->Right(), OperatorType(EQ), 0.0);

	fTranslatorListView->MakeFocus();
	fTranslatorListView->Select(0);
}
Ejemplo n.º 3
0
Archivo: parse.c Proyecto: PoCTo/yamsh
void ParseMorpheme(char* S, ParseStates* state, Tree** T){
    static char* redirop=NULL;
    redirop=myrealloc(redirop,3*sizeof(char));
    Tree* newT=NULL;
    switch (*state){
        case CMD:{
            switch (ParseGetTokenClass(S)){
                case TEXT:
                    StringPut(&((*T)->cmd),S);
                    (*T)->type=LINK_COMMAND;
                    *state=ARGS;
                    break;
                case SUBSHELL_BEGIN:
                    newT=TreeInit();
                    newT->type=LINK_SUBSHELL;
                    newT->left=(*T);
                    newT->parent=(*T)->parent;
                    (*T)->parent=newT;
                    if (newT->parent!=NULL){
                        if (newT->parent->left==(*T)) newT->parent->left=newT;
                        if (newT->parent->right==(*T)) newT->parent->right=newT;
                    }
                    *state=CMD;
                    break;
                case SUBSHELL_END:
                    while((*T)!=NULL &&((*T)->type!=LINK_SUBSHELL)) *T=(*T)->parent;
                    if (*T==NULL) *state=PARSEERROR;
                    else *state=AFTERSUBSHELL;
                    break;
                default:
                    *state=PARSEERROR;
                    break;
            }
            break;
        }
        case ARGS:{
            switch (ParseGetTokenClass(S)){
                case TEXT:
                    ListAdd(&((*T)->args),S);
                    *state=ARGS;
                    break;
                case REDIRECT:
                    strcpy(redirop,S);
                    *state=REDIR;
                    break;
                case OPER:
                    newT=TreeInit();
                    newT->type=OperatorType(S);
                    if (newT->type==LINK_AND || newT->type==LINK_OR){
                        while ((*T)->parent->type!=LINK_SUBSHELL) (*T)=(*T)->parent;
                    }
                    if (newT->type==LINK_BACKGROUND || newT->type==LINK_SEMICOLON){
                        while ((*T)->parent->type!=LINK_SUBSHELL
                                && (*T)->parent->type!=LINK_AND
                                && (*T)->parent->type!=LINK_OR) (*T)=(*T)->parent;
                    }
                    if (newT->type==LINK_BACKGROUND || newT->type==LINK_SEMICOLON){
                        while ((*T)->parent->type!=LINK_SUBSHELL
                                && (*T)->parent->type!=LINK_AND
                                && (*T)->parent->type!=LINK_OR) (*T)=(*T)->parent;
                    }
                    newT->parent=(*T)->parent;
                    if (newT->parent!=NULL) {
                        if (newT->parent->left==(*T)) newT->parent->left=newT;
                        if (newT->parent->right==(*T)) newT->parent->right=newT;
                    }
                    (*T)->parent=newT;
                    newT->left=(*T);
                    newT->right=TreeInit();
                    newT->right->parent=newT;
                    *T=newT->right;
                    *state=CMD;
                    break;
                case SUBSHELL_END:
                    while((*T)!=NULL &&((*T)->type!=LINK_SUBSHELL)) *T=(*T)->parent;
                    if (*T==NULL) *state=PARSEERROR;
                    else *state=AFTERSUBSHELL;
                    break;
                default:
                    *state=PARSEERROR;
            }
            break;
        }
        case REDIR:{
            switch (ParseGetTokenClass(S)){
                case TEXT:
                    if (!strcmp(redirop,">")) StringPut(&((*T)->out),S);
                    if (!strcmp(redirop,">>")) StringPut(&((*T)->append),S);
                    if (!strcmp(redirop,"<")) StringPut(&((*T)->in),S);
                    *state=ARGS;
                    break;
                default:
                    *state=PARSEERROR;
            }
            break;
        }
        case AFTERSUBSHELL:{
            switch (ParseGetTokenClass(S)){
                case OPER:
                    newT=TreeInit();
                    newT->type=OperatorType(S);
                    if (newT->type==LINK_AND || newT->type==LINK_OR){
                        while ((*T)->parent->type!=LINK_SUBSHELL) (*T)=(*T)->parent;
                    }
                    if (newT->type==LINK_BACKGROUND || newT->type==LINK_SEMICOLON){
                        while ((*T)->parent->type!=LINK_SUBSHELL
                                && (*T)->parent->type!=LINK_AND
                                && (*T)->parent->type!=LINK_OR) (*T)=(*T)->parent;
                    }
                    if (newT->type==LINK_BACKGROUND || newT->type==LINK_SEMICOLON){
                        while ((*T)->parent->type!=LINK_SUBSHELL
                                && (*T)->parent->type!=LINK_AND
                                && (*T)->parent->type!=LINK_OR) (*T)=(*T)->parent;
                    }
                    newT->parent=(*T)->parent;
                    if (newT->parent!=NULL) {
                        if (newT->parent->left==(*T)) newT->parent->left=newT;
                        if (newT->parent->right==(*T)) newT->parent->right=newT;
                    }
                    (*T)->parent=newT;
                    newT->left=(*T);
                    newT->right=TreeInit();
                    newT->right->parent=newT;
                    *T=newT->right;
                    *state=CMD;
                    break;
                case REDIRECT:
                    *state=REDIR;
                    break;
                case SUBSHELL_END:
                    *T=(*T)->parent;
                    while((*T)!=NULL &&((*T)->type!=LINK_SUBSHELL)) *T=(*T)->parent;
                    if (*T==NULL) *state=PARSEERROR;
                    else *state=AFTERSUBSHELL;
                    break;
                default:
                    *state=PARSEERROR;
            }
            break;
        }
        default:
            *state=PARSEERROR;
    }
}