Commit 0113353c authored by Seblu's avatar Seblu

avancement du parser

avancement des printer de l'ast
parent 00f2ed90
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Sun Jul 30 04:40:03 2006 Seblu
** Last update Fri Sep 1 00:30:34 2006 Seblu
** Last update Tue Sep 26 17:49:18 2006 Seblu
*/
#ifndef AST_H_
......@@ -189,6 +189,7 @@ void ast_print(s_ast_node *ast, const char *filename);
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_print_node(s_ast_node *ast, FILE *fs, unsigned int *node_id);
......@@ -279,6 +280,15 @@ void ast_case_destruct(s_ast_node *node);
*/
s_ast_node *ast_while_create(s_ast_node *cond, s_ast_node *exec);
/*!
** Print an ast while (while) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_while_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct a while ast node
**
......@@ -296,6 +306,15 @@ void ast_while_destruct(s_ast_node *node);
*/
s_ast_node *ast_until_create(s_ast_node *cond, s_ast_node *exec);
/*!
** Print an ast until (until) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_until_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct a until ast node
**
......@@ -339,7 +358,13 @@ void ast_cmd_add_argv(s_ast_node *node, char *argv);
*/
void ast_cmd_add_prefix(s_ast_node *node, char *assignment_word);
/*!
** Print an ast cmd node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_cmd_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
......@@ -359,6 +384,15 @@ void ast_cmd_destruct(s_ast_node *node);
*/
s_ast_node *ast_and_create(s_ast_node *lhs, s_ast_node *rhs);
/*!
** Print an ast and (&&) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_and_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct an and (&&) node
**
......@@ -376,6 +410,15 @@ void ast_and_destruct(s_ast_node *node);
*/
s_ast_node *ast_or_create(s_ast_node *lhs, s_ast_node *rhs);
/*!
** Print an ast or (||) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_or_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct an or (||) node
**
......@@ -384,7 +427,7 @@ s_ast_node *ast_or_create(s_ast_node *lhs, s_ast_node *rhs);
void ast_or_destruct(s_ast_node *node);
/*!
** Create a subshell ($()) ast node
** Create a subshell (()) ast node
**
** @param child subshell tree
**
......@@ -393,7 +436,16 @@ void ast_or_destruct(s_ast_node *node);
s_ast_node *ast_subshell_create(s_ast_node *child);
/*!
** Destruct a subshell ($()) node
** Print an ast subshell (()) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_subshell_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct a subshell (()) node
**
** @param node node to destroy
*/
......@@ -425,6 +477,15 @@ void ast_funcdec_destruct(s_ast_node *node);
*/
s_ast_node *ast_bang_create(s_ast_node *child);
/*!
** Print an ast bang (!) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_bang_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct a bang (!) node
**
......@@ -442,6 +503,15 @@ void ast_bang_destruct(s_ast_node *node);
*/
s_ast_node *ast_pipe_create(s_ast_node *lhs, s_ast_node *rhs);
/*!
** Print an ast pipe (|) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_pipe_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct a pipe (|) node
**
......@@ -459,6 +529,15 @@ void ast_pipe_destruct(s_ast_node *node);
*/
s_ast_node *ast_sep_create(s_ast_node *lhs, s_ast_node *rhs);
/*!
** Print an ast sep (;) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_sep_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct a sep (;) node
**
......@@ -476,6 +555,15 @@ void ast_sep_destruct(s_ast_node *node);
*/
s_ast_node *ast_sepand_create(s_ast_node *lhs, s_ast_node *rhs);
/*!
** Print an ast sepand (&) node
**
** @param ast ast node to add to file
** @param fs file stream where print ast
** @param node_id first free node id
*/
void ast_sepand_print(s_ast_node *node, FILE *fs, unsigned int *node_id);
/*!
** Destruct a sepand (&) node
**
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Mon Aug 28 23:57:05 2006 Seblu
** Last update Tue Sep 26 17:45:16 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,21 @@ s_ast_node *ast_and_create(s_ast_node *lhs, s_ast_node *rhs)
return node;
}
void ast_and_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, rhs_id, cur_id;
if (node->type != T_AND)
return;
fprintf(fs, "%u [label = \"&&\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_and.lhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
rhs_id = *node_id;
ast_print_node(node->body.child_and.rhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, rhs_id);
}
void ast_and_destruct(s_ast_node *node)
{
if (node->type != T_AND)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Mon Aug 28 23:57:20 2006 Seblu
** Last update Tue Sep 26 17:45:45 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,18 @@ s_ast_node *ast_bang_create(s_ast_node *child)
return node;
}
void ast_bang_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, cur_id;
if (node->type != T_BANG)
return;
fprintf(fs, "%u [label = \"!\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_bang.lhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
}
void ast_bang_destruct(s_ast_node *node)
{
if (node->type != T_BANG)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Fri Aug 18 22:13:51 2006 Seblu
** Last update Mon Sep 25 04:19:18 2006 Seblu
** Last update Tue Sep 26 17:25:05 2006 Seblu
*/
#include "ast.h"
......@@ -37,7 +37,7 @@ void ast_cmd_add_redir(s_ast_node *node,
red->fd = fd;
red->word = word;
red->next = NULL;
for (this = &node->body.child_cmd.redirs; *this; *this = (*this)->next)
for (this = &node->body.child_cmd.redirs; (*this) != NULL; this = &(*this)->next)
; //do nothing
*this = red;
}
......@@ -77,10 +77,10 @@ void ast_cmd_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
if (node->type != T_CMD)
return;
fprintf(fs, "%u [label = \"Command\"];\n", *node_id);
++*node_id;
//prefix
char **prefix = node->body.child_cmd.prefix;
if (prefix && prefix[0]) {
++*node_id;
fprintf(fs, "%u [label = \"", *node_id);
for (int i = 0; prefix && prefix[i]; ++i) {
fprintf(fs, "prefix[%d]:", i);
......@@ -93,11 +93,11 @@ void ast_cmd_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
}
fprintf(fs, "\"];\n");
fprintf(fs, "%u -> %u\n", cur_id, *node_id);
++*node_id;
}
//arguments
char **argv = node->body.child_cmd.argv;
if (argv && argv[0]) {
++*node_id;
fprintf(fs, "%u [label = \"", *node_id);
for (int i = 0; argv && argv[i]; ++i) {
fprintf(fs, "argv[%d]:", i);
......@@ -110,11 +110,11 @@ void ast_cmd_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
}
fprintf(fs, "\"];\n");
fprintf(fs, "%u -> %u\n", cur_id, *node_id);
++*node_id;
}
//redirs
if (node->body.child_cmd.redirs) {
int i = 0;
++*node_id;
fprintf(fs, "%u [label = \"", *node_id);
for (s_redir *this = node->body.child_cmd.redirs; this; this = this->next, ++i) {
fprintf(fs, "redirs[%d]: fd=%d, type=%d, word=", i, this->fd, this->type);
......@@ -124,6 +124,7 @@ void ast_cmd_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
fprintf(fs, "%.*s\\", p - last, this->word + last), last = p;
fprintf(fs, "%*s", p - last, this->word + last), last = p;
fprintf(fs, "\\n");
++*node_id;
}
fprintf(fs, "\"];\n");
fprintf(fs, "%u -> %u\n", cur_id, *node_id);
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Mon Aug 28 23:59:55 2006 Seblu
** Last update Tue Sep 26 17:45:54 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,21 @@ s_ast_node *ast_or_create(s_ast_node *lhs, s_ast_node *rhs)
return node;
}
void ast_or_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, rhs_id, cur_id;
if (node->type != T_OR)
return;
fprintf(fs, "%u [label = \"||\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_or.lhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
rhs_id = *node_id;
ast_print_node(node->body.child_or.rhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, rhs_id);
}
void ast_or_destruct(s_ast_node *node)
{
if (node->type != T_OR)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Tue Aug 29 00:00:31 2006 Seblu
** Last update Tue Sep 26 17:45:33 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,21 @@ s_ast_node *ast_pipe_create(s_ast_node *lhs, s_ast_node *rhs)
return node;
}
void ast_pipe_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, rhs_id, cur_id;
if (node->type != T_PIPE)
return;
fprintf(fs, "%u [label = \"|\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_pipe.lhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
rhs_id = *node_id;
ast_print_node(node->body.child_pipe.rhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, rhs_id);
}
void ast_pipe_destruct(s_ast_node *node)
{
if (node->type != T_PIPE)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Sat Mar 25 23:11:01 2006 Seblu
** Last update Fri Sep 1 00:31:28 2006 Seblu
** Last update Tue Sep 26 17:47:33 2006 Seblu
*/
#include <string.h>
......@@ -17,31 +17,31 @@
#include <sys/stat.h>
#include "ast.h"
#define NODE_TYPE_COUNT 14
enum { NODE_TYPE_COUNT = 14 };
typedef void (*print_fct)(s_ast_node *, FILE *, unsigned int *);
typedef void (*f_print)(s_ast_node *, FILE *, unsigned int *);
struct ast_print_switch
{
e_node_type type;
print_fct fct;
f_print fct;
};
struct ast_print_switch print_table[NODE_TYPE_COUNT] =
{
{T_IF, NULL}, // ast_if_print},
{T_FOR, NULL}, //ast_for_print},
{T_WHILE, NULL}, //ast_while_print},
{T_UNTIL, NULL}, //ast_until_print},
{T_WHILE, ast_while_print},
{T_UNTIL, ast_until_print},
{T_CMD, ast_cmd_print},
{T_AND, NULL}, //ast_and_print},
{T_OR, NULL}, //ast_or_print},
{T_SUBSHELL, NULL}, //ast_subshell_print},
{T_AND, ast_and_print},
{T_OR, ast_or_print},
{T_SUBSHELL, ast_subshell_print},
{T_FUNCDEC, NULL}, //ast_funcdec_print},
{T_BANG, NULL}, //ast_bang_print},
{T_PIPE, NULL}, //ast_pipe_print},
{T_SEPAND, NULL}, //ast_sepand_print},
{T_SEP, NULL}, //ast_sep_print},
{T_BANG, ast_bang_print},
{T_PIPE, ast_pipe_print},
{T_SEPAND, ast_sepand_print},
{T_SEP, ast_sep_print},
{T_CASE, NULL} //ast_sepand_print}
};
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Wed Aug 30 00:36:03 2006 Seblu
** Last update Tue Sep 26 17:10:01 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,21 @@ s_ast_node *ast_sep_create(s_ast_node *lhs, s_ast_node *rhs)
return node;
}
void ast_sep_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, rhs_id, cur_id;
if (node->type != T_SEP)
return;
fprintf(fs, "%u [label = \";\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_sep.lhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
rhs_id = *node_id;
ast_print_node(node->body.child_sep.rhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, rhs_id);
}
void ast_sep_destruct(s_ast_node *node)
{
if (node->type != T_SEP)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Tue Aug 29 00:00:49 2006 Seblu
** Last update Tue Sep 26 17:43:20 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,21 @@ s_ast_node *ast_sepand_create(s_ast_node *lhs, s_ast_node *rhs)
return node;
}
void ast_sepand_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, rhs_id, cur_id;
if (node->type != T_SEPAND)
return;
fprintf(fs, "%u [label = \"&\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_sepand.lhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
rhs_id = *node_id;
ast_print_node(node->body.child_sepand.rhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, rhs_id);
}
void ast_sepand_destruct(s_ast_node *node)
{
if (node->type != T_SEPAND)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Tue Aug 29 00:07:12 2006 Seblu
** Last update Tue Sep 26 17:43:33 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,18 @@ s_ast_node *ast_subshell_create(s_ast_node *child)
return node;
}
void ast_subshell_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, cur_id;
if (node->type != T_SUBSHELL)
return;
fprintf(fs, "%u [label = \"()\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_subshell.lhs, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
}
void ast_subshell_destruct(s_ast_node *node)
{
if (node->type != T_SUBSHELL)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Tue Aug 29 00:01:11 2006 Seblu
** Last update Tue Sep 26 17:44:32 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,21 @@ s_ast_node *ast_until_create(s_ast_node *cond, s_ast_node *exec)
return node;
}
void ast_until_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, rhs_id, cur_id;
if (node->type != T_UNTIL)
return;
fprintf(fs, "%u [label = \"until\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_until.cond, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
rhs_id = *node_id;
ast_print_node(node->body.child_until.exec, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, rhs_id);
}
void ast_until_destruct(s_ast_node *node)
{
if (node->type != T_UNTIL)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Thu Aug 3 02:41:37 2006 Seblu
** Last update Tue Aug 29 00:01:57 2006 Seblu
** Last update Tue Sep 26 17:44:08 2006 Seblu
*/
#include "ast.h"
......@@ -21,6 +21,21 @@ s_ast_node *ast_while_create(s_ast_node *cond, s_ast_node *exec)
return node;
}
void ast_while_print(s_ast_node *node, FILE *fs, unsigned int *node_id)
{
unsigned int lhs_id, rhs_id, cur_id;
if (node->type != T_WHILE)
return;
fprintf(fs, "%u [label = \"while\"];\n", cur_id = *node_id);
lhs_id = ++*node_id;
ast_print_node(node->body.child_while.cond, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, lhs_id);
rhs_id = *node_id;
ast_print_node(node->body.child_while.exec, fs, node_id);
fprintf(fs, "%u -> %u\n", cur_id, rhs_id);
}
void ast_while_destruct(s_ast_node *node)
{
if (node->type != T_WHILE)
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Wed Aug 2 00:56:07 2006 Seblu
** Last update Mon Sep 25 04:44:08 2006 Seblu
** Last update Tue Sep 26 17:59:36 2006 Seblu
*/
#include <stdio.h>
......@@ -82,6 +82,7 @@ static s_ast_node *parse_rulewhile(s_parser *parser);
static s_ast_node *parse_ruleuntil(s_parser *parser);
static s_ast_node *parse_ruleif(s_parser *parser);
static s_ast_node *parse_rulecase(s_parser *parser);
static s_ast_node *parse_compound_list(s_parser *parser);
/*!
** Notify a parse error
......@@ -131,7 +132,6 @@ static s_ast_node *regnode(s_parser *parser, s_ast_node *node)
static void parse_error(s_parser *parser, s_token t)
{
debugmsg("parse_error");
fprintf(stderr, "%s: syntax error near unexpected token `%s'\n",
shell->name, t.str);
parser->error = 1;
......@@ -268,6 +268,14 @@ static s_ast_node *parse_pipeline(s_parser *parser)
banged = 1;
}
lhs = parse_command(parser);
/* if ((token = lexer_lookahead(parser->lexer)) == TOK_PIPE) { */
/* lexer_gettoken(parser->lexer); */
/* while (lexer_lookahead(parser->lexer) == TOK_NEWLINE) */
/* lexer_gettoken(parser->lexer); */
/* parse_pipeline( */
/* } */
if (banged)
return regnode(parser, ast_bang_create(lhs));
return lhs;
}
......@@ -279,11 +287,11 @@ static s_ast_node *parse_command(s_parser *parser)
token = lexer_lookahead(parser->lexer);
recon(&token);
if (token.id == TOK_FOR || token.id == TOK_WHILE || token.id == TOK_UNTIL ||
token.id == TOK_CASE || token.id == TOK_IF ||
!strcmp(token.str, "{") || !strcmp(token.str, "("))
token.id == TOK_CASE || token.id == TOK_IF || token.id == TOK_LBRACE ||
!strcmp(token.str, "("))
return parse_shellcommand(parser);
// probleme de choix avec function pour l'instant ya pas defonction !
else if (token.id == TOK_WORD) {
else if (token.id >= TOK_DLESSDASH && token.id <= TOK_WORD) {
return parse_simplecommand(parser);
}
else
......@@ -355,20 +363,20 @@ static s_ast_node *parse_shellcommand(s_parser *parser)
debugmsg("parse_shellcommand");
token = lexer_lookahead(parser->lexer);
recon(&token);
switch (token.id) {
case TOK_IF: parse_ruleif(parser); break;
case TOK_FOR: parse_rulefor(parser); break;
case TOK_WHILE: parse_rulewhile(parser); break;
case TOK_UNTIL: parse_ruleuntil(parser); break;
case TOK_CASE: parse_rulecase(parser); break;
case TOK_IF: return parse_ruleif(parser);
case TOK_FOR: return parse_rulefor(parser);
case TOK_WHILE: return parse_rulewhile(parser);
case TOK_UNTIL: return parse_ruleuntil(parser);
case TOK_CASE: return parse_rulecase(parser);
case TOK_LBRACE: assert(0);
case TOK_WORD:
//gerer le cas de { et de (
assert(0);
break;
if (!strcmp(token.str, "("))
return regnode(parser, ast_subshell_create(parse_compound_list(parser)));
default:
parse_error(parser, token);
}
return NULL;
}
......@@ -381,7 +389,7 @@ static s_ast_node *parse_shellcommand(s_parser *parser)
static void parse_redirection(s_parser *parser, s_ast_node *cmd)
{
s_token token;
long int fd;
long int fd = -1;
e_redir_type redtype;
debugmsg("parse_redirection");
......@@ -396,15 +404,15 @@ static void parse_redirection(s_parser *parser, s_ast_node *cmd)
//retrieve redirection type
token = lexer_gettoken(parser->lexer);
switch (token.id) {
case TOK_GREAT: redtype = R_GREAT; break;
case TOK_DGREAT: redtype = R_DLESS; break;
case TOK_DLESSDASH: redtype = R_DLESSDASH; break;
case TOK_DLESS: redtype = R_DLESS; break;
case TOK_LESSGREAT: redtype = R_LESSGREAT; break;
case TOK_LESSAND: redtype = R_LESSAND; break;
case TOK_LESS: redtype = R_LESS; break;
case TOK_CLOBBER: redtype = R_CLOBBER; break;
case TOK_GREATAND: redtype = R_GREATAND; break;
case TOK_GREAT: redtype = R_GREAT; if (fd == -1) fd = 1; break;
case TOK_DGREAT: redtype = R_DLESS; if (fd == -1) fd = 1; break;
case TOK_DLESSDASH: redtype = R_DLESSDASH; if (fd == -1) fd = 0; break;
case TOK_DLESS: redtype = R_DLESS; if (fd == -1) fd = 0; break;
case TOK_LESSGREAT: redtype = R_LESSGREAT; if (fd == -1) fd = 0; break;
case TOK_LESSAND: redtype = R_LESSAND; if (fd == -1) fd = 0; break;
case TOK_LESS: redtype = R_LESS; if (fd == -1) fd = 0; break;
case TOK_CLOBBER: redtype = R_CLOBBER; if (fd == -1) fd = 1; break;
case TOK_GREATAND: redtype = R_GREATAND; if (fd == -1) fd = 1; break;
default:
parse_error(parser, token);
}
......@@ -416,11 +424,11 @@ static void parse_redirection(s_parser *parser, s_ast_node *cmd)
parse_error(parser, token);
}
/* static s_ast_node *parse_compound_list(s_parser *parser) */
/* { */
/* parser=parser; */
/* return NULL; */
/* } */
static s_ast_node *parse_compound_list(s_parser *parser)
{
parser=parser;
return NULL;
}
static s_ast_node *parse_rulefor(s_parser *parser)
{
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** Started on Wed Aug 2 00:49:50 2006 Seblu
** Last update Mon Sep 25 03:41:31 2006 Seblu
** Last update Mon Sep 25 05:20:21 2006 Seblu
*/
#include <setjmp.h>
......@@ -43,25 +43,24 @@ typedef enum tokenid
TOK_GREAT, // >
TOK_IONUMBER, // number juste before '>' or '<'
TOK_WORD, // all others
//token context-sensitive recognition (parser time)
TOK_IF,
TOK_THEN,
TOK_ELSE,
TOK_FI,
TOK_ELIF,
TOK_DO,
TOK_DONE,
TOK_CASE,
TOK_ESAC,
TOK_WHILE,
TOK_UNTIL,
TOK_FOR,
TOK_IN,
TOK_LBRACE,
TOK_RBRACE,
TOK_NUMBER,
TOK_ASSIGNMENT,
TOK_BANG
TOK_IF, // if
TOK_THEN, // then
TOK_ELSE, // else
TOK_FI, // fi
TOK_ELIF, // elif
TOK_DO, // do
TOK_DONE, // done
TOK_CASE, // case
TOK_ESAC, // esac
TOK_WHILE, // while
TOK_UNTIL, // until
TOK_FOR, // for
TOK_IN, // in
TOK_LBRACE, // {
TOK_RBRACE, // }