PDA

View Full Version : Syntax design...



audinue
11-15-2008, 09:11 AM
Mmm... anyone know what kind of diagram is this?
I saw something like this on ORACLE SQL Reference...

http://audinue.navhost.com/Draft.jpg

Maybe I can use it to design a programming language syntax.

Thanks in advance.

laserlight
11-15-2008, 09:17 AM
It is, uh, a syntax diagram. They arguably are an easier to trace alternative to EBNF, but a downside is that they are harder to translate and feed into parser generators.

brewbuck
11-15-2008, 11:18 AM
It is, uh, a syntax diagram. They arguably are an easier to trace alternative to EBNF, but a downside is that they are harder to translate and feed into parser generators.

In this case the diagram looks like it was generated by Antlr, so it probably started out in parser form in the first place.

audinue
11-16-2008, 08:08 AM
It is, uh, a syntax diagram. They arguably are an easier to trace alternative to EBNF, but a downside is that they are harder to translate and feed into parser generators.

Eww.. thanks for the answer laserlight! *_*


In this case the diagram looks like it was generated by Antlr, so it probably started out in parser form in the first place.

I drew it myself using Visio, there is a lot of mistake in it since I don't know what Syntax Diagram is.

Umm... can I add the second silly question?

We know three types of regular numbers in C...
Can you tell me what are their name please?


1. 123321, 223311, 1024, 4096
2. 0x00ff, 0x0123, 0x1212a
3. 0.1232, 123.121, 0.0001231

I know the second numbers are known as "hexadecimal numbers"...

Thank you.

CornedBee
11-16-2008, 08:11 AM
The first are integers in decimal notation.
The second are integers in hexdecimal notation.
The third are floating point numbers in point notation.

There's also integers in octal notation and floating point numbers in scientific notation.

tabstop
11-16-2008, 08:18 AM
And in C99, there's also the exciting "floating point numbers in hexadecimal scientific notation".

audinue
11-16-2008, 08:20 AM
There's also integers in octal notation and floating point numbers in scientific notation.

And in C99, there's also the exciting "floating point numbers in hexadecimal scientific notation".

Any example please?

tabstop
11-16-2008, 08:25 AM
You've never seen scientific notation before?
Anyway, octal always starts with 0, so 037 is octal.
Scientific notation is what it is: 4.75e128
And the funky hex stuff uses hex for the significand, but decimal for the exponent, so that same number would look like 0x4.cp128.

audinue
11-16-2008, 08:30 AM
Oh my god... I never saw those thing.

o_O... Incredible.

And yet another silly question...

I just curious of decimal notation...

Why we not allowed to start a number from 0?

For instance: 0000123, 00523

It will give a clear looks of constants instead of hexadecimal number.


#define ERROR_XXX 00001
#define ERROR_XXXX 00082
#define ERROR_XYZ 00103
#define ERROR_YYY 00127

tabstop
11-16-2008, 08:41 AM
Because numbers that start with zero are in octal notation.

P4R4N01D
11-17-2008, 02:45 AM
That "syntax diagram" looks like a failed Railroad Diagram. I would find EBNF easier to understand than those ovals and arrows. whats w/ those arrows anyway, they certainatly don't make it easier to follow.
Also, I didn't know that numbers that start w/ 0 are in base 8. I am suprised the 0s don't get truncated. Still, in maths (outside of C) 00001 is exactly the same as 1, becasue one has to explicitly define if the number is in a different base to 10 which is default. It works well though as it doesn't limit either number base.
So something to remember: 0x~ = hex, 0~ = octal, where ~ represents a number

laserlight
11-17-2008, 03:36 AM
That "syntax diagram" looks like a failed Railroad Diagram. I would find EBNF easier to understand than those ovals and arrows. whats w/ those arrows anyway, they certainatly don't make it easier to follow.
I believe that "syntax diagram" and "railroad diagram" are synonyms. The arrows allow the reader to distinguish between repetition and alternatives.