Correct Identation/Contex can solve the too many compiler error messages problem when a closing brac

T

Thomas Schodt

Skybuck said:
Lol, how often do you program ? Once every 3 years ? ;)

Two points come to mind.

For coders who produce a lot of code, indentation and putting in closing
braces is something you hardly think about - it just happens.

Ed did not explicitly say he never missed a close brace. As I read it he
is saying that, for years, he has not had a problem with the compiler
barfing as a result.
 
O

Oliver Wong

Skybuck Flying said:
Who cares about context free grammer. I dont care about.

I am all for context.

Runtime information is a sort of context.

Since you don't seem to know what context-free grammars are, I suggest
you read up on them before further embarassing yourself on topics of
programming language design. You can start with Wikipedia:
http://en.wikipedia.org/wiki/Context-free_grammar As an aside, there's no
shame in not knowing what CFGs are (most programmers don't), but it is very
discouraging that, rather than showing a curiosity or desire to learn more
about them, you dismiss them entirely.

If you are not willing to learn, it will be much more difficult (perhaps
impossible) for you to become as knowlegeable as someone who IS willing to
learn.
Lol, Why should I ? Python already does it.

So in other words, what you want has already been done. It's called
Python, and you're satisfied with Python. So why don't you code in Python,
post on Python related newsgroups, and let the Delphi/C/Java people code in
whatever languages they want?
Then I guess you wont be programming in python lol ;)

(where there are no brackets in the first place lol =D)

Hilarious.

- Oliver
 
P

Patricia Shanahan

Ed Prochak wrote:
....
I don't think a valid grammer for this style can be written in a
context free grammer. In order to keep tract of the block level the
inner level must somehow know the level of the outer block. IOW the
block level is not context free. Bruce's example doesn't work for
anything beyond while loops with a single simple statement. (no sub
blocks like another WHILE or IF)

The usual solution to inability to represent a rule in a CFG is to move
it out of the grammar.

For example, whether a token has the correct form to be a Java
identifier can be represented in a CFG. Trying to include in the grammar
issues such as whether there is an in-scope declaration, and if so what
the type is, would prevent the gramme from being context free, so they
are kept out of the grammar that is used for Java parsing.

Similarly, there are ways of fitting a reflection of indentation rules
into a CFG. I've seen it done with abstract INDENT and DEDENT tokens
that increase and reduce the indentation, and take the place of braces
in the CFG. A tokenizer, counting leading whitespace, can determine the
placement of INDENT and DEDENT tokens.

Patricia
 
B

Bruce Roberts

<tab>?

Lookup the basic concept of indentation lol, shouldn't be to hard to
grasp.

So you can't provide a definition. Makes it difficult to take your
suggestion seriously. (Well I can't say that I ever did, anyway.)
Here is what you do:

Turn the text into lines.

And that is done how?
Then process each line.

And that is done how?

Most compilers leave the processing of text to the lexical analyser,
allowing the parser to concentrate on the token stream. The lexer needs to
know how to recognize tokens, and you need to provide a non-ambiguous
definition of indentation it your scheme is to have a chance.
And ofcourse tab characters would be mandatory.

So those of us that like using spaces are out of luck. What about the
thousands, nay millions of lines of existing source that uses spaces and/or
tabs?
See above.

Yup, really makes sense. Lets break millions of lines of code to satisfy
someone who can't seem to match their begins and ends.
 
S

Skybuck Flying

Bruce Roberts said:
grasp.

So you can't provide a definition. Makes it difficult to take your
suggestion seriously. (Well I can't say that I ever did, anyway.)

You making this much harder than necessary. The Dictionary is your friend :)
And that is done how?

Figure it out yourself please or have other people figure it out for you. I
am not your daddy holding your hand lol.
And that is done how?

Most compilers leave the processing of text to the lexical analyser,
allowing the parser to concentrate on the token stream. The lexer needs to
know how to recognize tokens, and you need to provide a non-ambiguous
definition of indentation it your scheme is to have a chance.

The compilers might have to work in a different way to be able to handle
"context" ;)

So dont try to force a different concept into it ;)
So those of us that like using spaces are out of luck. What about the
thousands, nay millions of lines of existing source that uses spaces and/or
tabs?

Easily converted.
Yup, really makes sense. Lets break millions of lines of code to satisfy
someone who can't seem to match their begins and ends.

You are exaggarting ;)

Frankly I am getting quite tired of your posts asking obvious questions and
assuming something can't be done etc etc etc, so I don't feel any need to
spent more energy on your posts than absolutely necessary =D

Bye,
Skybuck.
 
S

Skybuck Flying

Oliver Wong said:
Since you don't seem to know what context-free grammars are, I suggest
you read up on them before further embarassing yourself on topics of
programming language design. You can start with Wikipedia:
http://en.wikipedia.org/wiki/Context-free_grammar As an aside, there's no
shame in not knowing what CFGs are (most programmers don't), but it is very
discouraging that, rather than showing a curiosity or desire to learn more
about them, you dismiss them entirely.

I like to keep things practical and simple... the above website is the
opposite of that, and useless for anybody wanting to learn.

Bye,
Skybuck.
 
S

Skybuck Flying

Thomas Schodt said:
Two points come to mind.

For coders who produce a lot of code, indentation and putting in closing
braces is something you hardly think about - it just happens.

Ed did not explicitly say he never missed a close brace. As I read it he
is saying that, for years, he has not had a problem with the compiler
barfing as a result.

Exactly. I have been coding for 10 years and I dont have a problem with it.

Though sometimes with C when I am newby to some complex C code it could be
nasty, if it's just a simple missing brace somewhere.

So I also have two points:

1. For newby programmers it's always a problem.

2. For advanced programmers new to somebody elses code contain missing
braces it's also a problem.

SWWwwwing =D

Bye,
Skybuck =D
 
B

Bruce Roberts

You making this much harder than necessary. The Dictionary is your friend
:)

I take it that you cannot provide a definition of your own concept. ISTM
that this means that you have given no real thought to your own suggestion.
Figure it out yourself please or have other people figure it out for you. I
am not your daddy holding your hand lol.

You are the one suggesting the change, not me. If you cannot describe the
basic parameters of your own suggestion its obvious that the suggestion
lacks any real merit.
The compilers might have to work in a different way to be able to handle
"context" ;)

So dont try to force a different concept into it ;)

I see, change a compiler to add a questionable "enhancement". <heavy
sarcasm> Makes sense to me.
Easily converted.

Really? You can't even define what it is to be converted to. How easy is
that?
You are exaggarting ;)

You think so? I guess you haven't stopped to consider just how many lines of
Delphi source are kicking around. I know that just on my development machine
I have over 1m lines.
Frankly I am getting quite tired of your posts asking obvious questions and
assuming something can't be done etc etc etc, so I don't feel any need to
spent more energy on your posts than absolutely necessary =D

Since you don't spend any time or energy thinking about your own ideas, I'm
not at all surprised that you have to chicken out when pressed for details.

Its not my job to read your mind. If you want a suggestion to go anywhere
you are going to have to explain it and defend it with reasonable detail.
Suggesting that a dictionary will provide an explanation doesn't cut it. I
want to know what you mean by a term, not what some natural language experts
think might be meant.
 
O

Oliver Wong

Skybuck Flying said:
Exactly. I have been coding for 10 years and I dont have a problem with
it.

You've been coding for 10 years professionally (i.e. getting paid to do
so), or just 10 years of what you would like to call "coding"? That last
statement may seem a bit antagonistic, but you seem to have a habit of
mis-using words.
Though sometimes with C when I am newby to some complex C code it could be
nasty, if it's just a simple missing brace somewhere.

[snip]

2. For advanced programmers new to somebody elses code contain missing
braces it's also a problem.

I don't know where you've been coding, but I have never been in a
situation where my boss hands me a piece of code written by somebody else
with a missing bracket and told me to work with it. In a business setting,
all the programs I've been handed have, at the very least, compiled.

- Oliver
 
R

robertwessel2

Skybuck said:
The original request was about preventing compilers from generating enormous
ammounts of error messages as soon as a bracket is missing. For example by
programming mistake or accident.

The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.

So at the end of a statement block there should be a closing bracket... if
there isn't the compiler could simply stop right there instead of looking at
the rest of the code etc and generating invalid/crazy/stupid error messages
;)


Rather than trying to change billions of lines of existing code, and
everyone else's behavior for no good reason, if this bothers you so
much consider using one of the Lint packages that will warn you about
odd indentation patterns. If you get a bad block pairing, there will
likely be an "illogical indentation" message.

OTOH, the odds of your code making through Lint seem rather small.
 
S

Skybuck Flying

Stop trolling dude.

1. First of all indentation is nothing new so it's not my concept in the
first place.
2. Spaces can easily be converted to tab characters thanks to "tabout" for
textpad try it sometime ;)
3. I do not feel the need to reinvent that which already exists. If you are
really interested in this I would suggest to take a look at python or if
that is unsuited because python is an interpreter instead of a compiler...
then first see if there are other compilers exist which already do this and
are open source and then lastly if all this fails then and only then should
you start using your own brain for a change lol.. since it's not that hard
in the first place.

Let's be honest... if you can't even split a text file into seperates lines
then what can you do ?

Simply put you shouldn't be writing compilers in the first place.

Bye,
Skybuck.
 
S

