1#!/usr/bin/env python
2# Copyright 2014 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Simple testing utility to just run the mojom parser."""
7
8
9import os.path
10import sys
11
12sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)),
13                                os.path.pardir, os.path.pardir))
14
15from mojom.parse.parser import Parse, ParseError
16
17
18def main(argv):
19  if len(argv) < 2:
20    print "usage: %s filename" % argv[0]
21    return 0
22
23  for filename in argv[1:]:
24    with open(filename) as f:
25      print "%s:" % filename
26      try:
27        print Parse(f.read(), filename)
28      except ParseError, e:
29        print e
30        return 1
31
32  return 0
33
34
35if __name__ == '__main__':
36  sys.exit(main(sys.argv))
37