16
16
-file("/clearcase/otp/erts/lib/parsetools/include/yeccpre.hrl", 0).
18
18
%% %CopyrightBegin%
20
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
20
%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
22
22
%% The contents of this file are subject to the Erlang Public License,
23
23
%% Version 1.1, (the "License"); you may not use this file except in
24
24
%% compliance with the License. You should have received a copy of the
25
25
%% Erlang Public License along with this software. If not, it can be
26
26
%% retrieved online at http://www.erlang.org/.
28
28
%% Software distributed under the License is distributed on an "AS IS"
29
29
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
30
30
%% the License for the specific language governing rights and limitations
31
31
%% under the License.
36
36
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37
37
% The parser generator will insert appropriate declarations before this line.%
39
-type(yecc_ret() :: {'error', _} | {'ok', _}).
39
-type yecc_ret() :: {'error', _} | {'ok', _}.
41
-spec(parse/1 :: (_) -> yecc_ret()).
41
-spec parse(_) -> yecc_ret().
43
43
yeccpars0(Tokens, false).
45
-spec(parse_and_scan/1 ::
46
({function() | {atom(), atom()}, [_]} | {atom(), atom(), [_]}) ->
45
-spec parse_and_scan({function() | {atom(), atom()}, [_]} | {atom(), atom(), [_]}) ->
48
47
parse_and_scan({F, A}) -> % Fun or {M, F}
49
48
yeccpars0([], {F, A});
50
49
parse_and_scan({M, F, A}) ->
51
50
yeccpars0([], {{M, F}, A}).
53
-spec(format_error/1 :: (any()) -> [char() | list()]).
52
-spec format_error(any()) -> [char() | list()].
54
53
format_error(Message) ->
55
54
case io_lib:deep_char_list(Message) of
62
% To be used in grammar files to throw an error message to the parser
63
% toplevel. Doesn't have to be exported!
61
%% To be used in grammar files to throw an error message to the parser
62
%% toplevel. Doesn't have to be exported!
64
63
-compile({nowarn_unused_function,{return_error,2}}).
65
-spec(return_error/2 :: (integer(), any()) -> no_return()).
64
-spec return_error(integer(), any()) -> no_return().
66
65
return_error(Line, Message) ->
67
66
throw({error, {Line, ?MODULE, Message}}).
101
100
yeccpars1([], {F, A}, State, States, Vstack) ->
102
101
case apply(F, A) of
103
102
{ok, Tokens, _Endline} ->
104
yeccpars1(Tokens, {F, A}, State, States, Vstack);
103
yeccpars1(Tokens, {F, A}, State, States, Vstack);
105
104
{eof, _Endline} ->
106
105
yeccpars1([], false, State, States, Vstack);
107
106
{error, Descriptor, _Endline} ->
123
122
yeccpars1(State1, State, States, Vstack, Stack1, [], {F, A}) ->
124
123
case apply(F, A) of
125
124
{ok, Tokens, _Endline} ->
126
yeccpars1(State1, State, States, Vstack, Stack1, Tokens, {F, A});
125
yeccpars1(State1, State, States, Vstack, Stack1, Tokens, {F, A});
127
126
{eof, _Endline} ->
128
127
yeccpars1(State1, State, States, Vstack, Stack1, [], false);
129
128
{error, Descriptor, _Endline} ->