Skybuck Flying

Oliver Wong said:
Skybuck Flying said:
Exactly. I have been coding for 10 years and I dont have a problem with
it.

You've been coding for 10 years professionally (i.e. getting paid to do
so), or just 10 years of what you would like to call "coding"? That last
statement may seem a bit antagonistic, but you seem to have a habit of
mis-using words.
Though sometimes with C when I am newby to some complex C code it could be
nasty, if it's just a simple missing brace somewhere.

[snip]

2. For advanced programmers new to somebody elses code contain missing
braces it's also a problem.

I don't know where you've been coding, but I have never been in a
situation where my boss hands me a piece of code written by somebody else
with a missing bracket and told me to work with it. In a business setting,
all the programs I've been handed have, at the very least, compiled.

Lol, I couldn't care a rat's ass less about this bussiness bullshit.

If you want to talk bussiness find another newsgroup.

Here we discuss programming and that is what I am here for.

I cant even count the number of times I downloaded some C source and it
didnt compile etc... and the end result is a storm of BS making my doubt
heavily if it's any use in the first place ;) =D

Nonononono that's a bad first impression dude oh no oh no oh no ohhhhh
noooo.

Bye,
Skybuck :p:p:p:p wieh.
 
S

Skybuck Flying

Rather than trying to change billions of lines of existing code, and
everyone else's behavior for no good reason, if this bothers you so
much consider using one of the Lint packages that will warn you about
odd indentation patterns. If you get a bad block pairing, there will
likely be an "illogical indentation" message.

Mhoaw... rather small improvement really. Nothing to big.
 
J

jussij

Ok I installed zeus and paste the code into it, the final result is lol:
It doesn't detect jack squat. (It simply folds everything etc lol
hahahahahaha)

If you paste the code into Zeus and fold the first opening brace it
displays this:

{ ....

Notice it does not display the expected result which is this:

{ .... }

Take a guess why?

Ok I will tell you. The "{ .." indicates a fold is missing.

So now open up the fold and try folding the next brace and see if
if folds correctly. Repeat this process a few times and with a
minimal amount of trial and error it quickly becomes clear where
the missing brace should be.

It does require a bit of user input but it certainly aint no rocket
science. Using you example it took me about 20 seconds to
find the missing brace.
You're an idiot.

Don't blame the tool if you don't know how to use it.

Jussi Jumppanen
Author: Zeus for Windows
 
S

Skybuck Flying

If you paste the code into Zeus and fold the first opening brace it
displays this:

{ ....

Notice it does not display the expected result which is this:

{ .... }

Take a guess why?

Ok I will tell you. The "{ .." indicates a fold is missing.

Ok thanks for this explanation ;)

Bye,
Skybuck =D
 
E

Ed Prochak

Skybuck said:
Ed Prochak said:
Skybuck Flying wrote:
[]
;)

The original request was about preventing compilers from generating enormous
ammounts of error messages as soon as a bracket is missing. For example by
programming mistake or accident.

What is the big deal. The compiler dumps a lot of error messages you
look at the first one or two, fixing them, and you get to the third one
which doesn't make sense, so you just save your changes and compile
again. If it was a bracket error, most of the other errors all go away.

Well what you rather have:

Storm of bull**expletive**.

Or storm of handy hints and error messages =D

Any sane person would prefer the second one ;)

But your suggestion does NOTHING to really solve the problem.
So it's simply an improvement thing I guess... though you should ask the
teacher.. maybe his students started **expletive**ing up all the code ;)

Sounds like you are the one still in school. If you want to know how
difficult it is to produce those "handy hints", try writing a compiler
with that feature. From the compiler's side it really is had to read
the mind of the programmer to figure out what was intended versus what
was programmed.
Fine, the compiler could still use the indentation to provide any possibly
hints and prevent bs-storm ;)

Repeating your suggestion does nothing to support it.
Lol, how often do you program ? Once every 3 years ? ;)

I might ask: when do you plan to start programming? 8^)
Nope problem is real look at any compiler today ;)

The problem is minor. I used to worry about such things when compiling
took a long time and result listings were on paper. Now with compile
times on the order of seconds, I fix whatever missing bracket typo I
have and recompile to find the next one. IOW, this is not a significant
problem except perhaps for inexperienced programmers and you.
Ahhhh see my second solution: automatic and mandatory indentation ;)

And how do you determine "automatically" when one block ends?
Point is you cannot.
See how the pieces of the puzzle fit together ? =D

Bye,
Skybuck.

You sure are a puzzle.
 
E

Ed Prochak

Skybuck said:
Ed Prochak said:
Skybuck Flying wrote: [snip]

Care to present a grammer for this "indented block" structure?
Code examples don't count.

