altoviso / bdParse

a JavaScript LL(1) parser in JavaScript
http://bdframework.org/bdParse/index.html
Other
14 stars 3 forks source link

No difference in AST between for (i in foo) and for (var i in foo) #2

Open csnover opened 13 years ago

csnover commented 13 years ago

Both are output with the same AST:

[ [ 'for (i in foo){}' ],
  { type: { value: 'asnRoot' },
    comment: undefined,
    location: { startLine: 0, startCol: 0, endLine: 0, endCol: 16 },
    children: 
     [ { type: { value: 'asnForIn' },
         comment: undefined,
         location: { startLine: 0, startCol: 0, endLine: 0, endCol: 16 },
         children: 
          [ { type: { value: 'tName', isExprAtom: true },
              value: 'i',
              location: { startLine: 0, startCol: 5, endLine: 0, endCol: 6 },
              newlineBefore: false,
              comment: undefined },
            { type: { value: 'asnName' },
              comment: undefined,
              location: { startLine: 0, startCol: 10, endLine: 0, endCol: 13 },
              children: 
               { type: { value: 'tName', isExprAtom: true },
                 value: 'foo',
                 location: { startLine: 0, startCol: 10, endLine: 0, endCol: 13 },
                 newlineBefore: false,
                 comment: undefined },
              parent: [Circular] },
            { type: { value: 'asnBlock' },
              comment: undefined,
              location: { startLine: 0, startCol: 14, endLine: 0, endCol: 16 },
              children: [],
              parent: [Circular] } ],
         parent: [Circular] } ] } ]

vs.

[ [ 'for (var i in foo){}' ],
  { type: { value: 'asnRoot' },
    comment: undefined,
    location: { startLine: 0, startCol: 0, endLine: 0, endCol: 20 },
    children: 
     [ { type: { value: 'asnForIn' },
         comment: undefined,
         location: { startLine: 0, startCol: 0, endLine: 0, endCol: 20 },
         children: 
          [ { type: { value: 'tName', isExprAtom: true },
              value: 'i',
              location: { startLine: 0, startCol: 9, endLine: 0, endCol: 10 },
              newlineBefore: false,
              comment: undefined },
            { type: { value: 'asnName' },
              comment: undefined,
              location: { startLine: 0, startCol: 14, endLine: 0, endCol: 17 },
              children: 
               { type: { value: 'tName', isExprAtom: true },
                 value: 'foo',
                 location: { startLine: 0, startCol: 14, endLine: 0, endCol: 17 },
                 newlineBefore: false,
                 comment: undefined },
              parent: [Circular] },
            { type: { value: 'asnBlock' },
              comment: undefined,
              location: { startLine: 0, startCol: 18, endLine: 0, endCol: 20 },
              children: [],
              parent: [Circular] } ],
         parent: [Circular] } ] } ]