Re: Happy / Alex description for Haskell2010

2018-10-25 Thread Sam Halliday
Thanks Doaitse,

I'm not looking for a parser that I can run, I am mostly interested in
the codified BNF, to study, and adapt.

I'll take a look at the Utrecht Haskell Compiler in any case, as it
sounds interesting... do you mean this file?
https://github.com/uhc/uhc/blob/master/EHC/src/helium/Parser/Parser.hs

On Thu, 25 Oct 2018 at 20:11, Doaitse Swierstra  wrote:
>
> I do not know why you do need a Haskell parser, but the Utrecht Haskell 
> Compiler contains a combinator based Haskell parser (using the uulib package, 
> supporting the offside rule) which might serve your needs. It can easily be 
> adapted if needed.
>
>  Doaitse Swierstra
>
>
>
> > Op 25 okt. 2018, om 20:31  heeft Sam Halliday  het 
> > volgende geschreven:
> >
> > Hello all,
> >
> > Is there a Happy / Alex file describing Haskell2010?
> >
> > I can see the versions in the ghc source tree, but of course they
> > support all the ghc extensions. The link to the hsparser page [1] in
> > the Happy documentation doesn't seem to exist anymore.
> >
> > I would also love to hear if there is a Bison definition.
> >
> > Best regards,
> > Sam
> >
> > [1] 
> > http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne/haskell_libs/hsparser.html
> > ___
> > Glasgow-haskell-users mailing list
> > Glasgow-haskell-users@haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
>
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


Re: Happy / Alex description for Haskell2010

2018-10-25 Thread Doaitse Swierstra
I do not know why you do need a Haskell parser, but the Utrecht Haskell 
Compiler contains a combinator based Haskell parser (using the uulib package, 
supporting the offside rule) which might serve your needs. It can easily be 
adapted if needed.

 Doaitse Swierstra



> Op 25 okt. 2018, om 20:31  heeft Sam Halliday  het 
> volgende geschreven:
> 
> Hello all,
> 
> Is there a Happy / Alex file describing Haskell2010?
> 
> I can see the versions in the ghc source tree, but of course they
> support all the ghc extensions. The link to the hsparser page [1] in
> the Happy documentation doesn't seem to exist anymore.
> 
> I would also love to hear if there is a Bison definition.
> 
> Best regards,
> Sam
> 
> [1] 
> http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne/haskell_libs/hsparser.html
> ___
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


Happy / Alex description for Haskell2010

2018-10-25 Thread Sam Halliday
Hello all,

Is there a Happy / Alex file describing Haskell2010?

I can see the versions in the ghc source tree, but of course they
support all the ghc extensions. The link to the hsparser page [1] in
the Happy documentation doesn't seem to exist anymore.

I would also love to hear if there is a Bison definition.

Best regards,
Sam

[1] 
http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne/haskell_libs/hsparser.html
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


Re: [Haskell-cafe] happy + alex parsing question

2011-02-17 Thread Roman Dzvinkovsky
Thanks,
adding state to lexer seems to be the way to go.

2011/2/16 Mihai Maruseac mihai.marus...@gmail.com

 On Wed, Feb 16, 2011 at 5:31 PM, Roman Dzvinkovsky romand...@gmail.com
 wrote:
  Hi,
 
  using alex+happy, how could I parse lines like these?
 
  mr username says message\n
 
  where both username and message may contain arbitrary characters
 (except
  eol)?
 
  If I make lexer tokens
 
  mr { T_Mr }
   says  { T_Says }
  \r?\n{ T_Eol }
  .{ T_Char $$ }
 
  and parser
 
  'mr '{ T_Mr }
  ' says ' { T_Says }
  eol  { T_Eol }
  char { T_Char }
 
  ...
 
  line :: { (String, String) }
   : 'mr ' string ' says ' string eol { ($2, $4) }
 
  string :: { String }
 : char{ [ $1 ] }
 | char string { $1 : $2 }
 
  then I get error when username or message contain mr 
  substrings, because parser encounters T_Mr token.
 
  Workaround is mention all small tokens in my string definition:
 
  string :: { String }
 : { [] }
 | 'mr ' string{ mr ++ $2 }
 | ' says ' string {  says  ++ $2 }
 | char string { $1 : $2 }
 
  but that is weird and I'm sure there is a better way.
 

 I don't have an implementation right now but you could try having some
 states or user data in which to record whether you have already parsed
 the 'mr ' part (etc..) Guess you could use monadUserData parser (just
 like I've found after a night without sleep [1] - solved now).

 --
 Mihai

 [1]:
 http://www.haskell.org/pipermail/haskell-cafe/2011-February/089330.html

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] happy + alex parsing question

2011-02-16 Thread Roman Dzvinkovsky
Hi,

using alex+happy, how could I parse lines like these?

 mr username says message\n

where both username and message may contain arbitrary characters (except
eol)?

If I make lexer tokens

 mr { T_Mr }
  says  { T_Says }
 \r?\n{ T_Eol }
 .{ T_Char $$ }

and parser

 'mr '{ T_Mr }
 ' says ' { T_Says }
 eol  { T_Eol }
 char { T_Char }

...

 line :: { (String, String) }
  : 'mr ' string ' says ' string eol { ($2, $4) }

 string :: { String }
: char{ [ $1 ] }
| char string { $1 : $2 }

then I get error when username or message contain mr 
substrings, because parser encounters T_Mr token.

Workaround is mention all small tokens in my string definition:

 string :: { String }
: { [] }
| 'mr ' string{ mr ++ $2 }
| ' says ' string {  says  ++ $2 }
| char string { $1 : $2 }

but that is weird and I'm sure there is a better way.

Thanks for advance,
Roman.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] happy + alex parsing question

