Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define and position token #378

Open
andreasabel opened this issue Sep 1, 2021 · 1 comment
Open

define and position token #378

andreasabel opened this issue Sep 1, 2021 · 1 comment
Labels
AST Concerning the generated abstract syntax define Issue with define pragma Haskell/Functor Concerning the Haskell backend with --functor position Concerning position information in parsed AST token Concerning token categories.

Comments

@andreasabel
Copy link
Member

This fails in some backends:

CNil.     Chars ::=                 ;
cSg.      Chars ::= Char            ;
CSnoc.    Chars ::= Chars Dot Char  ;

define    cSg c = CSnoc CNil (Dot ".") c;

position token     Dot '.'          ;
@andreasabel andreasabel added AST Concerning the generated abstract syntax define Issue with define pragma Haskell/Functor Concerning the Haskell backend with --functor position Concerning position information in parsed AST token Concerning token categories. labels Sep 1, 2021
@andreasabel
Copy link
Member Author

andreasabel commented Oct 25, 2021

Suggested fix:

  1. If the AST is not aware of positions, just put an invalid position there (Dot (0,0) ".").
    cSg :: Char -> Chars
    cSg c = CSnoc CNil (Dot ((0,0), ".")) c
    
    newtype Dot = Dot ((C.Int, C.Int), String)
  2. In Haskell/Functor, make position tokens polymorphic.
    cSg :: a -> Char -> Chars' a
    cSg a c = CSnoc a (CNil a) (Dot (a, ".")) c
    
    type Dot = Dot' BNFC'Position
    newtype Dot' a = Dot (a, String)
      deriving (C.Eq, C.Ord, C.Show, C.Read, C.Functor, C.Foldable, C.Traversable)

@andreasabel andreasabel added this to the 2.9.4 milestone Oct 25, 2021
@andreasabel andreasabel modified the milestones: 2.9.4, 2.9.5 Feb 8, 2022
@andreasabel andreasabel removed this from the 2.9.5 milestone Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AST Concerning the generated abstract syntax define Issue with define pragma Haskell/Functor Concerning the Haskell backend with --functor position Concerning position information in parsed AST token Concerning token categories.
Projects
None yet
Development

No branches or pull requests

1 participant