redsnow 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +34 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +20 -0
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +21 -0
  8. data/README.md +62 -0
  9. data/Rakefile +36 -0
  10. data/Vagrantfile +20 -0
  11. data/ext/snowcrash/Makefile +64 -0
  12. data/ext/snowcrash/Vagrantfile +20 -0
  13. data/ext/snowcrash/bin/snowcrash +0 -0
  14. data/ext/snowcrash/common.gypi +163 -0
  15. data/ext/snowcrash/config.gypi +10 -0
  16. data/ext/snowcrash/config.mk +5 -0
  17. data/ext/snowcrash/configure +213 -0
  18. data/ext/snowcrash/provisioning.sh +15 -0
  19. data/ext/snowcrash/snowcrash.gyp +141 -0
  20. data/ext/snowcrash/src/ActionParser.h +503 -0
  21. data/ext/snowcrash/src/AssetParser.h +215 -0
  22. data/ext/snowcrash/src/BlockUtility.h +186 -0
  23. data/ext/snowcrash/src/Blueprint.h +283 -0
  24. data/ext/snowcrash/src/BlueprintParser.h +347 -0
  25. data/ext/snowcrash/src/BlueprintParserCore.h +190 -0
  26. data/ext/snowcrash/src/BlueprintSection.h +140 -0
  27. data/ext/snowcrash/src/BlueprintUtility.h +126 -0
  28. data/ext/snowcrash/src/CBlueprint.cc +600 -0
  29. data/ext/snowcrash/src/CBlueprint.h +354 -0
  30. data/ext/snowcrash/src/CSourceAnnotation.cc +140 -0
  31. data/ext/snowcrash/src/CSourceAnnotation.h +106 -0
  32. data/ext/snowcrash/src/CodeBlockUtility.h +189 -0
  33. data/ext/snowcrash/src/DescriptionSectionUtility.h +156 -0
  34. data/ext/snowcrash/src/HTTP.cc +46 -0
  35. data/ext/snowcrash/src/HTTP.h +105 -0
  36. data/ext/snowcrash/src/HeaderParser.h +289 -0
  37. data/ext/snowcrash/src/ListBlockUtility.h +273 -0
  38. data/ext/snowcrash/src/ListUtility.h +95 -0
  39. data/ext/snowcrash/src/MarkdownBlock.cc +176 -0
  40. data/ext/snowcrash/src/MarkdownBlock.h +93 -0
  41. data/ext/snowcrash/src/MarkdownParser.cc +266 -0
  42. data/ext/snowcrash/src/MarkdownParser.h +88 -0
  43. data/ext/snowcrash/src/ParameterDefinitonParser.h +570 -0
  44. data/ext/snowcrash/src/ParametersParser.h +252 -0
  45. data/ext/snowcrash/src/Parser.cc +71 -0
  46. data/ext/snowcrash/src/Parser.h +29 -0
  47. data/ext/snowcrash/src/ParserCore.cc +120 -0
  48. data/ext/snowcrash/src/ParserCore.h +82 -0
  49. data/ext/snowcrash/src/PayloadParser.h +672 -0
  50. data/ext/snowcrash/src/Platform.h +54 -0
  51. data/ext/snowcrash/src/RegexMatch.h +32 -0
  52. data/ext/snowcrash/src/ResourceGroupParser.h +195 -0
  53. data/ext/snowcrash/src/ResourceParser.h +584 -0
  54. data/ext/snowcrash/src/SectionUtility.h +142 -0
  55. data/ext/snowcrash/src/Serialize.cc +52 -0
  56. data/ext/snowcrash/src/Serialize.h +69 -0
  57. data/ext/snowcrash/src/SerializeJSON.cc +601 -0
  58. data/ext/snowcrash/src/SerializeJSON.h +21 -0
  59. data/ext/snowcrash/src/SerializeYAML.cc +336 -0
  60. data/ext/snowcrash/src/SerializeYAML.h +21 -0
  61. data/ext/snowcrash/src/SourceAnnotation.h +177 -0
  62. data/ext/snowcrash/src/StringUtility.h +109 -0
  63. data/ext/snowcrash/src/SymbolTable.h +83 -0
  64. data/ext/snowcrash/src/UriTemplateParser.cc +195 -0
  65. data/ext/snowcrash/src/UriTemplateParser.h +243 -0
  66. data/ext/snowcrash/src/Version.h +39 -0
  67. data/ext/snowcrash/src/csnowcrash.cc +23 -0
  68. data/ext/snowcrash/src/csnowcrash.h +38 -0
  69. data/ext/snowcrash/src/posix/RegexMatch.cc +99 -0
  70. data/ext/snowcrash/src/snowcrash.cc +18 -0
  71. data/ext/snowcrash/src/snowcrash.h +41 -0
  72. data/ext/snowcrash/src/snowcrash/snowcrash.cc +170 -0
  73. data/ext/snowcrash/src/win/RegexMatch.cc +78 -0
  74. data/ext/snowcrash/sundown/CONTRIBUTING.md +10 -0
  75. data/ext/snowcrash/sundown/Makefile +83 -0
  76. data/ext/snowcrash/sundown/Makefile.win +33 -0
  77. data/ext/snowcrash/sundown/examples/smartypants.c +72 -0
  78. data/ext/snowcrash/sundown/examples/sundown.c +80 -0
  79. data/ext/snowcrash/sundown/html/houdini.h +37 -0
  80. data/ext/snowcrash/sundown/html/houdini_href_e.c +108 -0
  81. data/ext/snowcrash/sundown/html/houdini_html_e.c +84 -0
  82. data/ext/snowcrash/sundown/html/html.c +647 -0
  83. data/ext/snowcrash/sundown/html/html.h +77 -0
  84. data/ext/snowcrash/sundown/html/html_smartypants.c +389 -0
  85. data/ext/snowcrash/sundown/html_block_names.txt +25 -0
  86. data/ext/snowcrash/sundown/src/autolink.c +297 -0
  87. data/ext/snowcrash/sundown/src/autolink.h +51 -0
  88. data/ext/snowcrash/sundown/src/buffer.c +225 -0
  89. data/ext/snowcrash/sundown/src/buffer.h +96 -0
  90. data/ext/snowcrash/sundown/src/html_blocks.h +206 -0
  91. data/ext/snowcrash/sundown/src/markdown.c +2701 -0
  92. data/ext/snowcrash/sundown/src/markdown.h +147 -0
  93. data/ext/snowcrash/sundown/src/src_map.c +200 -0
  94. data/ext/snowcrash/sundown/src/src_map.h +58 -0
  95. data/ext/snowcrash/sundown/src/stack.c +81 -0
  96. data/ext/snowcrash/sundown/src/stack.h +29 -0
  97. data/ext/snowcrash/sundown/sundown.def +20 -0
  98. data/ext/snowcrash/tools/gyp/AUTHORS +11 -0
  99. data/ext/snowcrash/tools/gyp/DEPS +24 -0
  100. data/ext/snowcrash/tools/gyp/OWNERS +1 -0
  101. data/ext/snowcrash/tools/gyp/PRESUBMIT.py +120 -0
  102. data/ext/snowcrash/tools/gyp/buildbot/buildbot_run.py +190 -0
  103. data/ext/snowcrash/tools/gyp/codereview.settings +10 -0
  104. data/ext/snowcrash/tools/gyp/data/win/large-pdb-shim.cc +12 -0
  105. data/ext/snowcrash/tools/gyp/gyp +8 -0
  106. data/ext/snowcrash/tools/gyp/gyp.bat +5 -0
  107. data/ext/snowcrash/tools/gyp/gyp_main.py +18 -0
  108. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSNew.py +340 -0
  109. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSProject.py +208 -0
  110. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSSettings.py +1063 -0
  111. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSToolFile.py +58 -0
  112. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUserFile.py +147 -0
  113. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSUtil.py +267 -0
  114. data/ext/snowcrash/tools/gyp/pylib/gyp/MSVSVersion.py +409 -0
  115. data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.py +537 -0
  116. data/ext/snowcrash/tools/gyp/pylib/gyp/__init__.pyc +0 -0
  117. data/ext/snowcrash/tools/gyp/pylib/gyp/common.py +521 -0
  118. data/ext/snowcrash/tools/gyp/pylib/gyp/common.pyc +0 -0
  119. data/ext/snowcrash/tools/gyp/pylib/gyp/easy_xml.py +157 -0
  120. data/ext/snowcrash/tools/gyp/pylib/gyp/flock_tool.py +49 -0
  121. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.py +0 -0
  122. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/__init__.pyc +0 -0
  123. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/android.py +1069 -0
  124. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/cmake.py +1143 -0
  125. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/dump_dependency_json.py +81 -0
  126. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/eclipse.py +335 -0
  127. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypd.py +87 -0
  128. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/gypsh.py +56 -0
  129. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.py +2181 -0
  130. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/make.pyc +0 -0
  131. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/msvs.py +3335 -0
  132. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/ninja.py +2156 -0
  133. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.py +1224 -0
  134. data/ext/snowcrash/tools/gyp/pylib/gyp/generator/xcode.pyc +0 -0
  135. data/ext/snowcrash/tools/gyp/pylib/gyp/input.py +2809 -0
  136. data/ext/snowcrash/tools/gyp/pylib/gyp/input.pyc +0 -0
  137. data/ext/snowcrash/tools/gyp/pylib/gyp/mac_tool.py +510 -0
  138. data/ext/snowcrash/tools/gyp/pylib/gyp/msvs_emulation.py +972 -0
  139. data/ext/snowcrash/tools/gyp/pylib/gyp/ninja_syntax.py +160 -0
  140. data/ext/snowcrash/tools/gyp/pylib/gyp/ordered_dict.py +289 -0
  141. data/ext/snowcrash/tools/gyp/pylib/gyp/win_tool.py +292 -0
  142. data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.py +1440 -0
  143. data/ext/snowcrash/tools/gyp/pylib/gyp/xcode_emulation.pyc +0 -0
  144. data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.py +2889 -0
  145. data/ext/snowcrash/tools/gyp/pylib/gyp/xcodeproj_file.pyc +0 -0
  146. data/ext/snowcrash/tools/gyp/pylib/gyp/xml_fix.py +69 -0
  147. data/ext/snowcrash/tools/gyp/pylintrc +307 -0
  148. data/ext/snowcrash/tools/gyp/samples/samples +81 -0
  149. data/ext/snowcrash/tools/gyp/samples/samples.bat +5 -0
  150. data/ext/snowcrash/tools/gyp/setup.py +19 -0
  151. data/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.pbfilespec +27 -0
  152. data/ext/snowcrash/tools/gyp/tools/Xcode/Specifications/gyp.xclangspec +226 -0
  153. data/ext/snowcrash/tools/gyp/tools/emacs/gyp.el +252 -0
  154. data/ext/snowcrash/tools/gyp/tools/graphviz.py +100 -0
  155. data/ext/snowcrash/tools/gyp/tools/pretty_gyp.py +155 -0
  156. data/ext/snowcrash/tools/gyp/tools/pretty_sln.py +168 -0
  157. data/ext/snowcrash/tools/gyp/tools/pretty_vcproj.py +329 -0
  158. data/ext/snowcrash/tools/homebrew/snowcrash.rb +11 -0
  159. data/ext/snowcrash/vcbuild.bat +184 -0
  160. data/lib/redsnow.rb +31 -0
  161. data/lib/redsnow/binding.rb +132 -0
  162. data/lib/redsnow/blueprint.rb +365 -0
  163. data/lib/redsnow/object.rb +18 -0
  164. data/lib/redsnow/parseresult.rb +107 -0
  165. data/lib/redsnow/version.rb +4 -0
  166. data/provisioning.sh +20 -0
  167. data/redsnow.gemspec +35 -0
  168. data/test/_helper.rb +15 -0
  169. data/test/fixtures/sample-api-ast.json +97 -0
  170. data/test/fixtures/sample-api.apib +20 -0
  171. data/test/redsnow_binding_test.rb +35 -0
  172. data/test/redsnow_parseresult_test.rb +50 -0
  173. data/test/redsnow_test.rb +285 -0
  174. metadata +358 -0
@@ -0,0 +1,5 @@
1
+ @rem Copyright (c) 2009 Google Inc. All rights reserved.
2
+ @rem Use of this source code is governed by a BSD-style license that can be
3
+ @rem found in the LICENSE file.
4
+
5
+ @python %~dp0/samples %*
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) 2009 Google Inc. All rights reserved.
4
+ # Use of this source code is governed by a BSD-style license that can be
5
+ # found in the LICENSE file.
6
+
7
+ from setuptools import setup
8
+
9
+ setup(
10
+ name='gyp',
11
+ version='0.1',
12
+ description='Generate Your Projects',
13
+ author='Chromium Authors',
14
+ author_email='chromium-dev@googlegroups.com',
15
+ url='http://code.google.com/p/gyp',
16
+ package_dir = {'': 'pylib'},
17
+ packages=['gyp', 'gyp.generator'],
18
+ entry_points = {'console_scripts': ['gyp=gyp:script_main'] }
19
+ )
@@ -0,0 +1,27 @@
1
+ /*
2
+ gyp.pbfilespec
3
+ GYP source file spec for Xcode 3
4
+
5
+ There is not much documentation available regarding the format
6
+ of .pbfilespec files. As a starting point, see for instance the
7
+ outdated documentation at:
8
+ http://maxao.free.fr/xcode-plugin-interface/specifications.html
9
+ and the files in:
10
+ /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/
11
+
12
+ Place this file in directory:
13
+ ~/Library/Application Support/Developer/Shared/Xcode/Specifications/
14
+ */
15
+
16
+ (
17
+ {
18
+ Identifier = sourcecode.gyp;
19
+ BasedOn = sourcecode;
20
+ Name = "GYP Files";
21
+ Extensions = ("gyp", "gypi");
22
+ MIMETypes = ("text/gyp");
23
+ Language = "xcode.lang.gyp";
24
+ IsTextFile = YES;
25
+ IsSourceFile = YES;
26
+ }
27
+ )
@@ -0,0 +1,226 @@
1
+ /*
2
+ Copyright (c) 2011 Google Inc. 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
+ gyp.xclangspec
7
+ GYP language specification for Xcode 3
8
+
9
+ There is not much documentation available regarding the format
10
+ of .xclangspec files. As a starting point, see for instance the
11
+ outdated documentation at:
12
+ http://maxao.free.fr/xcode-plugin-interface/specifications.html
13
+ and the files in:
14
+ /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/
15
+
16
+ Place this file in directory:
17
+ ~/Library/Application Support/Developer/Shared/Xcode/Specifications/
18
+ */
19
+
20
+ (
21
+
22
+ {
23
+ Identifier = "xcode.lang.gyp.keyword";
24
+ Syntax = {
25
+ Words = (
26
+ "and",
27
+ "or",
28
+ "<!",
29
+ "<",
30
+ );
31
+ Type = "xcode.syntax.keyword";
32
+ };
33
+ },
34
+
35
+ {
36
+ Identifier = "xcode.lang.gyp.target.declarator";
37
+ Syntax = {
38
+ Words = (
39
+ "'target_name'",
40
+ );
41
+ Type = "xcode.syntax.identifier.type";
42
+ };
43
+ },
44
+
45
+ {
46
+ Identifier = "xcode.lang.gyp.string.singlequote";
47
+ Syntax = {
48
+ IncludeRules = (
49
+ "xcode.lang.string",
50
+ "xcode.lang.gyp.keyword",
51
+ "xcode.lang.number",
52
+ );
53
+ Start = "'";
54
+ End = "'";
55
+ };
56
+ },
57
+
58
+ {
59
+ Identifier = "xcode.lang.gyp.comma";
60
+ Syntax = {
61
+ Words = ( ",", );
62
+
63
+ };
64
+ },
65
+
66
+ {
67
+ Identifier = "xcode.lang.gyp";
68
+ Description = "GYP Coloring";
69
+ BasedOn = "xcode.lang.simpleColoring";
70
+ IncludeInMenu = YES;
71
+ Name = "GYP";
72
+ Syntax = {
73
+ Tokenizer = "xcode.lang.gyp.lexer.toplevel";
74
+ IncludeRules = (
75
+ "xcode.lang.gyp.dictionary",
76
+ );
77
+ Type = "xcode.syntax.plain";
78
+ };
79
+ },
80
+
81
+ // The following rule returns tokens to the other rules
82
+ {
83
+ Identifier = "xcode.lang.gyp.lexer";
84
+ Syntax = {
85
+ IncludeRules = (
86
+ "xcode.lang.gyp.comment",
87
+ "xcode.lang.string",
88
+ 'xcode.lang.gyp.targetname.declarator',
89
+ "xcode.lang.gyp.string.singlequote",
90
+ "xcode.lang.number",
91
+ "xcode.lang.gyp.comma",
92
+ );
93
+ };
94
+ },
95
+
96
+ {
97
+ Identifier = "xcode.lang.gyp.lexer.toplevel";
98
+ Syntax = {
99
+ IncludeRules = (
100
+ "xcode.lang.gyp.comment",
101
+ );
102
+ };
103
+ },
104
+
105
+ {
106
+ Identifier = "xcode.lang.gyp.assignment";
107
+ Syntax = {
108
+ Tokenizer = "xcode.lang.gyp.lexer";
109
+ Rules = (
110
+ "xcode.lang.gyp.assignment.lhs",
111
+ ":",
112
+ "xcode.lang.gyp.assignment.rhs",
113
+ );
114
+ };
115
+
116
+ },
117
+
118
+ {
119
+ Identifier = "xcode.lang.gyp.target.declaration";
120
+ Syntax = {
121
+ Tokenizer = "xcode.lang.gyp.lexer";
122
+ Rules = (
123
+ "xcode.lang.gyp.target.declarator",
124
+ ":",
125
+ "xcode.lang.gyp.target.name",
126
+ );
127
+ };
128
+ },
129
+
130
+ {
131
+ Identifier = "xcode.lang.gyp.target.name";
132
+ Syntax = {
133
+ Tokenizer = "xcode.lang.gyp.lexer";
134
+ Rules = (
135
+ "xcode.lang.gyp.string.singlequote",
136
+ );
137
+ Type = "xcode.syntax.definition.function";
138
+ };
139
+ },
140
+
141
+ {
142
+ Identifier = "xcode.lang.gyp.assignment.lhs";
143
+ Syntax = {
144
+ Tokenizer = "xcode.lang.gyp.lexer";
145
+ Rules = (
146
+ "xcode.lang.gyp.string.singlequote",
147
+ );
148
+ Type = "xcode.syntax.identifier.type";
149
+ };
150
+ },
151
+
152
+ {
153
+ Identifier = "xcode.lang.gyp.assignment.rhs";
154
+ Syntax = {
155
+ Tokenizer = "xcode.lang.gyp.lexer";
156
+ Rules = (
157
+ "xcode.lang.gyp.string.singlequote?",
158
+ "xcode.lang.gyp.array?",
159
+ "xcode.lang.gyp.dictionary?",
160
+ "xcode.lang.number?",
161
+ );
162
+ };
163
+ },
164
+
165
+ {
166
+ Identifier = "xcode.lang.gyp.dictionary";
167
+ Syntax = {
168
+ Tokenizer = "xcode.lang.gyp.lexer";
169
+ Start = "{";
170
+ End = "}";
171
+ Foldable = YES;
172
+ Recursive = YES;
173
+ IncludeRules = (
174
+ "xcode.lang.gyp.target.declaration",
175
+ "xcode.lang.gyp.assignment",
176
+ );
177
+ };
178
+ },
179
+
180
+ {
181
+ Identifier = "xcode.lang.gyp.array";
182
+ Syntax = {
183
+ Tokenizer = "xcode.lang.gyp.lexer";
184
+ Start = "[";
185
+ End = "]";
186
+ Foldable = YES;
187
+ Recursive = YES;
188
+ IncludeRules = (
189
+ "xcode.lang.gyp.array",
190
+ "xcode.lang.gyp.dictionary",
191
+ "xcode.lang.gyp.string.singlequote",
192
+ );
193
+ };
194
+ },
195
+
196
+ {
197
+ Identifier = "xcode.lang.gyp.todo.mark";
198
+ Syntax = {
199
+ StartChars = "T";
200
+ Match = (
201
+ "^\(TODO\(.*\):[ \t]+.*\)$", // include "TODO: " in the markers list
202
+ );
203
+ // This is the order of captures. All of the match strings above need the same order.
204
+ CaptureTypes = (
205
+ "xcode.syntax.mark"
206
+ );
207
+ Type = "xcode.syntax.comment";
208
+ };
209
+ },
210
+
211
+ {
212
+ Identifier = "xcode.lang.gyp.comment";
213
+ BasedOn = "xcode.lang.comment"; // for text macros
214
+ Syntax = {
215
+ Start = "#";
216
+ End = "\n";
217
+ IncludeRules = (
218
+ "xcode.lang.url",
219
+ "xcode.lang.url.mail",
220
+ "xcode.lang.comment.mark",
221
+ "xcode.lang.gyp.todo.mark",
222
+ );
223
+ Type = "xcode.syntax.comment";
224
+ };
225
+ },
226
+ )
@@ -0,0 +1,252 @@
1
+ ;;; gyp.el - font-lock-mode support for gyp files.
2
+
3
+ ;; Copyright (c) 2012 Google Inc. All rights reserved.
4
+ ;; Use of this source code is governed by a BSD-style license that can be
5
+ ;; found in the LICENSE file.
6
+
7
+ ;; Put this somewhere in your load-path and
8
+ ;; (require 'gyp)
9
+
10
+ (require 'python)
11
+ (require 'cl)
12
+
13
+ (when (string-match "python-mode.el" (symbol-file 'python-mode 'defun))
14
+ (error (concat "python-mode must be loaded from python.el (bundled with "
15
+ "recent emacsen), not from the older and less maintained "
16
+ "python-mode.el")))
17
+
18
+ (defadvice python-calculate-indentation (after ami-outdent-closing-parens
19
+ activate)
20
+ "De-indent closing parens, braces, and brackets in gyp-mode."
21
+ (if (and (eq major-mode 'gyp-mode)
22
+ (string-match "^ *[])}][],)}]* *$"
23
+ (buffer-substring-no-properties
24
+ (line-beginning-position) (line-end-position))))
25
+ (setq ad-return-value (- ad-return-value 2))))
26
+
27
+ (define-derived-mode gyp-mode python-mode "Gyp"
28
+ "Major mode for editing .gyp files. See http://code.google.com/p/gyp/"
29
+ ;; gyp-parse-history is a stack of (POSITION . PARSE-STATE) tuples,
30
+ ;; with greater positions at the top of the stack. PARSE-STATE
31
+ ;; is a list of section symbols (see gyp-section-name and gyp-parse-to)
32
+ ;; with most nested section symbol at the front of the list.
33
+ (set (make-local-variable 'gyp-parse-history) '((1 . (list))))
34
+ (gyp-add-font-lock-keywords))
35
+
36
+ (defun gyp-set-indentation ()
37
+ "Hook function to configure python indentation to suit gyp mode."
38
+ (setq python-continuation-offset 2
39
+ python-indent 2
40
+ python-guess-indent nil))
41
+
42
+ (add-hook 'gyp-mode-hook 'gyp-set-indentation)
43
+
44
+ (add-to-list 'auto-mode-alist '("\\.gyp\\'" . gyp-mode))
45
+ (add-to-list 'auto-mode-alist '("\\.gypi\\'" . gyp-mode))
46
+ (add-to-list 'auto-mode-alist '("/\\.gclient\\'" . gyp-mode))
47
+
48
+ ;;; Font-lock support
49
+
50
+ (defconst gyp-dependencies-regexp
51
+ (regexp-opt (list "dependencies" "export_dependent_settings"))
52
+ "Regular expression to introduce 'dependencies' section")
53
+
54
+ (defconst gyp-sources-regexp
55
+ (regexp-opt (list "action" "files" "include_dirs" "includes" "inputs"
56
+ "libraries" "outputs" "sources"))
57
+ "Regular expression to introduce 'sources' sections")
58
+
59
+ (defconst gyp-conditions-regexp
60
+ (regexp-opt (list "conditions" "target_conditions"))
61
+ "Regular expression to introduce conditions sections")
62
+
63
+ (defconst gyp-variables-regexp
64
+ "^variables"
65
+ "Regular expression to introduce variables sections")
66
+
67
+ (defconst gyp-defines-regexp
68
+ "^defines"
69
+ "Regular expression to introduce 'defines' sections")
70
+
71
+ (defconst gyp-targets-regexp
72
+ "^targets"
73
+ "Regular expression to introduce 'targets' sections")
74
+
75
+ (defun gyp-section-name (section)
76
+ "Map the sections we are interested in from SECTION to symbol.
77
+
78
+ SECTION is a string from the buffer that introduces a section. The result is
79
+ a symbol representing the kind of section.
80
+
81
+ This allows us to treat (for the purposes of font-lock) several different
82
+ section names as the same kind of section. For example, a 'sources section
83
+ can be introduced by the 'sources', 'inputs', 'outputs' keyword.
84
+
85
+ 'other is the default section kind when a more specific match is not made."
86
+ (cond ((string-match-p gyp-dependencies-regexp section) 'dependencies)
87
+ ((string-match-p gyp-sources-regexp section) 'sources)
88
+ ((string-match-p gyp-variables-regexp section) 'variables)
89
+ ((string-match-p gyp-conditions-regexp section) 'conditions)
90
+ ((string-match-p gyp-targets-regexp section) 'targets)
91
+ ((string-match-p gyp-defines-regexp section) 'defines)
92
+ (t 'other)))
93
+
94
+ (defun gyp-invalidate-parse-states-after (target-point)
95
+ "Erase any parse information after target-point."
96
+ (while (> (caar gyp-parse-history) target-point)
97
+ (setq gyp-parse-history (cdr gyp-parse-history))))
98
+
99
+ (defun gyp-parse-point ()
100
+ "The point of the last parse state added by gyp-parse-to."
101
+ (caar gyp-parse-history))
102
+
103
+ (defun gyp-parse-sections ()
104
+ "A list of section symbols holding at the last parse state point."
105
+ (cdar gyp-parse-history))
106
+
107
+ (defun gyp-inside-dictionary-p ()
108
+ "Predicate returning true if the parser is inside a dictionary."
109
+ (not (eq (cadar gyp-parse-history) 'list)))
110
+
111
+ (defun gyp-add-parse-history (point sections)
112
+ "Add parse state SECTIONS to the parse history at POINT so that parsing can be
113
+ resumed instantly."
114
+ (while (>= (caar gyp-parse-history) point)
115
+ (setq gyp-parse-history (cdr gyp-parse-history)))
116
+ (setq gyp-parse-history (cons (cons point sections) gyp-parse-history)))
117
+
118
+ (defun gyp-parse-to (target-point)
119
+ "Parses from (point) to TARGET-POINT adding the parse state information to
120
+ gyp-parse-state-history. Parsing stops if TARGET-POINT is reached or if a
121
+ string literal has been parsed. Returns nil if no further parsing can be
122
+ done, otherwise returns the position of the start of a parsed string, leaving
123
+ the point at the end of the string."
124
+ (let ((parsing t)
125
+ string-start)
126
+ (while parsing
127
+ (setq string-start nil)
128
+ ;; Parse up to a character that starts a sexp, or if the nesting
129
+ ;; level decreases.
130
+ (let ((state (parse-partial-sexp (gyp-parse-point)
131
+ target-point
132
+ -1
133
+ t))
134
+ (sections (gyp-parse-sections)))
135
+ (if (= (nth 0 state) -1)
136
+ (setq sections (cdr sections)) ; pop out a level
137
+ (cond ((looking-at-p "['\"]") ; a string
138
+ (setq string-start (point))
139
+ (goto-char (scan-sexps (point) 1))
140
+ (if (gyp-inside-dictionary-p)
141
+ ;; Look for sections inside a dictionary
142
+ (let ((section (gyp-section-name
143
+ (buffer-substring-no-properties
144
+ (+ 1 string-start)
145
+ (- (point) 1)))))
146
+ (setq sections (cons section (cdr sections)))))
147
+ ;; Stop after the string so it can be fontified.
148
+ (setq target-point (point)))
149
+ ((looking-at-p "{")
150
+ ;; Inside a dictionary. Increase nesting.
151
+ (forward-char 1)
152
+ (setq sections (cons 'unknown sections)))
153
+ ((looking-at-p "\\[")
154
+ ;; Inside a list. Increase nesting
155
+ (forward-char 1)
156
+ (setq sections (cons 'list sections)))
157
+ ((not (eobp))
158
+ ;; other
159
+ (forward-char 1))))
160
+ (gyp-add-parse-history (point) sections)
161
+ (setq parsing (< (point) target-point))))
162
+ string-start))
163
+
164
+ (defun gyp-section-at-point ()
165
+ "Transform the last parse state, which is a list of nested sections and return
166
+ the section symbol that should be used to determine font-lock information for
167
+ the string. Can return nil indicating the string should not have any attached
168
+ section."
169
+ (let ((sections (gyp-parse-sections)))
170
+ (cond
171
+ ((eq (car sections) 'conditions)
172
+ ;; conditions can occur in a variables section, but we still want to
173
+ ;; highlight it as a keyword.
174
+ nil)
175
+ ((and (eq (car sections) 'list)
176
+ (eq (cadr sections) 'list))
177
+ ;; conditions and sources can have items in [[ ]]
178
+ (caddr sections))
179
+ (t (cadr sections)))))
180
+
181
+ (defun gyp-section-match (limit)
182
+ "Parse from (point) to LIMIT returning by means of match data what was
183
+ matched. The group of the match indicates what style font-lock should apply.
184
+ See also `gyp-add-font-lock-keywords'."
185
+ (gyp-invalidate-parse-states-after (point))
186
+ (let ((group nil)
187
+ (string-start t))
188
+ (while (and (< (point) limit)
189
+ (not group)
190
+ string-start)
191
+ (setq string-start (gyp-parse-to limit))
192
+ (if string-start
193
+ (setq group (case (gyp-section-at-point)
194
+ ('dependencies 1)
195
+ ('variables 2)
196
+ ('conditions 2)
197
+ ('sources 3)
198
+ ('defines 4)
199
+ (nil nil)))))
200
+ (if group
201
+ (progn
202
+ ;; Set the match data to indicate to the font-lock mechanism the
203
+ ;; highlighting to be performed.
204
+ (set-match-data (append (list string-start (point))
205
+ (make-list (* (1- group) 2) nil)
206
+ (list (1+ string-start) (1- (point)))))
207
+ t))))
208
+
209
+ ;;; Please see http://code.google.com/p/gyp/wiki/GypLanguageSpecification for
210
+ ;;; canonical list of keywords.
211
+ (defun gyp-add-font-lock-keywords ()
212
+ "Add gyp-mode keywords to font-lock mechanism."
213
+ ;; TODO(jknotten): Move all the keyword highlighting into gyp-section-match
214
+ ;; so that we can do the font-locking in a single font-lock pass.
215
+ (font-lock-add-keywords
216
+ nil
217
+ (list
218
+ ;; Top-level keywords
219
+ (list (concat "['\"]\\("
220
+ (regexp-opt (list "action" "action_name" "actions" "cflags"
221
+ "conditions" "configurations" "copies" "defines"
222
+ "dependencies" "destination"
223
+ "direct_dependent_settings"
224
+ "export_dependent_settings" "extension" "files"
225
+ "include_dirs" "includes" "inputs" "libraries"
226
+ "link_settings" "mac_bundle" "message"
227
+ "msvs_external_rule" "outputs" "product_name"
228
+ "process_outputs_as_sources" "rules" "rule_name"
229
+ "sources" "suppress_wildcard"
230
+ "target_conditions" "target_defaults"
231
+ "target_defines" "target_name" "toolsets"
232
+ "targets" "type" "variables" "xcode_settings"))
233
+ "[!/+=]?\\)") 1 'font-lock-keyword-face t)
234
+ ;; Type of target
235
+ (list (concat "['\"]\\("
236
+ (regexp-opt (list "loadable_module" "static_library"
237
+ "shared_library" "executable" "none"))
238
+ "\\)") 1 'font-lock-type-face t)
239
+ (list "\\(?:target\\|action\\)_name['\"]\\s-*:\\s-*['\"]\\([^ '\"]*\\)" 1
240
+ 'font-lock-function-name-face t)
241
+ (list 'gyp-section-match
242
+ (list 1 'font-lock-function-name-face t t) ; dependencies
243
+ (list 2 'font-lock-variable-name-face t t) ; variables, conditions
244
+ (list 3 'font-lock-constant-face t t) ; sources
245
+ (list 4 'font-lock-preprocessor-face t t)) ; preprocessor
246
+ ;; Variable expansion
247
+ (list "<@?(\\([^\n )]+\\))" 1 'font-lock-variable-name-face t)
248
+ ;; Command expansion
249
+ (list "<!@?(\\([^\n )]+\\))" 1 'font-lock-variable-name-face t)
250
+ )))
251
+
252
+ (provide 'gyp)