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
19 changes: 19 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ EXTRA_DIST += src/frontend/c99-scanner.c

EXTRA_DIST += src/frontend/cxx03.l
EXTRA_DIST += src/frontend/cxx03.y
if ENABLE_GRAPH_GLR
EXTRA_DIST += src/frontend/cxx03-glr.y
endif
EXTRA_DIST += src/frontend/cxx03.y.in
EXTRA_DIST += src/frontend/cxx-scanner.c

Expand Down Expand Up @@ -461,6 +464,9 @@ BUILT_SOURCES += src/frontend/cxx03.l

BUILT_SOURCES += src/frontend/c99.y
BUILT_SOURCES += src/frontend/cxx03.y
if ENABLE_GRAPH_GLR
BUILT_SOURCES += src/frontend/cxx03-glr.y
endif

BUILT_SOURCES += src/frontend/cxx-parser.h
BUILT_SOURCES += src/frontend/c99-parser.h
Expand Down Expand Up @@ -593,16 +599,29 @@ CLEANFILES += src/frontend/cxx-parser.c
CLEANFILES += src/frontend/cxx-parser-internal.h
CLEANFILES += src/frontend/cxx-parser.output
CLEANFILES += src/frontend/cxx03.y
if ENABLE_GRAPH_GLR
CLEANFILES += src/frontend/cxx03-glr.y
endif
endif

src/frontend/cxx03.y : $(TPP) $(top_srcdir)/src/frontend/cxx03.y.in $(addprefix $(top_srcdir)/, $(ADDITIONAL_GRAMMARS))
$(TPP_verbose)(rm -f src/frontend/cxx03.y && $(TPP) -o src/frontend/cxx03.y -D CPLUSPLUS -I$(top_srcdir)/src/frontend $(top_srcdir)/src/frontend/cxx03.y.in && chmod -w src/frontend/cxx03.y)

src/frontend/cxx03-glr.y : $(TPP) $(top_srcdir)/src/frontend/cxx03.y.in $(addprefix $(top_srcdir)/, $(ADDITIONAL_GRAMMARS))
$(TPP_verbose)(rm -f src/frontend/cxx03-glr.y && $(TPP) -o src/frontend/cxx03-glr.y -D CPLUSPLUS -D GRAPH_GLR -I$(top_srcdir)/src/frontend $(top_srcdir)/src/frontend/cxx03.y.in && chmod -w src/frontend/cxx03-glr.y)

src/frontend/cxx-parser-internal.h : src/frontend/cxx-parser.c
if BISON_BUILDING
if ENABLE_GRAPH_GLR
src/frontend/cxx-parser.c : src/frontend/cxx03-glr.y
rm -f src/frontend/cxx-parser.c
$(BISON_verbose)$(BISON) -pmcxx --debug --defines=src/frontend/cxx-parser-internal.h --report=all --output=src/frontend/cxx-parser.c src/frontend/cxx03-glr.y
chmod -w src/frontend/cxx-parser.c
else
src/frontend/cxx-parser.c : src/frontend/cxx03.y
$(BISON_verbose)$(BISON) -pmcxx --debug --defines=src/frontend/cxx-parser-internal.h --report=all --output=src/frontend/cxx-parser.c src/frontend/cxx03.y
endif
endif

# These are obtained when invoking bison, if we write a rule like 'a b : d' it
# breaks parallel compilations since bison gets invoked twice.
Expand Down
39 changes: 39 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,7 @@ flex_good=no

force_bison=no
bison_good=no
enable_graph_glr=no

force_gperf=no
gperf_good=no
Expand Down Expand Up @@ -2020,6 +2021,35 @@ then
esac
fi

if test x$bison_good = xyes;
then
dnl Check if the current bison supports %graph-glr-parser
AC_MSG_CHECKING([bison supports %graph-glr-parser])

# Mini grammar file using %graph-glr
cat <<EOF > tmp.y
%graph-glr-parser
%token A
%start test

%%
test : A
;
EOF

AS_IF([$BISON -o /dev/null tmp.y &> /dev/null],
[
enable_graph_glr=yes
AC_MSG_RESULT([yes])
],
[
AC_MSG_RESULT([no])
]
)

rm -f tmp.y
fi

dnl Check gperf
AC_ARG_ENABLE([gperf-regeneration],
AS_HELP_STRING([--enable-gperf-regeneration], [Forces gperf regeneration, even if the version is not recommended or properly detected.]),
Expand Down Expand Up @@ -2074,6 +2104,14 @@ AM_CONDITIONAL([BISON_BUILDING], test x$bison_good = xyes)
AM_CONDITIONAL([FLEX_BUILDING], test x$flex_good = xyes)
AM_CONDITIONAL([GPERF_BUILDING], test x$gperf_good = xyes)

ENABLE_GRAPH_GLR=$enable_graph_glr
AC_SUBST([ENABLE_GRAPH_GLR])
AM_CONDITIONAL([ENABLE_GRAPH_GLR], test x$enable_graph_glr = xyes)
if test x$enable_graph_glr = xyes;
then
AC_DEFINE([ENABLE_GRAPH_GLR], 1, [Define to 1 if the Graph GLR algorithm is used])
fi

dnl --------------------- End of Regeneration files ---------------------

dnl --------------------- Type environments -----------------------------
Expand Down Expand Up @@ -2520,6 +2558,7 @@ print_tool()

print_tool "Flex " "$FLEX"
print_tool "GNU bison " "$BISON"
echo " - Graph GLR is enabled:" $enable_graph_glr
print_tool "GNU gperf " "$GPERF"

print_tool "git content tracker" "$GIT"
Expand Down
11 changes: 8 additions & 3 deletions src/frontend/cxx03.y.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@

%}

/*!ifnot GRAPH_GLR*/
%glr-parser
/*!endif*/
/*!if GRAPH_GLR*/
%graph-glr-parser
/*!endif*/

%union {
token_atrib_t token_atrib;
Expand All @@ -64,9 +69,6 @@
};


// This is a specific feature of rofi-bison 2.3
// %default-merge <ambiguityHandler>

%parse-param {AST* parsed_tree}

%locations
Expand Down Expand Up @@ -4891,6 +4893,9 @@ nested_name_specifier_0 : class_or_namespace_name
$$ = $1;
}
| decltype_specifier
{
$$ = $1;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a limitation of the current implementation of graph-glr and it will be lifted in the future. That said, the rest of the file uses this style so I think this is OK.

}
;

nested_name_specifier_1 : nested_name_specifier_0
Expand Down