Skip to content

Commit 55cdd86

Browse files
committed
Add missing bison files
1 parent 1045633 commit 55cdd86

File tree

21 files changed

+2313
-914
lines changed

21 files changed

+2313
-914
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Some usage notes for the D Parser:
2+
3+
- it is a port of the Java parser, so interface is very similar.
4+
5+
- the lexer class needs to implement the interface 'Lexer' (similar to
6+
java). It typically (depending on options) looks like this:
7+
8+
public interface Lexer
9+
{
10+
/**
11+
* Method to retrieve the beginning position of the last scanned token.
12+
* @return the position at which the last scanned token starts. */
13+
@property YYPosition startPos ();
14+
15+
/**
16+
* Method to retrieve the ending position of the last scanned token.
17+
* @return the first position beyond the last scanned token. */
18+
@property YYPosition endPos ();
19+
20+
/**
21+
* Method to retrieve the semantic value of the last scanned token.
22+
* @return the semantic value of the last scanned token. */
23+
@property YYSemanticType semanticVal ();
24+
25+
/**
26+
* Entry point for the scanner. Returns the token identifier corresponding
27+
* to the next token and prepares to return the semantic value
28+
* and beginning/ending positions of the token.
29+
* @return the token identifier corresponding to the next token. */
30+
YYTokenType yylex ();
31+
32+
/**
33+
* Entry point for error reporting. Emits an error
34+
* referring to the given location in a user-defined way.
35+
*
36+
* @param loc The location of the element to which the
37+
* error message is related
38+
* @param s The string for the error message. */
39+
void yyerror (YYLocation loc, string s);
40+
}
41+
42+
- semantic types are handled by D usions (same as for C/C++ parsers)
43+
44+
- the following (non-standard) %defines are supported:
45+
46+
%define package "<package_name>"
47+
%define api.parser.class "my_class_name>"
48+
%define position_type "my_position_type"
49+
%define location_type "my_location_type"
50+
51+
- the following declarations basically work like in C/C++:
52+
53+
%locations
54+
%error-verbose
55+
%parse-param
56+
%initial-action
57+
%code
58+
%union
59+
60+
- %destructor is not yet supported

msys2/usr/share/bison/bison.m4 renamed to msys2/usr/share/bison/skeletons/bison.m4

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
# Language-independent M4 Macros for Bison.
44

5-
# Copyright (C) 2002, 2004-2015, 2018 Free Software Foundation, Inc.
5+
# Copyright (C) 2002, 2004-2015, 2018-2019 Free Software Foundation,
6+
# Inc.
67

78
# This program is free software: you can redistribute it and/or modify
89
# it under the terms of the GNU General Public License as published by
@@ -263,8 +264,8 @@ m4_define([b4_subtract],
263264
# -------------------
264265
# Join with comma, skipping empty arguments.
265266
# b4_join calls itself recursively until it sees the first non-empty
266-
# argument, then calls _b4_join which prepends each non-empty argument
267-
# with a comma.
267+
# argument, then calls _b4_join (i.e., `_$0`) which prepends each
268+
# non-empty argument with a comma.
268269
m4_define([b4_join],
269270
[m4_if([$#$1],
270271
[1], [],
@@ -374,60 +375,42 @@ b4_define_flag_if([token_table]) # Whether yytoken_table is demanded.
374375
b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated.
375376

376377

378+
# b4_glr_cc_if([IF-TRUE], [IF-FALSE])
379+
# -----------------------------------
380+
m4_define([b4_glr_cc_if],
381+
[m4_if(b4_skeleton, ["glr.cc"], $@)])
382+
383+
377384
## --------- ##
378385
## Symbols. ##
379386
## --------- ##
380387

381-
# In order to unify the handling of the various aspects of symbols
382-
# (tag, type_name, whether terminal, etc.), bison.exe defines one
383-
# macro per (token, field), where field can has_id, id, etc.: see
384-
# src/output.c:prepare_symbols_definitions().
385-
#
386-
# The various FIELDS are:
388+
# For a description of the Symbol handling, see README.
387389
#
388-
# - has_id: 0 or 1.
389-
# Whether the symbol has an id.
390-
# - id: string
391-
# If has_id, the id. Guaranteed to be usable as a C identifier.
392-
# Prefixed by api.token.prefix if defined.
393-
# - tag: string.
394-
# A representat of the symbol. Can be 'foo', 'foo.id', '"foo"' etc.
395-
# - user_number: integer
396-
# The assigned (external) number as used by yylex.
397-
# - is_token: 0 or 1
398-
# Whether this is a terminal symbol.
399-
# - number: integer
400-
# The internalized number (used after yytranslate).
401-
# - has_type: 0, 1
402-
# Whether has a semantic value.
403-
# - type_tag: string
404-
# When api.value.type=union, the generated name for the union member.
405-
# yytype_INT etc. for symbols that has_id, otherwise yytype_1 etc.
406-
# - type
407-
# If it has a semantic value, its type tag, or, if variant are used,
408-
# its type.
409-
# In the case of api.value.type=union, type is the real type (e.g. int).
410-
# - has_printer: 0, 1
411-
# - printer: string
412-
# - printer_file: string
413-
# - printer_line: integer
414-
# If the symbol has a printer, everything about it.
415-
# - has_destructor, destructor, destructor_file, destructor_line
416-
# Likewise.
417-
#
418-
# The following macros provide access to these values.
390+
# The following macros provide access to symbol related values.
391+
392+
# __b4_symbol(NUM, FIELD)
393+
# -----------------------
394+
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
395+
# undefined.
396+
m4_define([__b4_symbol],
397+
[m4_indir([b4_symbol($1, $2)])])
398+
419399

420400
# _b4_symbol(NUM, FIELD)
421401
# ----------------------
422-
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
402+
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
423403
# undefined.
424404
m4_define([_b4_symbol],
425-
[m4_indir([b4_symbol($1, $2)])])
405+
[m4_ifdef([b4_symbol($1, number)],
406+
[__b4_symbol(m4_indir([b4_symbol($1, number)]), $2)],
407+
[__b4_symbol([$1], [$2])])])
408+
426409

427410

428411
# b4_symbol(NUM, FIELD)
429412
# ---------------------
430-
# Recover a FIELD about symbol #NUM. Thanks to m4_indir, fails if
413+
# Recover a FIELD about symbol #NUM (or "orig NUM"). Fails if
431414
# undefined. If FIELD = id, prepend the token prefix.
432415
m4_define([b4_symbol],
433416
[m4_case([$2],
@@ -468,8 +451,8 @@ m4_define([b4_symbol_action_location],
468451
m4_define([b4_symbol_action],
469452
[b4_symbol_if([$1], [has_$2],
470453
[b4_dollar_pushdef([(*yyvaluep)],
471-
b4_symbol_if([$1], [has_type],
472-
[m4_dquote(b4_symbol([$1], [type]))]),
454+
[$1],
455+
[],
473456
[(*yylocationp)])dnl
474457
_b4_symbol_case([$1])[]dnl
475458
b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])
@@ -497,7 +480,7 @@ m4_define([b4_symbol_actions],
497480
m4_ifval(m4_defn([b4_actions_]),
498481
[switch (m4_default([$2], [yytype]))
499482
{
500-
m4_defn([b4_actions_])
483+
m4_defn([b4_actions_])[]dnl
501484
default:
502485
break;
503486
}dnl
@@ -508,7 +491,9 @@ m4_popdef([b4_actions_])dnl
508491

509492
# _b4_symbol_case(SYMBOL-NUM)
510493
# ---------------------------
511-
# Issue a "case NUM" for SYMBOL-NUM.
494+
# Issue a "case NUM" for SYMBOL-NUM. Ends with its EOL to make it
495+
# easier to use with m4_map, but then, use []dnl to suppress the last
496+
# one.
512497
m4_define([_b4_symbol_case],
513498
[case b4_symbol([$1], [number]): b4_symbol_tag_comment([$1])])
514499
])
@@ -569,7 +554,7 @@ m4_define([b4_token_format],
569554
# Run actions for the symbol NUMS that all have the same type-name.
570555
# Skip NUMS that have no type-name.
571556
#
572-
# To specify the action to run, define b4_dollar_dollar(NUMBER,
557+
# To specify the action to run, define b4_dollar_dollar(SYMBOL-NUM,
573558
# TAG, TYPE).
574559
m4_define([_b4_type_action],
575560
[b4_symbol_if([$1], [has_type],

msys2/usr/share/bison/c++-skel.m4 renamed to msys2/usr/share/bison/skeletons/c++-skel.m4

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# C++ skeleton dispatching for Bison.
44

5-
# Copyright (C) 2006-2007, 2009-2015, 2018 Free Software Foundation,
6-
# Inc.
5+
# Copyright (C) 2006-2007, 2009-2015, 2018-2019 Free Software
6+
# Foundation, Inc.
77

88
# This program is free software: you can redistribute it and/or modify
99
# it under the terms of the GNU General Public License as published by
@@ -18,10 +18,10 @@
1818
# You should have received a copy of the GNU General Public License
1919
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2020

21-
b4_glr_if( [m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])])
22-
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_pkgdatadir/[glr.cc]])])
21+
b4_glr_if( [m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
22+
b4_nondeterministic_if([m4_define([b4_used_skeleton], [b4_skeletonsdir/[glr.cc]])])
2323

24-
m4_define_default([b4_used_skeleton], [b4_pkgdatadir/[lalr1.cc]])
24+
m4_define_default([b4_used_skeleton], [b4_skeletonsdir/[lalr1.cc]])
2525
m4_define_default([b4_skeleton], ["b4_basename(b4_used_skeleton)"])
2626

2727
m4_include(b4_used_skeleton)

0 commit comments

Comments
 (0)