2011-02-16 Thread Mihai Maruseac
On Wed, Feb 16, 2011 at 5:31 PM, Roman Dzvinkovsky romand...@gmail.com wrote:
 Hi,

 using alex+happy, how could I parse lines like these?

 mr username says message\n

 where both username and message may contain arbitrary characters (except
 eol)?

 If I make lexer tokens

 mr     { T_Mr }
  says  { T_Says }
 \r?\n    { T_Eol }
 .    { T_Char $$ }

 and parser

 'mr '    { T_Mr }
 ' says ' { T_Says }
 eol  { T_Eol }
 char { T_Char }

 ...

 line :: { (String, String) }
  : 'mr ' string ' says ' string eol { ($2, $4) }

 string :: { String }
    : char    { [ $1 ] }
    | char string { $1 : $2 }

 then I get error when username or message contain mr 
 substrings, because parser encounters T_Mr token.

 Workaround is mention all small tokens in my string definition:

 string :: { String }
    : { [] }
    | 'mr ' string    { mr     ++ $2 }
    | ' says ' string {  says  ++ $2 }
    | char string { $1 : $2 }

 but that is weird and I'm sure there is a better way.


I don't have an implementation right now but you could try having some
states or user data in which to record whether you have already parsed
the 'mr ' part (etc..) Guess you could use monadUserData parser (just
like I've found after a night without sleep [1] - solved now).

-- 
Mihai

[1]: http://www.haskell.org/pipermail/haskell-cafe/2011-February/089330.html

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] happy + alex parsing question

2011-02-16 Thread Stephen Tetley
On 16 February 2011 15:31, Roman Dzvinkovsky romand...@gmail.com wrote:


 using alex+happy, how could I parse lines like these?

 mr username says message\n

Alex has both user states and powerful regex and character set
operators (complement and set difference), that said, LR parsing plus
Alex lexing doesn't look like a satisfactory match for the input
format. I'd either go with regexps or write a hand-coded lexer and do
all the work the work in the lexer as the result just needs to be a
list of pairs [(String,String)].

If you are using this input format as a test-case for learning how to
use Happy+Alex, it isn't a good start point. You'd be better choosing
something with more structure and less problematic tokens such as an
expression parser.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [GHC] #2495: Source dist should include Happy/Alex-generated sources

2008-09-27 Thread GHC
#2495: Source dist should include Happy/Alex-generated sources
--+-
 Reporter:  simonmar  |  Owner: 
 Type:  bug   | Status:  closed 
 Priority:  normal|  Milestone:  6.10.1 
Component:  Build System  |Version:  6.8.3  
 Severity:  normal| Resolution:  fixed  
 Keywords:| Difficulty:  Unknown
 Testcase:|   Architecture:  Unknown
   Os:  Unknown   |  
--+-
Changes (by igloo):

  * status:  new = closed
  * resolution:  = fixed

Comment:

 Now done.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2495#comment:1
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2495: Source dist should include Happy/Alex-generated sources

2008-08-07 Thread GHC
#2495: Source dist should include Happy/Alex-generated sources
-+--
Reporter:  simonmar  |   Owner: 
Type:  bug   |  Status:  new
Priority:  normal|   Milestone:  6.10.1 
   Component:  Build System  | Version:  6.8.3  
Severity:  normal|Keywords: 
  Difficulty:  Unknown   |Testcase: 
Architecture:  Unknown   |  Os:  Unknown
-+--
 For 6.10.1 we need to make sure that the source dist contains the
 generated files, so that building from the source tarball doesn't require
 Happy or Alex.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2495
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[Haskell] help with happy/alex

2006-11-22 Thread robert bauer
Hi,

I have a .y and .x file.  The alex -g _.x gives me a .hs file and happy -g -a 
-c _.y gives me a .hs file.
I then use ghc -c alex.hs to get a a .o and a .hi file.  This works great.
Unfortunately
ghc -c happy.y doesn't work -- it says that it the module name for the lexer 
doesn't match.  I've attached the
.y and .x files.

Also,  I cannot figure out what I need to do in the parser to call the lexer 
and I don't know how to kick start the
parser -- I have no clue what to put in third, main.hs, module.

Any help would be appreciated.



TVScriptParser.y
Description: Binary data


TVScriptLexer.x
Description: Binary data
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Happy Alex

2003-02-28 Thread Per Larsson
I have successfully used the the excellent haskell tools Happy and Alex in a 
couple of parsing projects, but I have failed when trying to  combine a 
monadic Happy grammar (using the %monad and %lexer directives) together with 
an Alex generated okenizer, nor are there any such examples in the Happy and 
Alex distributions. Have anyone tried this combination and can give me some 
advice or a simple example?

-- 
Per 


___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


RE: Happy Alex

2003-02-28 Thread Simon Marlow

 I have successfully used the the excellent haskell tools 
 Happy and Alex in a 
 couple of parsing projects, but I have failed when trying to  
 combine a 
 monadic Happy grammar (using the %monad and %lexer 
 directives) together with 
 an Alex generated okenizer, nor are there any such examples 
 in the Happy and 
 Alex distributions. Have anyone tried this combination and 
 can give me some 
 advice or a simple example?

I've been doing some work on Alex recently, and getting it to work
smoothly with Happy's monadic scheme is one of the goals.  I'll post
something when it's done, but if you want to have a look at the
work-in-progress look in the CVS tree, under fptools/happy/alex on the
branch simonm-hackery-branch.

The other things I'm doing include making Alex's syntax more lex-like
and Happy-like (mostly done), making the generated code more efficient
in terms of both space and time (mostly done), and adding support for
Unicode (not done, I'm still thinking about how best to do this - I have
some ideas but suggestions are welcome).

Cheers,
Simon
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell