Hi, I'm trying to build a simple lexer/parser with Alex/Happy in Haskell, and I would like to keep some localisation information from the text file into my final AST.
I managed to build a lexer using Alex that build a list of Tokens with localisation:
data Token = Token AlexPosn Foo Bar
lexer :: String -> [Token]
in my Happy file, when declaring the %token part, I can declare what are the semantic part of the token with the $$ symbol
%token FOO { Token _ $$ _ }
and in the parsing rule, the $i will refer to this $$.
foo_list: FOO { [$1] }
| foo_list FOO { $2 : $1 }
Is there a way to refer to the AlexPosn part and to the Foo part of the FOO token ? Right now I only know how do refer to only one of them. I can find information on a way to ''add several $$'', and to refer to them afterwards.
Is there a way to do so ?
V.