# Checking the Bison scanner. -*- Autotest -*-
-# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-# Free Software Foundation, Inc.
+
+# Copyright (C) 2002-2011 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
AT_COMPILE([input.o], [-c input.c])
-# Periods and dashes are genuine letters, they can start identifiers.
-# Digits cannot.
+# Periods are genuine letters, they can start identifiers.
+# Digits and dashes cannot.
AT_DATA_GRAMMAR([input.y],
[[%token .GOOD
-GOOD
1NV4L1D
+ -123
%%
-start: .GOOD -GOOD
+start: .GOOD GOOD
]])
AT_BISON_CHECK([-o input.c input.y], [1], [],
-[[input.y:11.10-16: invalid identifier: `1NV4L1D'
+[[input.y:10.10: invalid character: `-'
+input.y:11.10-16: invalid identifier: `1NV4L1D'
+input.y:12.10: invalid character: `-'
]])
AT_CLEANUP
AT_CLEANUP
+## ------------------------------- ##
+## %prec's token must be defined. ##
+## ------------------------------- ##
+
+AT_SETUP([[%prec's token must be defined]])
+
+# According to POSIX, a %prec token must be defined separately.
+
+AT_DATA([[input.y]],
+[[%%
+start: %prec PREC ;
+]])
+
+AT_BISON_CHECK([[input.y]], [[0]], [],
+[[input.y:2.8-17: warning: token for %prec is not defined: PREC
+]])
+
+AT_CLEANUP
+
+
## -------------------------------- ##
## Reject unused %code qualifiers. ##
## -------------------------------- ##
%%
start: ;
]])
-AT_BISON_CHECK([[input-c.y]], [0], [],
-[[input-c.y:1.7: warning: %code qualifier `q' is not used
-input-c.y:2.7-9: warning: %code qualifier `bad' is not used
-input-c.y:3.7-9: warning: %code qualifier `bad' is not used
-input-c.y:4.7-12: warning: %code qualifier `format' is not used
+AT_BISON_CHECK([[input-c.y]], [[1]], [],
+[[input-c.y:1.7: %code qualifier `q' is not used
+input-c.y:2.7-9: %code qualifier `bad' is not used
+input-c.y:3.7-9: %code qualifier `bad' is not used
+input-c.y:4.7-12: %code qualifier `format' is not used
]])
AT_DATA([input-c-glr.y],
%%
start: ;
]])
-AT_BISON_CHECK([[input-c-glr.y]], [0], [],
-[[input-c-glr.y:1.7: warning: %code qualifier `q' is not used
-input-c-glr.y:2.7-9: warning: %code qualifier `bad' is not used
-input-c-glr.y:3.8-10: warning: %code qualifier `bad' is not used
+AT_BISON_CHECK([[input-c-glr.y]], [[1]], [],
+[[input-c-glr.y:1.7: %code qualifier `q' is not used
+input-c-glr.y:2.7-9: %code qualifier `bad' is not used
+input-c-glr.y:3.8-10: %code qualifier `bad' is not used
]])
AT_DATA([input-c++.y],
%%
start: ;
]])
-AT_BISON_CHECK([[input-c++.y]], [0], [],
-[[input-c++.y:1.7: warning: %code qualifier `q' is not used
-input-c++.y:2.7-9: warning: %code qualifier `bad' is not used
-input-c++.y:3.8: warning: %code qualifier `q' is not used
+AT_BISON_CHECK([[input-c++.y]], [[1]], [],
+[[input-c++.y:1.7: %code qualifier `q' is not used
+input-c++.y:2.7-9: %code qualifier `bad' is not used
+input-c++.y:3.8: %code qualifier `q' is not used
]])
AT_DATA([input-c++-glr.y],
%%
start: ;
]])
-AT_BISON_CHECK([[input-c++-glr.y]], [0], [],
-[[input-c++-glr.y:1.7-9: warning: %code qualifier `bad' is not used
-input-c++-glr.y:2.7: warning: %code qualifier `q' is not used
-input-c++-glr.y:3.7: warning: %code qualifier `q' is not used
+AT_BISON_CHECK([[input-c++-glr.y]], [[1]], [],
+[[input-c++-glr.y:1.7-9: %code qualifier `bad' is not used
+input-c++-glr.y:2.7: %code qualifier `q' is not used
+input-c++-glr.y:3.7: %code qualifier `q' is not used
]])
AT_DATA([special-char-@@.y],
%%
start: ;
]])
-AT_BISON_CHECK([[special-char-@@.y]], [0], [],
-[[special-char-@@.y:1.7-9: warning: %code qualifier `bad' is not used
-special-char-@@.y:2.7: warning: %code qualifier `q' is not used
-special-char-@@.y:3.7: warning: %code qualifier `q' is not used
+AT_BISON_CHECK([[special-char-@@.y]], [[1]], [],
+[[special-char-@@.y:1.7-9: %code qualifier `bad' is not used
+special-char-@@.y:2.7: %code qualifier `q' is not used
+special-char-@@.y:3.7: %code qualifier `q' is not used
]])
AT_DATA([special-char-@:>@.y],
%%
start: ;
]])
-AT_BISON_CHECK([[special-char-@:>@.y]], [0], [],
-[[special-char-@:>@.y:1.7-9: warning: %code qualifier `bad' is not used
-special-char-@:>@.y:2.7: warning: %code qualifier `q' is not used
-special-char-@:>@.y:3.7: warning: %code qualifier `q' is not used
+AT_BISON_CHECK([[special-char-@:>@.y]], [[1]], [],
+[[special-char-@:>@.y:1.7-9: %code qualifier `bad' is not used
+special-char-@:>@.y:2.7: %code qualifier `q' is not used
+special-char-@:>@.y:3.7: %code qualifier `q' is not used
]])
AT_CLEANUP
start: ;
]])
-AT_BISON_CHECK([[input-unused.y]], [[0]], [],
-[[input-unused.y:1.9-11: warning: %define variable `var' is not used
+AT_BISON_CHECK([[input-unused.y]], [[1]], [],
+[[input-unused.y:1.9-11: %define variable `var' is not used
]])
AT_CLEANUP
## %define, --define, --force-define. ##
## ----------------------------------- ##
-AT_SETUP([%define, --define, --force-define])
+AT_SETUP([[%define, --define, --force-define]])
-AT_DATA([skel.c],
+AT_DATA([[skel.c]],
[[m4@&t@_divert_push(0)@
@output(b4_parser_file_name@)@
[var-dd: ]b4_percent_define_get([[var-dd]])[
var-fd: ]b4_percent_define_get([[var-fd]])
m4@&t@_divert_pop(0)
]])
-
-AT_DATA([input.y],
+AT_DATA([[input.y]],
[[%define var-dfg "gram"
%%
start: ;
]])
-
AT_BISON_CHECK([[-Dvar-dd=cmd-d1 -Dvar-dd=cmd-d2 \
-Fvar-ff=cmd-f1 -Fvar-ff=cmd-f2 \
-Dvar-dfg=cmd-d -Fvar-dfg=cmd-f \
-Fvar-fd=cmd-f -Dvar-fd=cmd-d \
- -Dunused-d -Funused-f \
- --skeleton ./skel.c input.y]], [[0]], [],
-[[<command line>:10: warning: %define variable `unused-d' is not used
-<command line>:11: warning: %define variable `unused-f' is not used
-]])
-
+ --skeleton ./skel.c input.y]])
AT_CHECK([[cat input.tab.c]], [[0]],
[[var-dd: cmd-d2
var-ff: cmd-f2
var-fd: cmd-d
]])
-AT_DATA([input-dg.y],
+AT_DATA([[input-dg.y]],
[[%define var "gram"
%%
start: ;
]])
-
AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
[[input-dg.y:1.9-11: %define variable `var' redefined
<command line>:2: previous definition
]])
+AT_DATA([[input-unused.y]],
+[[%%
+start: ;
+]])
+AT_BISON_CHECK([[-Dunused-d -Funused-f input-unused.y]], [[1]], [],
+[[<command line>:2: %define variable `unused-d' is not used
+<command line>:3: %define variable `unused-f' is not used
+]])
+
AT_CLEANUP
## --------------------------- ##
]])
AT_BISON_CHECK([[input.y]], [[1]], [[]],
[[input.y:1.9-29: invalid value for %define variable `lr.default-reductions': `bogus'
-input.y:1.9-29: accepted value: `all'
+input.y:1.9-29: accepted value: `most'
input.y:1.9-29: accepted value: `consistent'
input.y:1.9-29: accepted value: `accepting'
]])
%%
start: ;
]])
-AT_BISON_CHECK([[input.y]], [0], [],
-[[input.y:1.9-15: warning: %define variable `foo_bar' is not used
+AT_BISON_CHECK([[input.y]], [[1]], [],
+[[input.y:1.9-15: %define variable `foo_bar' is not used
]])
AT_CLEANUP
start: ;
]])
-AT_BISON_CHECK([[input.y]], [0], [],
-[[input.y:1.9-16: warning: %define variable `api.pure' is not used
+AT_BISON_CHECK([[input.y]], [[1]], [],
+[[input.y:1.9-16: %define variable `api.pure' is not used
]])
])
]])
AT_CLEANUP
+
+## ------------------------- ##
+## LAC: Errors for %define. ##
+## ------------------------- ##
+
+AT_SETUP([[LAC: Errors for %define]])
+
+AT_DATA([[input.y]],
+[[%%
+start: ;
+]])
+
+# parse.lac.* options are useless if LAC isn't actually activated.
+AT_BISON_CHECK([[-Dparse.lac.es-capacity-initial=1 input.y]],
+ [[1]], [],
+[[<command line>:2: %define variable `parse.lac.es-capacity-initial' is not used
+]])
+AT_BISON_CHECK([[-Dparse.lac.memory-trace=full input.y]],
+ [[1]], [],
+[[<command line>:2: %define variable `parse.lac.memory-trace' is not used
+]])
+
+AT_CLEANUP