Notices
Results 1 to 2 of 2

Thread: Syntax Directed Translation

  1. #1 Syntax Directed Translation 
    New Member
    Join Date
    Mar 2014
    Posts
    3
    Hi there,

    I indeed asked in another topic something about Syntax Analysis (parsing). But I believe that this needs a separate topic, just to make things more organized.

    I have a few questions regarding compiler construction, and specifically Syntax Directed Translation. I'm really struggling to understand this part.

    Question 1:
    From my understanding, Syntax Directed Translation is semantic analysis. It adds rules and actions, but does not perform these actions.
    The rules/actions are rather checked during type checking, but then my real question: isn't type checking part of the ''semantic analysis''? (which is again from my understanding, semantic analysis?)

    In what order are these things happening now?
    Lexical Analysis -> Syntax Analysis -> Semantic Analysis (=Syntax Directed Translation?) -> Intermediate Code Generation -> etc.
    Is this the correct order? Where is type checking then performed? Because the dragonbook explains type checking during the intermediate code generation phase.
    So is type checking during the intermediate code generation or semantic analysis?

    Question 2:
    I understand that you can combine phases of the compiler. If you combine the parts of Syntax Analysis and Semantic Analysis. Would you first create an AST and then traverse a second time to apply semantic checks? And by checks I mean: does it just apply rules but check them in a later phase (intermediate code generation; type checking?)

    Thank you!


    Reply With Quote  
     

  2.  
     

  3. #2  
    Forum Radioactive Isotope MagiMaster's Avatar
    Join Date
    Jul 2006
    Posts
    3,440
    If I've understood correctly, syntax directed translation is neither syntax analysis nor semantic analysis. It's a series of actions attached to the syntax analysis phase generally used to produce some intermediate code (or some other interpretation of the original). There's no analysis going on during those actions. (A typical action would be to output a line or few of intermediate code.) Static type checking might could be considered syntax analysis (int a = "Hello"; is a syntax error in many languages). Dynamic type checking would be semantic analysis, which might not happen until run time.

    Most compilers do very little semantic analysis because semantics are "what you mean" and it's not the compiler's job to mess with or second guess that.


    Reply With Quote  
     

Similar Threads

  1. Syntax Analysis parsing methods questions
    By Achy in forum Computer Science
    Replies: 3
    Last Post: March 31st, 2014, 03:47 PM
  2. translation help
    By fiveworlds in forum Computer Science
    Replies: 3
    Last Post: September 18th, 2012, 04:13 PM
  3. Dr Syntax
    By marcusclayman in forum Site Feedback
    Replies: 14
    Last Post: December 10th, 2009, 12:02 PM
  4. OBJ-C Syntax Question
    By collred in forum Computer Science
    Replies: 1
    Last Post: December 7th, 2009, 08:02 PM
  5. Syntax tree's to Finitie state machines..?
    By blackout83 in forum Computer Science
    Replies: 1
    Last Post: May 24th, 2009, 06:21 AM
Bookmarks
Bookmarks
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •