PDA

View Full Version : [Tool/Web/Other] Online missing brackets finder


RedJohn
11/07/2012, 09:00 PM
PAWN: Online missing brackets counter

Hey guys. I made a little PHP website where you paste your pawno script and it shows you number of opened and number of closed brackets.

It's easy to use. This is just simple website and I will update it and fix known bugs in future.


Website link: Website is down. Upgrading with new features

FireCat
11/07/2012, 09:01 PM
Nice! :0

RedJohn
11/07/2012, 09:02 PM
Nice! :0

Thanks bro!

Kirollos
11/07/2012, 09:51 PM
nice script :) +Rep

Y_Less
11/07/2012, 10:33 PM
Bug:


//{
'{'
}

JoBullet
12/07/2012, 01:23 AM
Bug:


//{
'{'
}


It sure cannot catch everything, otherwise he might need parser, preprocessor and lexer(i.e. full compiler). Just think of macros, strings, comments, character literals etc. There are limitless ways of misrepresenting braces this online web service does not catch because it's simple and stupid.

Y_Less
12/07/2012, 03:41 AM
Yes, but if it is trying to find missing brackets and can't even tell this then frankly it its basically useless.

RedJohn
12/07/2012, 07:34 AM
Yes, but if it is trying to find missing brackets and can't even tell this then frankly it its basically useless.

I will create software so you'll check for any bugs. BTW i saw one's using perl and other shit! Bitch please, can anybody create simple software without any shit?!

Y_Less
12/07/2012, 07:40 AM
I actually have no clue what you are trying to say with that post! Do you mean you want me to beta-test a new version? And what's wrong with perl? It is designed specifically for text parsing operations, which is exactly what you are trying to do. Perl regular expressions are the best around - basically everything else's are generally described as "perl compatible" (PHP, PCRE).

RedJohn
12/07/2012, 07:45 AM
I don't want to argue with beta tester. I'm little guys. You know better!

Y_Less
12/07/2012, 07:51 AM
I don't mind debates, I'm just not sure what your previous point was. Just because I'm a beta tester doesn't actually mean I know everything.

FireCat
12/07/2012, 11:35 AM
I don't want to argue with beta tester. I'm little guys. You know better!

You know, Y_Less has a point.
If you're releasing something to help the community, you should accept criticism.
And your code ain't just to test small things, probably people will use it for big codes, because thats where normaly it happens, in big ass codes...

next-studio|TheKiller
12/07/2012, 11:41 AM
RedJohn, you're most likely just counting the "{" and "}" with the explodes.

example:

$open = count(explode("{", $_POST['code']));
$close = count(exokide("}", $_POST['code']));
echo '<script type="text/javascript">alert("you have '.$open.' open brackets\nAnd '.$close.' closed brackets");</script>';


ps: scripted on the quick reply box e.e

Lorenzo*
12/07/2012, 11:43 AM
looks okay, but from the comments it seems to be scrappy, 4/10

RedJohn
12/07/2012, 12:41 PM
Thank you all guys. I understand that people will use it for big codes so i create a software. But if i use big codes i need to wait for a while! (Depending on your machine). So i will release also my software and you guys test both and tell me result. And i @FireCat i accept any, any type of criticism but i don't want to argue with somebody who can "crush" me with knowledge of those thing.

Y_Less
12/07/2012, 01:23 PM
i don't want to argue with somebody who can "crush" me with knowledge of those thing.

I didn't think we were arguing - I simply pointed out some bugs so you could improve the tool. An online one is helpful, but I also think you might be better off writing it in JavaScript rather than perl, so the checks are done client-side. This should make the whole process quite a bit faster.

As I say, if you disagree with my views (some of them are just my personal opinion) then say so! Don't hide your thoughts just because I have more posts than you!

RedJohn
12/07/2012, 01:36 PM
No, no, no, no. I WANT you to see my posts and tools and i want you to point me to some bugs, I just respect somebody who knows better that me!

Y_Less
12/07/2012, 03:47 PM
Yes, that's fine and I will. I think there is a misunderstanding going on here. I am happy to point out problems, and will continue to do so if you want. But you should not worry about replying!

RedJohn
12/07/2012, 05:14 PM
Thank you my friend!

StatusRed
13/07/2012, 08:36 AM
On a serious note. This will be quite useful when you make it redisplay the code and highlight any brackets that are not closed. In a large piece of code just saying how many unclosed brackets there are isn't that helpful, when trying to debug.

ipsBruno
15/07/2012, 07:05 AM
Good work, but:

Online missing brackets COUNTER :|

I Will create an brackets finder online as soon as possible: p

Faster tip:

<script>

function checkIt(str) {

var arrBracket = new Array();
var arrLineBkt = new Array();

var opens = 0;
var lines = 0;

for(i = 0, j = str.length; i != j; i++) {

if(str[i] == '{') {
arrBracket[opens] = 1;
arrLineBkt[opens] = lines;
opens++;
}

if(str[i] == '}') {
arrBracket[opens] = 0;
if(!opens) {
return alert("ERROR EXCESSIVE '}' on line " + lines);
}
opens--;

}

if(str[i] == '\n') lines ++;
}

if(!opens) {
alert('NO ERROR !!1 YOU IS BEST !!');
}


for(i = 0; i != opens; i++) {
if(arrBracket[i]) {
alert("ERROR '{' on line" + arrLineBkt[i]);
}
}

return true;
}


