Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Install dependencies
command: |
sudo apt-get update
sudo apt-get install -qy make gcc libtool autoconf automake bison libreadline-dev
sudo apt-get install -qy make gcc libtool autoconf automake libreadline-dev

- run:
name: Autotools
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
test/tests/trip.es text diff
y.tab.c -diff
y.tab.h -diff
token.h -diff
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ config.h

# yacc

y.*
y.output
y.tab.h

# es

initial.c
sigmsgs.c
token.h
es
esdump
testrun
23 changes: 9 additions & 14 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ mandir = @mandir@
bindir = @bindir@
srcdir = @srcdir@
testdir = @srcdir@/test

VPATH = $(srcdir)


SHELL = /bin/sh
CC = @CC@
YACC = @YACC@
Expand All @@ -52,7 +49,7 @@ LDFLAGS = @LDFLAGS@ $(ADDLDFLAGS)
LIBS = @READLINE_LIBS@ @LIBS@ $(ADDLIBS)

HFILES = config.h es.h gc.h input.h prim.h print.h sigmsgs.h \
stdenv.h syntax.h term.h var.h
stdenv.h syntax.h term.h token.h var.h
CFILES = access.c closure.c conv.c dict.c eval.c except.c fd.c gc.c glob.c \
glom.c input.c heredoc.c history.c list.c main.c match.c open.c opt.c \
prim-ctl.c prim-etc.c prim-io.c prim-sys.c prim.c print.c proc.c \
Expand All @@ -64,7 +61,7 @@ OFILES = access.o closure.o conv.o dict.o eval.o except.o fd.o gc.o glob.o \
sigmsgs.o signal.o split.o status.o str.o syntax.o term.o token.o \
tree.o util.o var.o vec.o version.o y.tab.o
OTHER = Makefile parse.y mksignal
GEN = esdump y.tab.c y.tab.h y.output token.h sigmsgs.c initial.c
GEN = esdump y.tab.h y.output sigmsgs.c initial.c

SIGFILES = @SIGFILES@

Expand Down Expand Up @@ -104,14 +101,12 @@ testclean :
src :
@echo $(OTHER) $(CFILES) $(HFILES)

y.tab.h : parse.y
$(YACC) -vd $(srcdir)/parse.y

y.tab.c : y.tab.h

token.h : y.tab.h
token.h : parse.y
$(YACC) -vd -b y $(srcdir)/parse.y
-cmp -s y.tab.h token.h || cp y.tab.h token.h

y.tab.c : token.h

initial.c : esdump $(srcdir)/initial.es
./esdump < $(srcdir)/initial.es > initial.c

Expand All @@ -134,9 +129,9 @@ fd.o : fd.c es.h config.h stdenv.h
gc.o : gc.c es.h config.h stdenv.h gc.h
glob.o : glob.c es.h config.h stdenv.h gc.h
glom.o : glom.c es.h config.h stdenv.h gc.h
input.o : input.c es.h config.h stdenv.h input.h
heredoc.o : heredoc.c es.h config.h stdenv.h gc.h input.h syntax.h
history.o : history.c es.h config.h stdenv.h gc.h input.h
input.o : input.c es.h config.h stdenv.h input.h token.h
heredoc.o : heredoc.c es.h config.h stdenv.h gc.h input.h syntax.h token.h
history.o : history.c es.h config.h stdenv.h gc.h input.h token.h
list.o : list.c es.h config.h stdenv.h gc.h
main.o : main.c es.h config.h stdenv.h
match.o : match.c es.h config.h stdenv.h
Expand Down
9 changes: 8 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ dnl Build configuration.

AC_ARG_ENABLE(strict, AS_HELP_STRING([--enable-strict], [enable strict compiler flags for testing and debugging; not all compilers support these]), opt_strict_mode=$enableval, opt_strict_mode=no)

AC_ARG_VAR(YACC, [yacc command. es requires bison, byacc, or something else that supports generating pure parsers.])

if test $opt_strict_mode = yes; then
AC_SUBST([STRICT_CFLAGS], ["-ansi -pedantic -DGCDEBUG=1 -D_POSIX_C_SOURCE=200112L -DREF_ASSERTIONS=1"])
fi
Expand All @@ -31,7 +33,12 @@ AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_MKDIR_P
AC_PROG_YACC

dnl Custom yacc check, because we don't want POSIX yacc.
dnl If we don't find either bison or byacc, just set it to yacc and see if it
dnl works or barfs on the extension.

AC_CHECK_PROGS(YACC, bison byacc, yacc)

dnl ----------------------------
dnl CHECK FOR /dev/fd FILESYSTEM
Expand Down
4 changes: 3 additions & 1 deletion input.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#define MAXUNGET 2 /* maximum 2 character pushback */

#include "token.h" /* for YYSTYPE */

typedef struct Input Input;
struct Input {
int (*get)(Input *self);
Expand Down Expand Up @@ -34,7 +36,7 @@ extern void yyerror(const char *s);
/* token.c */

extern const char dnw[];
extern int yylex(void);
extern int yylex(YYSTYPE *y);
extern void inityy(void);
extern void print_prompt2(void);

Expand Down
2 changes: 2 additions & 0 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "syntax.h"
%}

%define api.pure full

%token <str> WORD QWORD
%token LOCAL LET FOR CLOSURE FN
%token <tree> REDIR DUP
Expand Down
3 changes: 1 addition & 2 deletions token.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,12 @@ static Boolean getfds(int fd[2], int c, int default0, int default1) {
return TRUE;
}

extern int yylex(void) {
extern int yylex(YYSTYPE *y) {
static Boolean dollar = FALSE;
int c;
size_t i; /* The purpose of all these local assignments is to */
const char *meta; /* allow optimizing compilers like gcc to load these */
char *buf = tokenbuf; /* values into registers. On a sparc this is a */
YYSTYPE *y = &yylval; /* win, in code size *and* execution time */

if (goterror) {
goterror = FALSE;
Expand Down
110 changes: 110 additions & 0 deletions token.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/* A Bison parser, made by GNU Bison 3.8.2. */

/* Bison interface for Yacc-like parsers in C

Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 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 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 <https://www.gnu.org/licenses/>. */

/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.

This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */

/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */

#ifndef YY_YY_Y_TAB_H_INCLUDED
# define YY_YY_Y_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif

/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
WORD = 258, /* WORD */
QWORD = 259, /* QWORD */
LOCAL = 260, /* LOCAL */
LET = 261, /* LET */
FOR = 262, /* FOR */
CLOSURE = 263, /* CLOSURE */
FN = 264, /* FN */
REDIR = 265, /* REDIR */
DUP = 266, /* DUP */
ANDAND = 267, /* ANDAND */
BACKBACK = 268, /* BACKBACK */
BBFLAT = 269, /* BBFLAT */
BFLAT = 270, /* BFLAT */
EXTRACT = 271, /* EXTRACT */
CALL = 272, /* CALL */
COUNT = 273, /* COUNT */
FLAT = 274, /* FLAT */
OROR = 275, /* OROR */
PRIM = 276, /* PRIM */
SUB = 277, /* SUB */
NL = 278, /* NL */
ENDFILE = 279, /* ENDFILE */
ERROR = 280, /* ERROR */
MATCH = 281, /* MATCH */
PIPE = 282 /* PIPE */
};
typedef enum yytokentype yytoken_kind_t;
#endif

/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 27 "./parse.y"

Tree *tree;
char *str;
NodeKind kind;

#line 97 "y.tab.h"

};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif




int yyparse (void);


#endif /* !YY_YY_Y_TAB_H_INCLUDED */
Loading