c - Is there rule of thumb for catching errors in Lex/Yacc parsing? -


Should we parse the language of general purpose as quickly as possible (in Lex) or where it is more convenient and we Give more information (YACCP)? How do different languages ​​solve this problem?

More complex error in general, code to emphasize more complex error Lexers and parsons are quite simple (in practice), and therefore ordinary errors are ripe.
  • Li> Ol>

    Complex errors are usually on various translations at runtime or elsewhere in compiled time. Examples might include reference to a function / method that does not exist. Tons of closed scope / binding, object and reference identifiers, logic validity, overloading, and many other language dependent materials.

    Anything beyond that very narrow token / syntax scope should be carried out (or handled) in those AST analyzes or intermediate code generation.

    Consider:

      ab (); Now ();  

    Both should make it for the object-oriented language via lexer / parser, where both statements are valid Is there an error?

    1. If your language is quite stable and the identifier can be resolved at compile time

    2. You compiler error To generate a runtime error, instead of running on the runtime , the ID can replace both the statements with the resolution code.

    The differences between resolution and semantics of runtime and compiled time can be subtle and widely in language to language.

    Errors are usually caught when they are known for errors and where you have more information, it changes between languages ​​and implementation.


    Comments

    Popular posts from this blog

    sql - dynamically varied number of conditions in the 'where' statement using LINQ -

    asp.net mvc - Dynamically Generated Ajax.BeginForm -

    Debug on symbian -