c# - Antlr4 solving boolean function -


i want solve boolean functions like:

(2and2)or0

(true , false) , true etc.

i did tutorial simple calculator: http://programming-pages.com/2013/12/14/antlr-4-with-c-and-visual-studio-2012/

when try solve functions " true , false", right result out of it. project need solve functions integer numbers " 2 , 0 ". , result want have " true or false !".

so tried convert integer numbers of input boolean ( 0 = false, , everyting else true) , compare expressions && or || .

can tell me why ist not working this:

public override bool visitint(combined2parser.intcontext context) {   return bool.parse(context.int().gettext()); } 

in opinion shall convert integers found in inputstring bool, not working this.

( whole code please have on tutorial , code same )


thanks help.

my next step is, whenever parser finds letter, shall transform float variable, , replace p/t input value.

but need separation if expr number or letter.

like:

if( expr(0) != "number" && expr(1) != "number")

then ask value want use

how can code if- function?

you can't use bool.parse converting numbers boolean values. doesn't work way in c# (.net framework), bool.parse parsing string values true , false.

you can use compare integer values 0 , return accordingly like:

public override bool visitint(combined2parser.intcontext context) {   return context.int() != 0; //true other 0, false 0 } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -