This is for a syntax checker. (yeah i know using regex is not ideal)
The reader already detected that it is on the int
|float
|char
|bool
part and now it needs to check if the declaration and initialization is syntactically valid. The ff are sample of the str that my condition should pass.
a;
a, _b2;
a, _b2=0;
a=1, _b2=0;
a=1+1, _b2=a+1, c, d=555, e;
a=2.33;
a='a', b=3;
a="asb", b='3';
a=true, b=false, c="false";
Should not pass:
a= , b2 = 1;
a = ;
a = '23;
a = 50, b = a+1
a = a.23;
The condition ive made is not matching when it sees =
Could you please help me correcting my condition
^(\s*[A-z_][A-z0-9]*\s*(=\s*0-9|=\s*"[^]*"|=\s*'[^]*')?\s*,)*\s*[A-z_][A-z0-9]*\s*(=\s*0-9|=\s*"[^]*"|=\s*'[^]*')?\s*;
UPDATE: considered floating values
UPDATE: made it a general regex that is applicable to int, float, char and boolean values