SCOUG Logo


Next Meeting: Sat, TBD
Meeting Directions


Be a Member
Join SCOUG

Navigation:


Help with Searching

20 Most Recent Documents
Search Archives
Index by date, title, author, category.


Features:

Mr. Know-It-All
Ink
Download!










SCOUG:

Home

Email Lists

SIGs (Internet, General Interest, Programming, Network, more..)

Online Chats

Business

Past Presentations

Credits

Submissions

Contact SCOUG

Copyright SCOUG



warp expowest
Pictures from Sept. 1999

The views expressed in articles on this site are those of their authors.

warptech
SCOUG was there!


Copyright 1998-2024, Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.

The Southern California OS/2 User Group
USA

SCOUG-Programming Mailing List Archives

Return to [ 29 | April | 2005 ]

>> Next Message >>


Date: Fri, 29 Apr 2005 17:06:35 PDT7
From: "Gregory W. Smith" <gsmith@well.com >
Reply-To: scoug-programming@scoug.com
To: scoug-programming@scoug.com
Subject: SCOUG-Programming: Progress--Step 3

Content Type: text/plain

It has been a while, but back on April 15
Lynn Maxson wrote:
> Greg,
>
> Apparently we need to develop a deeper understanding of
> LEX and YACC, how they work together, their inputs, and
> their outputs. We don't need no stinking referee, because we
> can determine for ourselves what we can and cannot do. As
> these two, as well as we two (or three if you include Peter)
> keep coming up in the discussion, maybe it's important that we
> clear the air. I certainly don't want to make untrue assertions
> as I'm sure neither do you. The proof of the pudding....

OK, we might start with Thomas Nieman's online document:

http://epaperpress.com/lexandyacc/index.html

The document is also available as a PDF file:

http://epaperpress.com/lexandyacc/download/lexyacc.pdf

Now if we go to sourceforge and get pl1gcc.0.0.10.zip we can
get a few documents and programs to look at. In the zip
archive we find the lex and yacc input files pl1-scanner.l
and pl1-parser.y. According to the diagam in Nieman's tutorial,
we use these as inputs to generate our language front end as
follows:

pl1-parser.y
|
V
+------------+ pl1-scanner.l
| YACC | |
+------------+ V
| | y.tab.h +--------------+
| +-------------------->| LEX |
V +--------------+
y.tab.c |
| V
| lex.yy.c
| |
+---------------+ +-----------+
| |
V V
+-------------------+
| Gnu C Compiler |
+-------------------+
|
V
+---------------+
PL/1 Program ----->| PL1-1.exe |-----> Compiled Output
+---------------+

Note that GCC has several stages in the compilation. Lex and YACC
are only the first step in the compilation since the "Compiled Output"
from the first stage is RTL (Register Transfer Language). RTL is
code for an abstract machine that is passed on to the next stage
that analyzes and optimizes the intermediate code. The next pass
takes the optimized intermediate code and generates the actual
x86 code. Finally, the linker puts the code into an executable
format with links to the appropriate libraries needed to make the
final binary.

In essence, the C code generated by LEX scans the input PL/I
into tokens and associated data. So we have 3.1416E0 returns
the token type NUMFLOAT with the associated data "3.1416E0". Note
that LEX does NOT parse the token data to a native C data type:

SP [ ]
TAB [\t]
HEX [\000\013\014\017]
WSP ({SP}|{TAB}|{HEX})*
ANY [^ \t\n\r;\"']+
NBR [0-9][0-9_]*
LET [A-Z]+
CHR [_$#@]+
VARNAME ({CHR}|{LET})({CHR}|{LET}|[0-9])*
NBREE (D|E|F|S|Q)[+\-]?{NBR}

{NBR}{NBREE} |
{NBR}"."{NBR}{NBREE} |
"."{NBR}{NBREE} |
{NBR}"."{NBREE} |
"."{NBR} |
{NBR}"." |
{NBR}"."{NBR} dupyy(NUMFLOAT); /* consider to let pl1.y handle these combinations */

The C code generated by YACC generates the compiled output by
applying the BNF style grammar to the tokens returned by the
LEX generated code. So if PL/I cannot be processed by LEX and
YACC, then this must be an admission that the PL/I language
cannot be specified by a BNF grammar.

Now the gotcha for OS/2 users: pl1-1.exe is meant to integrate
with the 4.x versions of the Gnu Compiler Collection. The current
GCC in EMX is 3.2.1 and the most recent GCC on my FreeBSD and
Linux boxes is 3.3. So, who wants to try and get the cutting
edge 4.x versions of GCC up on OS/2?

--
Gregory W. Smith (WD9GAY) gsmith@well.com

=====================================================

To unsubscribe from this list, send an email message
to "steward@scoug.com". In the body of the message,
put the command "unsubscribe scoug-programming".

For problems, contact the list owner at
"postmaster@scoug.com".

=====================================================


>> Next Message >>

Return to [ 29 | April | 2005 ]



The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA

Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS RESERVED.

SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group. OS/2, Workplace Shell, and IBM are registered trademarks of International Business Machines Corporation. All other trademarks remain the property of their respective owners.