How to define a boolean in Flex

…衆ロ難τιáo~ 提交于 2019-12-12 03:36:39

问题


I am building a compiler for a toy Java language (Decaf) and I am having trouble with defining a bool. When I try to analyze a boolean, it always returns false, whether or not I wrote false.

Flex code:

true|false  {
            yylval.boolConstant = yytext;
            return T_BoolConstant;
        }

Input code:

bool x = true;
bool y = false;

Output:

true         T_BoolConstant (value = false)
false        T_BoolConstant (value = false)

I tried searching on SO but this was the closest I could get to a proper answer:

Simulating Booleans in Bison with C

Thank you!

EDIT: The output is coded in a separate c file that prints the string found in the test code, what kind of value it is (in this case it is a boolean or BooleanConstant) and then the value of the token that was saved. Sorry for any confusion.


回答1:


I believe you need to convert the strings "true" and "false" into the boolean constants true and false. Otherwise you're just storing strings.

true {
    yylval.boolConstant = true;
    return T_BoolConstant;
}

false {
    yylval.boolConstant = false;
    return T_BoolConstant;
}

Here is a similar question with a different approach.




回答2:


**Uson for the web services**   
 private var IsCity:Boolean = true;
    private function button_click():void {
        //dg.dataProvider= countrys
        webService.getCountries.send(1,0);

    }

    private function getCountries_result(evt:ResultEvent):void {

        //var countryList:ArrayCollection=evt.result as ArrayCollection;
                    dg.dataProvider=evt.result as ArrayCollection;

    }
    private function dgridclick():void{
    IsCity=false;
                webService.getSubLocationsByMultipleParameters.send(1,2,true,dg.selectedItem.id,dg.selectedItem.targetCode)

    }
    private function getState_result(evt:ResultEvent):void{

        if(IsCity)
            dg2.dataProvider=evt.result as ArrayCollection;
        else
            dg1.dataProvider=evt.result as ArrayCollection;

    }

    private function d1click():void{
      IsCity=true
    webService.getSubLocationsByMultipleParameters.send(1[4,3],false,dg1.selectedItem.id,dg1.selectedItem.targetCode);
    }


来源:https://stackoverflow.com/questions/35143357/how-to-define-a-boolean-in-flex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!