Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Side by Side Diff: chrome/tools/profile_reset/jtl_compiler.h

Issue 24998003: Compiler for the JSON Traversal Language. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed linker errors on Win. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/tools/profile_reset/OWNERS ('k') | chrome/tools/profile_reset/jtl_compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_
6 #define CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11
12 // Compiles text-based JTL source code into JTL byte-code.
13 //
14 // For an overview of JTL (JSON Traversal Language), and the exhaustive list of
15 // instructions, please see "chrome/browser/profile_resetter/jtl_foundation.h".
16 //
17 // The text-based JTL syntax itself much resembles C/C++. A program consists of
18 // zero or more sentences. Each sentence is terminated by a semi-colon (;), and
19 // is composed of *one* or more operations, separated by forward slashes (/).
20 //
21 // Each operation resembles a C/C++ function call and consists of an instruction
22 // name, and an optional argument list, which takes Boolean values and/or string
23 // literals. The text-based instruction names are defined in "jtl_compiler.cc".
24 //
25 // Whitespace does not matter, except for inside string literals. C++-style,
26 // double-slash-introduced comments are also supported.
27 //
28 // Example source code:
29 //
30 // // Store "x"=true if path "foo.bar" is found.
31 // node("foo")/node("bar")/store_bool("x", true);
32 //
33 // // Store "y"="1" if the above value is set.
34 // compare_stored_bool("x", true, false)/store_hash("y", "1");
35 //
36 class JtlCompiler {
37 public:
38 struct CompileError {
39 enum ErrorCode {
40 ERROR_NONE,
41 MISMATCHED_DOUBLE_QUOTES,
42 PARSING_ERROR,
43 INVALID_OPERATION_NAME,
44 INVALID_ARGUMENT_COUNT,
45 INVALID_ARGUMENT_TYPE
46 };
47
48 CompileError() : line_number(0), error_code(ERROR_NONE) {}
49 CompileError(size_t line_number,
50 const std::string& context,
51 ErrorCode error_code)
52 : line_number(line_number), context(context), error_code(error_code) {}
53
54 size_t line_number; // 0-based.
55 std::string context;
56 ErrorCode error_code;
57 };
58
59 // Compiles text-based JTL source code contained in |source_code| into JTL
60 // byte-code to |output_bytecode|. Variable, node names, and string literals
61 // will be hashed using the seed in |hash_seed|.
62 // On success, returns true. Otherwise, returns false and fills |error| with
63 // more information (if it is non-NULL).
64 static bool Compile(const std::string& source_code,
65 const std::string& hash_seed,
66 std::string* output_bytecode,
67 CompileError* error);
68
69 private:
70 DISALLOW_IMPLICIT_CONSTRUCTORS(JtlCompiler);
71 };
72
73 #endif // CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_
OLDNEW
« no previous file with comments | « chrome/tools/profile_reset/OWNERS ('k') | chrome/tools/profile_reset/jtl_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698