Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let ass = p.and(['name', p.e('='), 'expression'], {'id': 'assignment', 'on_match': 'Assignment'})
- call p.and(['term', p.maybe_many(p.or(['add', 'subtract']))], {'id': 'expression', 'on_match': 'Expression'})
- call p.and([p.e('-'), 'term'], {'id': 'subtract', 'on_match': 'Op'})
- call p.and([p.e('+'), 'term'], {'id': 'add', 'on_match': 'Op'})
- call p.and(['factor', p.maybe_many(p.or(['multiply', 'divide']))], {'id': 'term', 'on_match': 'Term'})
- call p.and([p.e('/'), 'factor'], {'id': 'divide', 'on_match': 'Op'})
- call p.and([p.e('*'), 'factor'], {'id': 'multiply', 'on_match': 'Op'})
- call p.or(['number', p.and([p.e('('), 'expression', p.e(')')]), 'ident'], {'id': 'factor', 'on_match': 'Factor'})
- call p.or(['func', 'name'], {'id': 'ident', 'on_match': 'Ident'})
- call p.and(['name', p.and([p.e('('), p.e(')')])], {'id': 'func', 'on_match': 'Func'})
- call p.and(['alpha', p.maybe_many('alphanum')], {'id': 'name', 'on_match': 'Name'})
- call p.e('[a-zA-Z_]', {'id': 'alpha'})
- call p.or(['alpha', 'digit'], {'id': 'alphanum'})
- call p.many('digit', {'id': 'number', 'on_match': 'Number'})
- call p.e('[0-9]', {'id': 'digit'})
Advertisement
Add Comment
Please, Sign In to add comment