Article View: comp.lang.modula2
Article #1354M2 Grammers for Lex and Yacc
From: Cobus Debeer
Date: Mon, 29 Oct 1990 05:07
Date: Mon, 29 Oct 1990 05:07
100 lines
3540 bytes
3540 bytes
The foolowing is a grammer exactly as I received it on the BBS. I had to
split it into four files to make it fit the bbs limits.
This message contains the source of a lex'er and parser for
Modula-2; files m2c.l and m2c.y respectively. The makefile
will generate a syntax checker for Modula 2 in m2c. There is
also a manual page in m2c.1.
Cornelia Boldyreff
p.s. I would be interested to hear what other grammars you receive;
we may be interested in the C/C++ grammars.
====m2cm.l (=lex input)
%%
[ \n\t] { ; } /* ignore white space: blanks, newlines & tabs */
AND { return( AND );}
ARRAY { return( ARRAY );}
BEGIN { return( _BEGIN );}
BY { return( BY );}
CASE { return( CASE );}
CONST { return( CONST );}
DEFINITION { return( DEFINITION );}
DIV { return( DIV );}
DO { return( DO );}
ELSE { return( ELSE );}
ELSIF { return( ELSIF );}
END { return( END );}
EXIT { return( EXIT );}
EXPORT { return( EXPORT );}
FOR { return( FOR );}
FROM { return( FROM );}
IF { return( IF );}
IMPLEMENTATION { return( IMPLEMENTATION );}
IMPORT { return( IMPORT );}
IN { return( IN );}
LOOP { return( LOOP );}
MODULE { return( MODULE );}
MOD { return( MOD );}
NOT { return( NOT );}
OF { return( OF );}
OR { return( OR );}
POINTER { return( POINTER );}
PROCEDURE { return( PROCEDURE );}
QUALIFIED { return( QUALIFIED );}
RECORD { return( RECORD );}
REPEAT { return( REPEAT );}
RETURN { return( RETURN );}
SET { return( SET );}
THEN { return( THEN );}
TO { return( TO );}
TYPE { return( TYPE );}
UNTIL { return( UNTIL );}
VAR { return( VAR );}
WHILE { return( WHILE );}
WITH { return( WITH );}
\& { return( ampersand );}
\* { return( asterisk );}
\:\= { return( colon_equals );}
: { return( colon );}
\, { return( comma );}
\.\. { return( dot_dot );}
\. { return( dot );}
= { return( equals_sign );}
\>= { return( greater_than_or_equals );}
\> { return( greater_than );}
\{ { return( left_curley_bracket );}
\( { return( left_parenthesis );}
\[ { return( left_square_bracket );}
\<= { return( less_than_or_equals );}
\<\> { return( not_equals );}
\< { return( less_than );}
\- { return( minus );}
\+ { return( plus );}
# { return( pound_sign );}
\} { return( right_curley_bracket );}
\) { return( right_parenthesis );}
\] { return( right_square_bracket );}
; { return( semicolon );}
\/ { return( slash );}
\^ { return( up_arrow );}
\| { return( vertical_bar );}
"\""[^"\""\n]*"\"" { return( string );}
\'[^\'\n]*\' { return( string );}
[A-Za-z][0-9A-Za-z]* { return( identifier ); }
[0-9][0-9]*\.[0-9]*E[\+\-][0-9]+ { return( real );}
[0-9][0-9]*\.[0-9]* { return( real );}
[0-7]+B { return( integer );}
[0-7]+C { return( integer );}
[0-9][0-9A-F]*H { return( integer );}
[0-9]+ { return( integer );}
Grammer continues ...
Regards
- Cobus
--
uucp: uunet!m2xenix!puddle!5!491!1.0!Cobus.Debeer
Internet: Cobus.Debeer@p0.f1.n491.z5.fidonet.org
Technical Details
Message-ID:
<290.2730462B@puddle.fidonet.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!puddle!p0.f1.n491.z5.fidonet.org!Cobus.DebeerShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tektronix!nosun!qiclab!m2xenix!puddle!p0.f1.n491.z5.fidonet.org!Cobus.Debeer From: Cobus.Debeer@p0.f1.n491.z5.fidonet.org (Cobus Debeer) Newsgroups: comp.lang.modula2 Subject: M2 Grammers for Lex and Yacc Message-ID: <290.2730462B@puddle.fidonet.org> Date: 29 Oct 90 05:07:22 GMT Sender: ufgate@puddle.fidonet.org (newsout1.26) Organization: FidoNet node 5:491/1.0 - Golden City Opus, Johannesburg RSA Lines: 100