473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

C++ syntax expressed in toot-toot diagrams?

In the old ages when I was taught Pascal, the manual had nice
syntax diagrams. Each grammatical structure was shown as
round boxes connected by arrows, with a model railway look,
with the boxes representing either lexical tokens or other
diagrams (i.e. terminals/nonterminals). They seemed very
intuitive because you could toot-toot one finger along the
rails in the book while moving another finger over your code.

Does anything similar exist for C++? Or am I stuck with the bnf?
(I really appreciate the hyperlinked version http://www.nongnu.org/hcb/
but it's still a mess...)

If I have to create the diagrams myself, I might as well use UML,
that being the company standard. But I'm not sure whether I
shold use state diagrams or activity diagrams or something else
- the state diagrams are conceptually close but they represent
states as boxes and transitions as arrows, which is the opposite
of what I want. Activity diagrams seem a better graphical match
but perhaps less appropriate conceptually.

Any hints?
Sep 10 '07 #1
4 2134
Ole Nielsby wrote:
In the old ages when I was taught Pascal, the manual had nice
syntax diagrams. Each grammatical structure was shown as
round boxes connected by arrows, with a model railway look,
with the boxes representing either lexical tokens or other
diagrams (i.e. terminals/nonterminals). They seemed very
intuitive because you could toot-toot one finger along the
rails in the book while moving another finger over your code.

Does anything similar exist for C++? Or am I stuck with the bnf?
(I really appreciate the hyperlinked version http://www.nongnu.org/hcb/
but it's still a mess...)

If I have to create the diagrams myself, I might as well use UML,
that being the company standard. But I'm not sure whether I
shold use state diagrams or activity diagrams or something else
- the state diagrams are conceptually close but they represent
states as boxes and transitions as arrows, which is the opposite
of what I want. Activity diagrams seem a better graphical match
but perhaps less appropriate conceptually.

Any hints?

I really doubt such a thing exists in the wild. Maybe at Dinkumware
they might have something like that...I doubt gnu would... I doubt Dink
will share but you could try.
Sep 10 '07 #2
Noah Roberts wrote:
Ole Nielsby wrote:
>In the old ages when I was taught Pascal, the manual had nice
syntax diagrams. [...] with a model railway look [...]
Does anything similar exist for C++?

I really doubt such a thing exists in the wild. Maybe at Dinkumware they
might have something like that...I doubt gnu would... I doubt Dink will
share but you could try.
Never mind, I decided to do the graphics from scratch, using an
egg-laying turtle.... I hope I can get someone to review the diagrams
when I think I'm done.
Sep 11 '07 #3
On Mon, 10 Sep 2007 15:12:15 +0200, Ole Nielsby wrote:
In the old ages when I was taught Pascal, the manual had nice
syntax diagrams. Each grammatical structure was shown as
round boxes connected by arrows, with a model railway look,
with the boxes representing either lexical tokens or other
diagrams (i.e. terminals/nonterminals). They seemed very
intuitive because you could toot-toot one finger along the
rails in the book while moving another finger over your code.

Does anything similar exist for C++? Or am I stuck with
the bnf? (I really appreciate the hyperlinked version
http://www.nongnu.org/hcb/ but it's still a mess...)
I also loved those diagrams you mentioned in some Pascal book.
Recently I found them used at http://www.json.org/ , but I still
don't know what if anything produces them.

However, I managed to create a program that converts EBNF style
grammar into Graphviz graph files that resemble loosely the
diagrams which you describe.
An example of its input and the matching product are shown
respectively here:
http://tasvideos.org/SiteTechnology/...tatementSyntax
http://bisqwit.iki.fi/kala/snap/tasvqueryflowchart.png
And the source of the converter:
http://bisqwit.iki.fi/src/bnf_to_graph.php.txt

--
Joel Yliluoma - http://bisqwit.iki.fi/
: comprehension = 1 / (2 ^ precision)
Sep 11 '07 #4
Joel Yliluoma <bi*****@iki.fiwrote:
On Mon, 10 Sep 2007 15:12:15 +0200, Ole Nielsby wrote:
>[...] syntax diagrams [...] with a model railway look

I also loved those diagrams you mentioned in some Pascal book.
Recently I found them used at http://www.json.org/ , but I still
don't know what if anything produces them.

However, I managed to create a program that converts EBNF style
grammar into Graphviz graph files [...]
I dug up the old turtle graphics concept from the Logo days and adapted
it into a thing I call tokentoot-turtletalk when I'm sober - now I can hand-
code the diagrams with relative ease. The JSON ref looks nice, I'll go for
a similar look.

(The bnf grammar for C++ is too lax, it accepts too much rubbish, I
need something tighter even if I have to produce it myself.)

In case anyone wonders what tokentoot-turtletalk looks like, here's
a sample that tries to describe a decl-specifier - it's all very
prelimiary...
the graphs look nicer than the code...

:y 70 .tokentoot .
bar
right 30
fork up 50 right 600 down 50 right 60 bar join
fork
right 60
fork
right 30
fork right 60 hit "export" right 60 down 25 left 120 down 10 join
down 50 right 60 hit "template" right 60
fork down 25 right 360 down 10 join
right 40 hit "<"
right 40
fork
up 40
right 100
box "template-parameter" right 100
fork up 35 left 100 hit "," left 100 down 35 right 10 end join
down 40 right 10
join
right 100 toot "-export" right 140 hit ">" right 40 down 200 left 510
down 10
join
down 300 right 30 bar right 10 bar
join
down 400 right 10 bar
Sep 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
24
by: Steven Bethard | last post by:
I think one of the biggest reasons we're having such problems coming to any agreement on decorator syntax is that each proposal makes a number of syntax decisions, not just one. For decorators, I...
12
by: Steven Bethard | last post by:
The poll, as stated, asked voters to vote for the syntax suggestion they liked the /most/. Some of the conclusions people are trying to draw from it are what syntaxes people liked the /least/. ...
8
by: Ike | last post by:
I am hoping someone can help me with the proper syntax for this. I have an attribute, called, say "name," such that: <set name="something">thename</set> However, the value for name, is...
8
by: cody | last post by:
Why do we always need braces around namespaces? It frightens me that even a simply class looks so much nested and complicated due to this verbose namespace syntax. It also unnecessarily...
1
by: Peter Oliphant | last post by:
I got 2005 Express to prepare for the arrival of my company's MSDN full version. Upon loading my project it was converted successfully, but did warn me modifications would have to be done for it to...
1
by: amitbadgi | last post by:
I am geting the following error while conv an asp to asp.net Exception Details: System.Runtime.InteropServices.COMException: Syntax error in query expression 'id =System.__ComObject'. Source...
1
by: amitbadgi | last post by:
HI i am getting the foll error while conv an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Syntax error in UPDATE statement. Source Error: Line...
4
by: nooneinparticular314159 | last post by:
I'm trying to understand template metaprogramming syntax. It's been years since I've touched C++, so this may actually be a C++ syntax issue (although it seems that the language has changed...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.