I don't think a valid grammer for this style can be written in a
context free grammer. In order to keep tract of the block level the

Who cares about context free grammer. I dont care about.

The compiler writers care about it.
I am all for context.

Runtime information is a sort of context.

We are discussing COMPILE time errors. There isn't even an executable
yet, as far as this discussion goes, let alone RUNTIME context.
Lol, Why should I ? Python already does it.

So then go program in Python. C programmers have been doing fine
without this "improvement" for a long time now.
Then I guess you wont be programming in python lol ;)

I don't have problems programming in C, braces and all, thank you very
much.
If I left out a brace in C, I get compile errors. If I mis-indent a
line in python, I might not know until runtime, maybe. (I don't know
since I haven't used python.)
(where there are no brackets in the first place lol =D)

Exactly why the compiler might miss a line in the wrong block.
Bye,
Skybuck.

So far I haven't had a need to learn PYTHON. Certainly identifying
blocks by indentation is not a compelling reason for me to check it
out.

have a good day in school Skybuck. Your teachers miss you.
Ed
 
E

Ed Prochak

Patricia said:
Ed Prochak wrote:
...

The usual solution to inability to represent a rule in a CFG is to move
it out of the grammar.

For example, whether a token has the correct form to be a Java
identifier can be represented in a CFG. Trying to include in the grammar
issues such as whether there is an in-scope declaration, and if so what
the type is, would prevent the gramme from being context free, so they
are kept out of the grammar that is used for Java parsing.

Similarly, there are ways of fitting a reflection of indentation rules
into a CFG. I've seen it done with abstract INDENT and DEDENT tokens
that increase and reduce the indentation, and take the place of braces
in the CFG. A tokenizer, counting leading whitespace, can determine the
placement of INDENT and DEDENT tokens.

Patricia

But the issue is whether such indentation rules will reduce compiler
errors. I think the answer is No. Skybuck thinks yes

Adding such indentation rules to C will do little to solve Skybucks
inability to understand and use the error messages produced by his C
compiler.

The INDENT/DEDENT rules sound interesting, but I don't see how they
help the problem of errors. If the programmer happens to indent lines
of code to the wrong level, how does the INDENT/DEDENT syntax stop the
compiler from generating, as Skybuck like to say, lots of
bull<expletive> lines of errors?

Ed.
 
O

Oliver Wong

Ed Prochak said:
If the programmer happens to indent lines
of code to the wrong level, how does the INDENT/DEDENT syntax stop the
compiler from generating, as Skybuck like to say, lots of
bull<expletive> lines of errors?

I don't think the INDENT/DEDENT syntax itself with stop the compiler
from generating lots of lines of errors, the concept of INDENT/DEDENT is
orthogonal to the concept of intelligent error message supression, which is
a moderately well understood problem.

To give you an example, consider the following line:

int i = a + (b + (c + (d + e)));

Imagine that a, b, c and d are all integers, while e is something else,
such that you cannot add an integer and whatever e is together. So the
expression "d + e" results in a type error, and will yield an error message.
But that means the type of the expression "(d + e)" (which is distinct from
the expression "d + e") is also erroneous. And the type of "(c + (d + e))"
is erroneous as well, and so on.

What is usually done then is that the compiler has a dummy "error_type"
type that it uses in the type checking phase. When it sees "d + e", it'll
report the error message, but then claim that the type of the expression is
"error_type" (as opposed to say, "int"). Then, by definition, any operation
with an error_type is "legal" in the sense that it generates no errors. So
adding an int to an error_type doesn't generate an error message.

That's how the compiler is able to generate just one error message for
the case above, instead of half a dozen errors.

Handling missing block structure tokens (e.g. '{' and '}' in C-like
languages) is a bit trickier, but still doable, depending on the complexity
of the language, from a parsing point of view. I've never tried to write a C
compiler, so I don't know how hard it'd be in C, but I know that the grammar
that describes the Java language is relatively simple. For example, in Java,
when you encounter a method declaration, you'll know it's a method
declaration for sure; it cannot be confused as a cast operation or a
variable declaration or anything like that.

When the parser encounters something that it doesn't expect, it knows
something's gone wrong (it may be a missing closing bracket, or something
else). In these situations, it can just report the error of seeing something
it doesn't expect, and then stumble along until it encounters something it
recognizes, for example, a method declaration. Since method declarations
can't be nested in Java, if it sees a new method declaration, the parser can
know to close the old method declaration, and just continue parsing on from
there. The idea is to not complain or generate error messages about all
those strange tokens it saw during the "stumbling along" phase, since the
structure of the parse tree is too damaged to make any informed error
messages anyway. Once it grounds itself again, and can establish where it is
located in the parse tree, it can turn error reporting on again, and
continue on its merry way.

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top