Mono and Generics

Installed the mono beta without a hitch. Had no idea where it ended up in (thank god for OSX HD indexing and searching). Eventually found it in /opt/local/bin (didn’t even know that directory existed). Tried to compile some of my code and got:

cyrusn@Foo ~> /opt/local/bin/mcs foo.cs
syntax error, got token `OP_LT', expecting OPEN_BRACE COLON
foo.cs(1) error CS1041: Identifier expected
Mono.CSharp.yyParser.yyException: irrecoverable syntax error
in <0x00b00> Mono.CSharp.CSharpParser:yyparse (Mono.CSharp.yyParser.yyInput)
in <0x000b4> Mono.CSharp.CSharpParser:parse ()

foo.cs(1) error CS8025: Parsing error
Compilation failed: 2 error(s), 0 warnings

This amused me greatly. Mostly because I wrote a LALR parser generator in C# and used it to parse C# and this kind of error message was nearly identical to the unfriendly error messages I would present. Luckily mcs is intended to be used by programmers who can most likely infer that OP_LT corresponds to < corresponds to some error in your code. However, i do think it would be good for the parser to output the line/column where the error occured to make tracking down the offending code easier.

It would also be great if the mono teamed looked into some of the excellent work done in automatic LALR parser recovery to make the parser better able to recover after these issues. Of course, these are “nice to haves” and not in any way requirements.

Comments (6)

  1. Mollyfud says:

    Mono being open source, I am sure the case is:

    They welcome your submission!



  2. NoName says:

    To compile generics code, don’t you use gmcs instead of mcs?

  3. Yes. And I realized that later. You can see the error i got using gmcs in

  4. Misho says:

    Your blog is very interesint