From d09cc0f103a824596340d8bbaff38ecd795ba8b1 Mon Sep 17 00:00:00 2001
From: Adela Vais <adela.vais99@gmail.com>
Date: Fri, 18 Dec 2020 19:53:32 +0200
Subject: [PATCH for Dlang support 9/9] d: create alias Position for YYPosition

* data/skeletons/d.m4: Here.
* data/skeletons/lalr1.d: Adjust.
* doc/bison.texi: Document it.
* examples/d/calc/calc.y: Use it.
* tests/calc.at: Test it.
---
 data/skeletons/d.m4    |  3 ++-
 data/skeletons/lalr1.d |  4 ++--
 doc/bison.texi         | 16 ++++++++--------
 examples/d/calc/calc.y |  8 ++++----
 tests/calc.at          |  4 ++--
 5 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/data/skeletons/d.m4 b/data/skeletons/d.m4
index beb7d445..4e4d6aff 100644
--- a/data/skeletons/d.m4
+++ b/data/skeletons/d.m4
@@ -455,7 +455,8 @@ m4_define([b4_public_types_declare],
 [[
 alias Symbol = ]b4_parser_class[.Symbol;
 alias Value = ]b4_yystype[;]b4_locations_if([[
-alias Location = ]b4_location_type[;]])[
+alias Location = ]b4_location_type[;
+alias Position = ]b4_position_type[;]])[
 ]])
 
 # b4_symbol_type_define
diff --git a/data/skeletons/lalr1.d b/data/skeletons/lalr1.d
index 23ec07cc..4a2dff38 100644
--- a/data/skeletons/lalr1.d
+++ b/data/skeletons/lalr1.d
@@ -57,12 +57,12 @@ public interface Lexer
   /**
    * Method to retrieve the beginning position of the last scanned token.
    * @@return the position at which the last scanned token starts.  */
-  ]b4_position_type[ startPos ();
+  Position startPos ();
 
   /**
    * Method to retrieve the ending position of the last scanned token.
    * @@return the first position beyond the last scanned token.  */
-  ]b4_position_type[ endPos ();
+  Position endPos ();
 
 ]])[
   /**
diff --git a/doc/bison.texi b/doc/bison.texi
index 660a1aae..0eadc837 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -13847,16 +13847,16 @@ When the directive @code{%locations} is used, the D parser supports
 location tracking, see @ref{Tracking Locations}.  The position and
 the location structures are provided.
 
-@deftypeivar {Location} {YYPosition} begin
-@deftypeivarx {Location} {YYPosition} end
+@deftypeivar {Location} {Position} begin
+@deftypeivarx {Location} {Position} end
 The first, inclusive, position of the range, and the first beyond.
 @end deftypeivar
 
-@deftypeop {Constructor} {Location} {} this(@code{YYPosition} @var{loc})
+@deftypeop {Constructor} {Location} {} this(@code{Position} @var{loc})
 Create a @code{Location} denoting an empty range located at a given point.
 @end deftypeop
 
-@deftypeop {Constructor} {Location} {} this(@code{YYPosition} @var{begin}, @code{YYPosition} @var{end})
+@deftypeop {Constructor} {Location} {} this(@code{Position} @var{begin}, @code{Position} @var{end})
 Create a @code{Location} from the endpoints of the range.
 @end deftypeop
 
@@ -13918,7 +13918,7 @@ which also turns on verbose error messages.
 @deftypemethod {YYParser} {void} yyerror(@code{string} @var{msg})
 @deftypemethodx {YYParser} {void} yyerror(@code{Location} @var{loc}, @code{string} @var{msg})
 Print an error message using the @code{yyerror} method of the scanner
-instance in use. The @code{Location} and @code{YYPosition} parameters are
+instance in use. The @code{Location} and @code{Position} parameters are
 available only if location tracking is active.
 @end deftypemethod
 
@@ -14016,8 +14016,8 @@ Return the next token. The return value is of type @code{Symbol}, which
 binds together the @code{TokenKind}, the semantic value and the location.
 @end deftypemethod
 
-@deftypemethod {Lexer} {YYPosition} getStartPos()
-@deftypemethodx {Lexer} {YYPosition} getEndPos()
+@deftypemethod {Lexer} {Position} getStartPos()
+@deftypemethodx {Lexer} {Position} getEndPos()
 Return respectively the first position of the last token that @code{yylex}
 returned, and the first position beyond it.  These methods are not needed
 unless location tracking is active.
@@ -16465,7 +16465,7 @@ London, Department of Computer Science, TR-00-12 (December 2000).
 @c LocalWords: colorYellow rgbRed colorRed rgbBlue colorBlue rgbPurple Ddoc
 @c LocalWords: colorPurple ifhtml ifnothtml situ rcex MERCHANTABILITY Wnone
 @c LocalWords: diagError diagNotice diagWarning diagOff danglingElseCex
-@c LocalWords: Location YYPosition nonunifying
+@c LocalWords: Location Position nonunifying
 
 @c Local Variables:
 @c ispell-dictionary: "american"
diff --git a/examples/d/calc/calc.y b/examples/d/calc/calc.y
index d8f3967c..c4ff89a3 100644
--- a/examples/d/calc/calc.y
+++ b/examples/d/calc/calc.y
@@ -95,8 +95,8 @@ if (isInputRange!R && is(ElementType!R : dchar))
 
   this(R r) { input = r; }
 
-  YYPosition start;
-  YYPosition end;
+  Position start;
+  Position end;
   Location location;
 
   // Should be a local in main, shared with %parse-param.
@@ -170,12 +170,12 @@ if (isInputRange!R && is(ElementType!R : dchar))
     }
   }
 
-  YYPosition startPos() const
+  Position startPos() const
   {
     return start;
   }
 
-  YYPosition endPos() const
+  Position endPos() const
   {
     return end;
   }
diff --git a/tests/calc.at b/tests/calc.at
index ebd5768f..75b64e10 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -562,12 +562,12 @@ class CalcLexer(R) : Lexer
   Value semanticVal_;]AT_LOCATION_IF([[
   Location location;
 
-  public final @property YYPosition startPos()
+  public final @property Position startPos()
   {
     return location.begin;
   }
 
-  public final @property YYPosition endPos()
+  public final @property Position endPos()
   {
     return location.end;
   }
-- 
2.17.1

