[comp.lang.modula2] M2 Grammers for Lex and Yacc

Cobus.Debeer@p0.f1.n491.z5.fidonet.org (Cobus Debeer) (10/29/90)

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

Ben.Stuyts@p6.f202.n281.z2.fidonet.org (Ben Stuyts) (11/03/90)

In a message of <28 Oct 90 21:07:22>, Cobus Debeer (5:491/1.0) writes:

 CD> The foolowing is a grammer exactly as I received it on the BBS.  I 

It seems that the last part of m2c.l didn't make it over here (part3/5?). 
Could you please repost it?

Thanks,
Ben


--  
uucp: uunet!m2xenix!puddle!2!281!202.6!Ben.Stuyts
Internet: Ben.Stuyts@p6.f202.n281.z2.fidonet.org

Kaare.Rasmussen@f15.n231.z2.fidonet.org (Kaare Rasmussen) (11/25/90)

Hi Cobus

 CD> The foolowing is a grammer exactly as I received it on the BBS.  I had 
 CD> to split it into four files to make it fit the bbs limits.

You made 4 msgs, but named the 2/5, 4/5, 5/5. Where is 3/5?

Regards, Kaare


--  
uucp: uunet!m2xenix!puddle!2!231!15!Kaare.Rasmussen
Internet: Kaare.Rasmussen@f15.n231.z2.fidonet.org