</script>

<textarea id=area>Put code here</textarea>
<input type=button onClick=checkIt(document.getElementById('area').va lue) value=Hey />


(It works .. Now, only filter string brackets or comments !! :mrgreen: )

--

With Highlight:

<script>

function checkIt(str) {

var arrBracket = new Array();
var arrLineBkt = new Array();

var opens = 0;
var lines = 0;

for(i = 0, j = str.length; i != j; i++) {

if(str[i] == '{') {
arrBracket[opens] = 1;
arrLineBkt[opens] = lines;
opens++;
}

if(str[i] == '}') {
arrBracket[opens] = 0;
if(!opens) {
return alert("ERROR EXCESSIVE '}' on line " + lines);
}
opens--;

}

if(str[i] == '\n') lines ++;
}

if(!opens) {
alert('NO ERROR !!1 YOU IS BEST !!');
}


lines = 0;
brackets = 0;



for(i = 0; i != opens; i++) {
if(arrBracket[i]) {
brackets = arrLineBkt[i];
alert("ERROR { on line" + brackets );
}
}


for(i = 0, j = str.length; i != j; i++) {

if(str[i] == '\n') {
lines ++;
document.write("<br/>");
}
else {

if(lines == brackets) {
document.write("<font color=red>"+str[i]+"</font>");
}
else {
document.write(str[i]);
}
}

}
return true;
}


</script>

<textarea id=area>Put code here</textarea>
<input type=button onClick=checkIt(document.getElementById('area').va lue) value=Hey />



How test? Save in "seila.html" and open with your navigator :)

RedJohn
17/09/2012, 07:57 AM
Good work, but:

Online missing brackets COUNTER :|

I Will create an brackets finder online as soon as possible: p

Faster tip:

<script>

function checkIt(str) {

var arrBracket = new Array();
var arrLineBkt = new Array();

var opens = 0;
var lines = 0;

for(i = 0, j = str.length; i != j; i++) {

if(str[i] == '{') {
arrBracket[opens] = 1;
arrLineBkt[opens] = lines;
opens++;
}

if(str[i] == '}') {
arrBracket[opens] = 0;
if(!opens) {
return alert("ERROR EXCESSIVE '}' on line " + lines);
}
opens--;

}

if(str[i] == '\n') lines ++;
}

if(!opens) {
alert('NO ERROR !!1 YOU IS BEST !!');
}


for(i = 0; i != opens; i++) {
if(arrBracket[i]) {
alert("ERROR '{' on line" + arrLineBkt[i]);
}
}

return true;
}


</script>

<textarea id=area>Put code here</textarea>
<input type=button onClick=checkIt(document.getElementById('area').va lue) value=Hey />


(It works .. Now, only filter string brackets or comments !! :mrgreen: )

--

With Highlight:

<script>

function checkIt(str) {

var arrBracket = new Array();
var arrLineBkt = new Array();

var opens = 0;
var lines = 0;

for(i = 0, j = str.length; i != j; i++) {

if(str[i] == '{') {
arrBracket[opens] = 1;
arrLineBkt[opens] = lines;
opens++;
}

if(str[i] == '}') {
arrBracket[opens] = 0;
if(!opens) {
return alert("ERROR EXCESSIVE '}' on line " + lines);
}
opens--;

}

if(str[i] == '\n') lines ++;
}

if(!opens) {
alert('NO ERROR !!1 YOU IS BEST !!');
}


lines = 0;
brackets = 0;



for(i = 0; i != opens; i++) {
if(arrBracket[i]) {
brackets = arrLineBkt[i];
alert("ERROR { on line" + brackets );
}
}


for(i = 0, j = str.length; i != j; i++) {

if(str[i] == '\n') {
lines ++;
document.write("<br/>");
}
else {

if(lines == brackets) {
document.write("<font color=red>"+str[i]+"</font>");
}
else {
document.write(str[i]);
}
}

}
return true;
}


</script>

<textarea id=area>Put code here</textarea>
<input type=button onClick=checkIt(document.getElementById('area').va lue) value=Hey />



How test? Save in "seila.html" and open with your navigator :)

Nice. I've tested it and it's working but please add line numbers at textarea so I know on which line is error!

Y_Less
17/09/2012, 09:53 AM
Doesn't work properly, try this:


{
//}

RedJohn
17/09/2012, 05:28 PM
Doesn't work properly, try this:


{
//}


Y_Less, do you know what is the best way to create bug-free braces finder? No matter if it's online-based or software.

Y_Less
17/09/2012, 05:33 PM
You will need a "tokeniser", a program that reads through the script character by character to determine if something should be used or not. For this you just need a way to work out if you are in a string, a comment, or nothing.

However, the REAL trick is "#if", and for that you will need MUCH more processing, in fact you will need half the PAWN compiler to resolve that. You can't solve this without quite a lot of processing:


#define A 24
#define B b + 6
#if A > 28
{
#endif
}


Are you missing a brace? Parsing language syntax is not a simple problem - I can recommend some books on compiler design if you'd like. To do this you actually need to make the first few stages of a compiler.

RedJohn
17/09/2012, 06:40 PM
Thank you for "clearing" this thing to me.

I can see that this isn't easy to do (even if I thought it's a piece of cake).

I think this isn't for me, I'm going back to my AutoCAD and SolidWorks.