/****************************************************************************** * Date: Thu Oct 25 11:43:04 CDT 2007 * Author: John Quigley * Revision: $Id$ * * The White Programming Language * Copyright (C) 2007 John Quigley * * 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 3 of the License, 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 program. If not, see . *****************************************************************************/ %{ #include #include #include "core/util.h" #include "frontend/scan.h" #define YYPARSE_PARAM scanner #define YYLEX_PARAM scanner void yyerror (char const *s) { fprintf (stderr, "%s\n", s); } %} %pure-parser %locations %union { char * strval; /* string value */ long lval; /* rational value */ long long llval; /* integer value */ long double ldval; /* rational value */ } %token INTEGER %token RATIONAL %token SCIENTIFIC %token HEX %token OCTAL %token COMPLEX %token STRING %token SYMBOL %token KEYWORD %token IDENTIFIER %% program: /* empty */ { LOGGER_DEBUG("parser found program"); } | clause { LOGGER_DEBUG("parser found program"); } ; /* ************************************************************************* */ clause: expr ';' { LOGGER_DEBUG("parser found clause: expr"); return 0; } | clause expr ';' { LOGGER_DEBUG( "parser found clause: "); return 0; } ; expr: atomic_expr { LOGGER_DEBUG("parser found expr: atomic_expr"); } | grouped_expr { LOGGER_DEBUG("parser found expr: grouped_expr"); } | expr atomic_expr { LOGGER_DEBUG("parser found expr: "); } | expr grouped_expr { LOGGER_DEBUG( "parser found expr: "); } ; /* ************************************************************************* */ grouped_expr: '(' expr ')' { LOGGER_DEBUG("parser found grouped_expr: expr"); } | '[' clause ']' { LOGGER_DEBUG("parser found grouped_expr: complete_expr"); } ; atomic_expr: INTEGER { LOGGER_DEBUG("atomic_expr: INTEGER '%lld'", $1); } | RATIONAL { LOGGER_DEBUG("atomic_expr: RATIONAL '%Lf'", $1); } | SCIENTIFIC { LOGGER_DEBUG("atomic_expr: SCIENTIFIC '%Le'", $1); } | HEX { LOGGER_DEBUG("atomic_expr: HEX '%lx'", $1); } | OCTAL { LOGGER_DEBUG("atomic_expr: OCTAL '%lo'", $1); } | COMPLEX { LOGGER_DEBUG("atomic_expr: COMPLEX '%ld * i'", $1); } | STRING { LOGGER_DEBUG("atomic_expr: STRING '%s'", $1); } | SYMBOL { LOGGER_DEBUG("atomic_expr: SYMBOL '%s'", $1); } | IDENTIFIER { LOGGER_DEBUG("atomic_expr: IDENTIFIER '%s'", $1); } | KEYWORD { LOGGER_DEBUG("atomic_expr: KEYWORD '%s'", $1); } ; %% /* EOF */