| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A simple command-line compiler for JTL (JSON Traversal Language). | 5 // A simple command-line compiler for JTL (JSON Traversal Language). |
| 6 // | 6 // |
| 7 // Translates rules from a text-based, human-readable format to an easy-to-parse | 7 // Translates rules from a text-based, human-readable format to an easy-to-parse |
| 8 // byte-code format, which then can be interpreted by JtlInterpreter. | 8 // byte-code format, which then can be interpreted by JtlInterpreter. |
| 9 // | 9 // |
| 10 // Example usage: | 10 // Example usage: |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 std::cerr << " Line number: " << (error.line_number + 1) << std::endl; | 93 std::cerr << " Line number: " << (error.line_number + 1) << std::endl; |
| 94 std::cerr << " Context: " << (error.context.size() > 63 | 94 std::cerr << " Context: " << (error.context.size() > 63 |
| 95 ? error.context.substr(0, 60) + "..." | 95 ? error.context.substr(0, 60) + "..." |
| 96 : error.context) << std::endl; | 96 : error.context) << std::endl; |
| 97 return -2; | 97 return -2; |
| 98 } | 98 } |
| 99 | 99 |
| 100 base::FilePath bytecode_path = | 100 base::FilePath bytecode_path = |
| 101 MakeAbsoluteFilePath(cmd_line->GetSwitchValuePath(kOutputPath)); | 101 MakeAbsoluteFilePath(cmd_line->GetSwitchValuePath(kOutputPath)); |
| 102 int bytes_written = | 102 int bytes_written = |
| 103 file_util::WriteFile(cmd_line->GetSwitchValuePath(kOutputPath), | 103 base::WriteFile(cmd_line->GetSwitchValuePath(kOutputPath), |
| 104 bytecode.data(), | 104 bytecode.data(), |
| 105 static_cast<int>(bytecode.size())); | 105 static_cast<int>(bytecode.size())); |
| 106 if (bytes_written != static_cast<int>(bytecode.size())) { | 106 if (bytes_written != static_cast<int>(bytecode.size())) { |
| 107 std::cerr << "ERROR: Cannot write output file." << std::endl; | 107 std::cerr << "ERROR: Cannot write output file." << std::endl; |
| 108 return -3; | 108 return -3; |
| 109 } | 109 } |
| 110 | 110 |
| 111 return 0; | 111 return 0; |
| 112 } | 112 } |
| OLD | NEW |