Guest User

Untitled

a guest
Jul 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. The source
  2.  
  3. { 1 2 } 3
  4.  
  5. is not a valid sentence in the ECMAScript grammar, even with the automatic semicolon insertion rules. In contrast, the source
  6.  
  7. { 1
  8. 2 } 3
  9.  
  10. is also not a valid ECMAScript sentence, but is transformed by automatic semicolon insertion into the following:
  11.  
  12. { 1
  13. ;2 ;} 3;
  14.  
  15. which is a valid ECMAScript sentence.
  16.  
  17. The source
  18.  
  19. for (a; b
  20. )
  21.  
  22. is not a valid ECMAScript sentence and is not altered by automatic semicolon insertion because the semicolon is needed for the header of a for statement. Automatic semicolon insertion never inserts one of the two semicolons in the header of a for statement.
  23.  
  24. The source
  25.  
  26. return
  27. a + b
  28.  
  29. is transformed by automatic semicolon insertion into the following:
  30.  
  31. return;
  32. a + b;
  33.  
  34. NOTE The expression a + b is not treated as a value to be returned by the return statement, because a LineTerminator separates it from the token return.
  35.  
  36. The source
  37.  
  38. a = b
  39. ++c
  40.  
  41. is transformed by automatic semicolon insertion into the following:
  42.  
  43. a = b;
  44. ++c;
  45.  
  46. NOTE The token ++ is not treated as a postfix operator applying to the variable b, because a LineTerminator occurs between b and ++.
  47.  
  48. The source
  49.  
  50. if (a > b)
  51. else c = d
  52.  
  53. is not a valid ECMAScript sentence and is not altered by automatic semicolon insertion before the else token, even though no production of the grammar applies at that point, because an automatically inserted semicolon would then be parsed as an empty statement.
  54.  
  55. The source
  56.  
  57. a = b + c
  58. (d + e).print()
  59.  
  60. is not transformed by automatic semicolon insertion, because the parenthesised expression that begins the second line can be interpreted as an argument list for a function call:
  61.  
  62. a = b + c(d + e).print()
Add Comment
Please, Sign In to add comment