Newer
Older
/*
** parser.h for 42sh
**
** Made by Seblu
** Login <seblu@epita.fr>
**
** Started on Wed Aug 2 00:49:50 2006 Seblu
#include "../ast/ast.h"
#ifndef PARSER_H_
# define PARSER_H_
// Define is parser or lexer is running for DEBBUGING
#define DEBUG_PARSER 1
#define DEBUG_LEXER 0
//token free-context recognition (lexer time)
TOK_NEWLINE, // \n
TOK_EOF, // EOF
TOK_AND, // &&
TOK_SEPAND, // &
TOK_OR, // ||
TOK_PIPE, // |
TOK_DSEMI, // ;;
TOK_SEP, // ;
TOK_DLESSDASH, // <<-
TOK_DLESS, // <<
TOK_LESSGREAT, // <>
TOK_LESSAND, // <&
TOK_LESS, // <
TOK_DGREAT, // >>
TOK_GREATAND, // >&
TOK_CLOBBER, // >|
TOK_GREAT, // >
TOK_IONUMBER, // number juste before '>' or '<'
//token context-sensitive recognition (parser time)
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, // }
TOK_BANG // !
/*!
** Parser initialization
**
** @param fs file stream to read
**
** @return the new struct
*/
/*!
** Do a parse pass
**
** @param parser the parser where we do this parse
**
** @return ast_to_execute
*/
** Lexer initialization
**
** @param fs file stream to read
**
** @return the new struct
*/
** This must be call by parser before each parse start
** This function is necessarity to correctly show the prompt
** @param lexer lexer to set in starting block
**
** @return return if lexer is ready to start or not
** Return the next token and destroy it
** @warning The token MUST be freed !
**
** @return the next token
** Return the next token without destruction of it.
** @warning The token string MUST NOT be freed !
** @return the look ahead token
/*!
** Parse input as a here-document (describe is XSI)
**
** @param lexer current lexer
*/
s_token lexer_getheredoc(s_lexer *lexer, const char *delim);