spend a lot of time with alex generated module

hat-trans spends a lot of time (really a lot of time) in generate module from a module generated by alex. The original module has 330 lines of code and module generated by hat-trans has 40700 !!. Somebody knows what's happening? thanks -- View this message in context: http://www.nabble.com/spend-a-lot-of-time-with-alex-generated-module-tf20813... Sent from the Haskell - Hat forum at Nabble.com.

kgu
hat-trans spends a lot of time (really a lot of time) in generate module from a module generated by alex. The original module has 330 lines of code and module generated by hat-trans has 40700 !!.
It is well-known that giving a machine-generated input to any compiler-like tool is the best way to show up its weaknesses! I suppose the output from Alex is very different from the kind of code that a human would write. Since Alex creates essentially a table-driven lexical analyser, it is possible that a large static description of the tables is where hat-trans is spending lots of time. Also, if the Alex-generated code is deeply nested, hat-trans may spend too much time trying to pretty-print its output within 80 columns, when really the formatting will not fit nicely into such a small width. Just some ideas. If you want to send a copy of the original Alex specification, we may be able to investigate further. Regards, Malcolm

Malcolm Wallace wrote:
kgu
wrote: hat-trans spends a lot of time (really a lot of time) in generate module from a module generated by alex. The original module has 330 lines of code and module generated by hat-trans has 40700 !!.
It is well-known that giving a machine-generated input to any compiler-like tool is the best way to show up its weaknesses! I suppose the output from Alex is very different from the kind of code that a human would write. Since Alex creates essentially a table-driven lexical analyser, it is possible that a large static description of the tables is where hat-trans is spending lots of time. Also, if the Alex-generated code is deeply nested, hat-trans may spend too much time trying to pretty-print its output within 80 columns, when really the formatting will not fit nicely into such a small width.
Just some ideas. If you want to send a copy of the original Alex specification, we may be able to investigate further.
Regards, Malcolm _______________________________________________ Hat mailing list Hat@haskell.org http://www.haskell.org/mailman/listinfo/hat
I attach original specification.It's a very simple lexer specification. I had some problem to compile module generated by hat-trans , it spends a lot of time too and it did not compile. Thanks for your help and your job, i'm developing a compiler and hat is a really useful tool for me, it's a great tool! Thanks, Iván { module Lexer (Token(..), alexScanTokens) where } %wrapper "basic" $digit = 0-9 -- digits $alpha = [a-zA-Z] -- alphabetic characters tokens :- $white+ ; "--".* ; \. { \s -> TPUNTO } \) { \s -> TPARDER } \( { \s -> TPARIZQ } \[ { \s -> TCORIZQ } \] { \s -> TCORDER } \| { \s -> TPIPE } = { \s -> TIGUAL } != { \s -> TDISTINTO } "->" { \s -> TFLECHA }
{ \s -> TMAYOR } = { \s -> TMAYORIGUAL }
\< { \s -> TMENOR } \<= { \s -> TMENORIGUAL } \+ { \s -> TMAS } \- { \s -> TMENOS } \* { \s -> TPOR } \/ { \s -> TBARRA } & { \s -> TAND } \^ { \s -> TTILDE } \, { \s -> TCOMA } \; { \s -> TPUNTOCOMA } := { \s -> TDOSIGUAL } :: { \s -> TCUATROPUNTOS } \;\; { \s -> TDOSPUNTOCOMA } : { \s -> TDOSPUNTOS } [] { \s -> TCORCHETES } null { \s -> TNULL } Int { \s -> TINT } String { \s -> TSTRING } in { \s -> TIN } let { \s -> TLET } rec { \s -> TISREC } case { \s -> TCASE } of { \s -> TOF } if { \s -> TIF } then { \s -> TTHEN } else { \s -> TELSE } "\""['A'-'Z''a'-'z''0'-'9''_'' ']* "\"" { \s -> TCADENA s } $digit+ { \s -> TENTERO (read s) } $alpha [$alpha $digit \_ \']* { \s -> TVAR s } eof { \s -> TEOF } { data Token = TBLANCO | TCOMMENT | TPUNTO | TPARIZQ | TPARDER | TCORIZQ | TCORDER | TPIPE | TAMBER | TIGUAL | TDISTINTO | TFLECHA | TMAYOR | TMAYORIGUAL | TMENOR | TMENORIGUAL | TMAS | TMENOS | TPOR | TBARRA | TTILDE | TCOMA | TPUNTOCOMA | TDOSIGUAL | TCUATROPUNTOS | TDOSPUNTOCOMA | TDOSPUNTOS | TCORCHETES | TNULL | TAND | TINT | TSTRING | TIN | TLET | TISREC | TCASE | TOF | TIF | TTHEN | TELSE | TCADENA String | TENTERO Int | TVAR String | TEOF deriving (Eq,Show) }
participants (3)
-
ivan gomez rodriguez
-
kgu
-
Malcolm Wallace