Skip to content

Instantly share code, notes, and snippets.

@jonschlinkert
Created October 21, 2016 22:15
Show Gist options
  • Save jonschlinkert/099c8914f56529f75bc757cc9e5e8e2a to your computer and use it in GitHub Desktop.
Save jonschlinkert/099c8914f56529f75bc757cc9e5e8e2a to your computer and use it in GitHub Desktop.
var mm = require('micromatch');
var ast = mm.parse('*(*(of*(a)x)z)', {sourcemap: true});
console.log(ast);
// results in:
{ type: 'root',
errors: [],
nodes:
[ { type: 'bos', val: '' },
{ type: 'paren',
prefix: '*',
nodes:
[ { type: 'paren.open', parsed: '', val: '*(' },
{ type: 'paren',
prefix: '*',
nodes:
[ { type: 'paren.open', parsed: '*(', val: '*(' },
{ type: 'text', val: 'of' },
{ type: 'paren',
prefix: '*',
nodes:
[ { type: 'paren.open', parsed: '*(*(of', val: '*(' },
{ type: 'text', val: 'a' },
{ type: 'paren.close',
rest: 'x)z)',
parsed: '*(*(of*(a',
val: ')',
prefix: '*' } ] },
{ type: 'text', val: 'x' },
{ type: 'paren.close',
rest: 'z)',
parsed: '*(*(of*(a)x',
val: ')',
prefix: '*' } ] },
{ type: 'text', val: 'z' },
{ type: 'paren.close',
rest: '',
parsed: '*(*(of*(a)x)z',
val: ')',
prefix: '*' } ] },
{ type: 'eos', val: '' } ],
input: '*(*(of*(a)x)z)' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment