/*	Copyright (C) 1994 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this software; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */

/*
 * Tom Lord
 * Cygnus Support
 */

%{
#include "yourscm.h"
#include "parse-ctax.tab.h"

/* According to POSIX (and what byacc actually does), this is only
   declared by parse-ctax.tab.h if %union is used.  So we need to declare it
   ourselves.  */
extern YYSTYPE yylval;

#ifdef __STDC__
extern char * ck_savestr ();
#endif
extern int parse_line_no;

%}

DIGIT [0-9]
NUMBER {DIGIT}+("."{DIGIT}*)?
%%
[\n]		++parse_line_no;
[ \t]*
\/\/.*
{NUMBER}	{
		  show("ctax_number_lx");
		  yylval = parse_number(yytext);
		  return ctax_number_lx;
		}
scm		show("ctax_SCM_lx"); return ctax_SCM_lx;
if		show("ctax_if_lx"); return ctax_if_lx;
else		show("ctax_else_lx"); return ctax_else_lx;
for		show("ctax_for_lx"); return ctax_for_lx;
while		show("ctax_while_lx"); return ctax_while_lx;
return		show("return"); return ctax_return_lx;
do		show("ctax_do_lx"); return ctax_do_lx;
break		show("ctax_break_lx"); return ctax_break_lx;
continue	show("ctax_continue_lx"); return ctax_continue_lx;
interactive	show("ctax_interactive_lx"); return ctax_interactive_lx;
[a-z][a-z?!<>=0-9_]*	{
			  show("ctax_id_lx");
			  yylval = parse_intern (yytext);
		          return ctax_id_lx;
		        }
=		show("'='"); return '=';
\+		show("'+'"); return '+';
-		show("'-'"); return '-';
\*		show("'*'"); return '*';
\/		show("'/'"); return '/';
&		show("'&'"); return '&';
\|		show("'|'"); return '|';
~		show("'~'"); return '~';
!		show("'!'"); return '!';
\^		show("'^'"); return '^';
%		show("'%'"); return '%';
;		show("';'"); return ';';
\<		show("'<'"); return '<';
>		show("'>'"); return '>';
,		show("','"); return ',';
\?		show("'?'"); return '?';
:		show("':'"); return ':';
\(		show("'('"); return '(';
\)		show("')'"); return ')';
==		show("ctax_eq_lx"); return ctax_eq_lx;
!=		show("ctax_ne_lx"); return ctax_ne_lx;
>=		show("ctax_ge_lx"); return ctax_ge_lx;
\<=		show("ctax_le_lx"); return ctax_le_lx;
\<\<		show("ctax_lshift_lx"); return ctax_lshift_lx;
\>\>		show("ctax_rshift_lx"); return ctax_rshift_lx;
&&		show("ctax_and_lx"); return ctax_and_lx;
\|\|		show("ctax_or_lx"); return ctax_or_lx;
\"([^\"\\]*(\\\")?)*\"    {
			    show("ctax_string_lx");
			    yylval = parse_make_string (yytext);
			    return ctax_string_lx;
			  }

'.'			  {
			    show("ctax_char_lx");
			    yylval = parse_make_char (yytext);
			    return ctax_char_lx;
			  }
\{			  show("{"); return '{';
\}			  show("}"); return '}';
%%

show (s)
  char * s;
{
#if 0
  printf ("lex: %s %s\n", s, yytext);
#endif
}

yyerror (msg)
  char * msg;
{
  printf ("%s\n", msg);
}
