[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-source-highlight] Support for Google Protocol Buffers protobuf lan
From: |
Joel Smith |
Subject: |
[Help-source-highlight] Support for Google Protocol Buffers protobuf language (.proto) |
Date: |
Tue, 09 Mar 2010 13:01:44 -0700 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
Hi,
Attached is a patch that adds support for Google's Protocol Buffers
language. See this URL for more information about the language:
http://code.google.com/apis/protocolbuffers/docs/proto.html
Additionally, I wanted to mention that the code checked out of git
wouldn't build for me until I added the following two lines to the
configure.ac:
m4_include([m4/ax_boost_base.m4])
m4_include([m4/ax_boost_regex.m4])
I'm not sure if there is something wrong with my installation or what,
but without those, autoconf didn't expand macros properly and the
resulting configure script wouldn't run.
I'm not sure if my message will make it through to the list or not since
I guess I'm awaiting moderator approval before I'm on the list, so I
guess we'll see!
Thanks,
Joel
diff --git a/src/Makefile.am b/src/Makefile.am
index 8d98543..c29e7e9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -83,7 +83,7 @@ desktop.lang lsm.lang spec.lang haxe.lang ldap.lang glsl.lang
xorg.lang \
clike_vardeclaration.lang scala.lang ada.lang conf.lang pc.lang oz.lang \
texinfo.lang haskell.lang manifest.lang asm.lang todo.lang applescript.lang \
vbscript.lang awk.lang bat.lang clipper.lang cobol.lang d.lang \
-errors.lang erlang.lang
+errors.lang erlang.lang proto.lang
OUTLANGFILES = \
css_common.outlang \
diff --git a/src/lang.map b/src/lang.map
index 43fe58c..bf22985 100644
--- a/src/lang.map
+++ b/src/lang.map
@@ -21,6 +21,8 @@ php4 = php.lang
php5 = php.lang
php = php.lang
ctp = php.lang
+protobuf = proto.lang
+proto = proto.lang
python = python.lang
py = python.lang
ruby = ruby.lang
diff --git a/src/proto.lang b/src/proto.lang
new file mode 100644
index 0000000..d32a58b
--- /dev/null
+++ b/src/proto.lang
@@ -0,0 +1,30 @@
+# definitions for Google Protocol Buffers (protobuf)
+# http://code.google.com/apis/protocolbuffers/docs/proto.html
+# Added by Joel Smith
+
+comment start "//"
+
+(keyword,normal,classname) =
+ `(\<message|service)([[:blank:]]+)([[:alnum:]_]+)`
+
+symbol = "(",")","=","[","]",";"
+
+preproc = "import","package","option"
+
+include "number.lang"
+
+include "c_string.lang"
+
+keyword = "group",
+ "optional|required|repeated",
+ "default",
+ "extend|extensions|to|max",
+ "service|method|rpc|returns",
+ "enum",
+ "true|false"
+
+type = "int32|int64|uint32|uint64|sint32|sint64",
+ "fixed32|fixed64|sfixed32|sfixed64",
+ "float|double|bool|string|bytes"
+
+cbracket = "{|}"
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3c502f9..a78264a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -299,7 +299,8 @@ test.clipper test.clipper.html \
test.cobol test.cobol.html \
test.d test.d.html \
test.errors test.errors.html \
-test.erl test.erl.html
+test.erl test.erl.html \
+test.proto test.proto.html
LINERANGE1EXE=$(JAVA2HTML) --line-range="12-18","29-34" --line-number
LINERANGE2EXE=$(JAVA2HTML) --line-range="12-18","29-34" --line-number
--range-context=3
@@ -417,6 +418,7 @@ check_cobol \
check_d \
check_errors \
check_erlang \
+check_proto \
check-output-dir \
check_stop \
check_vardecl \
@@ -778,6 +780,11 @@ check_fortran:
$(DIFF) $(srcdir)/test.fortran.html test.fortran.out.html
$(DIFF) $(srcdir)/test.fixed-fortran.html test.fixed-fortran.out.html
+check_proto:
+ $(PROGNAME_STD) -i $(srcdir)/test.proto -o test.proto.out.html
+ @echo expect no output from diff
+ $(DIFF) $(srcdir)/test.proto.html test.proto.out.html
+
check_spec:
$(SPEC2HTML) -i $(srcdir)/test.spec -o test.spec.out.html
@echo expect no output from diff
@@ -1160,4 +1167,4 @@ clean_html:
DISTCLEANFILES=my_test_ref_tmp.tags $(TEMP_TAGFILE)
-#DISTCLEANFILES=test_ref.xhtml test_ref.tags test_ref.tags tags test_ref.tex
test_ref_post.tex test_ref.texinfo syslog.style.html test_ref.docbook
\ No newline at end of file
+#DISTCLEANFILES=test_ref.xhtml test_ref.tags test_ref.tags tags test_ref.tex
test_ref_post.tex test_ref.texinfo syslog.style.html test_ref.docbook
diff --git a/tests/lang.list b/tests/lang.list
index 751d641..ff0577f 100644
--- a/tests/lang.list
+++ b/tests/lang.list
@@ -99,6 +99,8 @@ postscript = postscript.lang
prg = clipper.lang
prolog = prolog.lang
properties = properties.lang
+proto = proto.lang
+protobuf = proto.lang
ps = postscript.lang
py = python.lang
python = python.lang
diff --git a/tests/test.proto b/tests/test.proto
new file mode 100644
index 0000000..97fdc3f
--- /dev/null
+++ b/tests/test.proto
@@ -0,0 +1,56 @@
+// Created from samples at
+// http://code.google.com/apis/protocolbuffers/docs/proto.html
+import "google/protobuf/descriptor.proto"
+
+option optimize_for = CODE_SIZE;
+
+package test;
+
+extend google.protobuf.FileOptions {
+ optional string my_file_option = 50000;
+}
+extend google.protobuf.MessageOptions {
+ optional int32 my_message_option = 50001;
+}
+extend google.protobuf.FieldOptions {
+ optional float my_field_option = 50002;
+}
+extend google.protobuf.EnumOptions {
+ optional bool my_enum_option = 50003;
+}
+extend google.protobuf.EnumValueOptions {
+ optional uint32 my_enum_value_option = 50004;
+}
+extend google.protobuf.ServiceOptions {
+ optional MyEnum my_service_option = 50005;
+}
+extend google.protobuf.MethodOptions {
+ optional MyMessage my_method_option = 50006;
+}
+
+option (my_file_option) = "Hello world!";
+
+message MyMessage {
+ option (my_message_option) = 1234;
+
+ optional int32 foo = 1 [(my_field_option) = 4.5];
+ optional string bar = 2;
+}
+
+enum MyEnum {
+ option (my_enum_option) = true;
+
+ FOO = 1 [(my_enum_value_option) = 321];
+ BAR = 2;
+}
+
+service MyService {
+ option (my_service_option) = FOO;
+
+ method MyMethod() {
+ // Note: my_method_option has type MyMessage. We can set each field
+ // within it using a separate "option" line.
+ option (my_method_option).foo = 567;
+ option (my_method_option).bar = "Some string";
+ }
+}
diff --git a/tests/test.proto.html b/tests/test.proto.html
new file mode 100644
index 0000000..1dbf6ad
--- /dev/null
+++ b/tests/test.proto.html
@@ -0,0 +1,61 @@
+<!-- Generator: GNU source-highlight
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><i><font color="#9A1900">// Created from samples at</font></i>
+<i><font color="#9A1900">//
http://code.google.com/apis/protocolbuffers/docs/proto.html</font></i>
+<b><font color="#000080">import</font></b> <font
color="#FF0000">"google/protobuf/descriptor.proto"</font>
+
+<b><font color="#000080">option</font></b> optimize_for <font
color="#990000">=</font> CODE_SIZE<font color="#990000">;</font>
+
+<b><font color="#000080">package</font></b> test<font color="#990000">;</font>
+
+<b><font color="#0000FF">extend</font></b> google.protobuf.FileOptions <font
color="#FF0000">{</font>
+ <b><font color="#0000FF">optional</font></b> <font
color="#009900">string</font> my_file_option <font color="#990000">=</font>
<font color="#993399">50000</font><font color="#990000">;</font>
+<font color="#FF0000">}</font>
+<b><font color="#0000FF">extend</font></b> google.protobuf.MessageOptions
<font color="#FF0000">{</font>
+ <b><font color="#0000FF">optional</font></b> <font
color="#009900">int32</font> my_message_option <font color="#990000">=</font>
<font color="#993399">50001</font><font color="#990000">;</font>
+<font color="#FF0000">}</font>
+<b><font color="#0000FF">extend</font></b> google.protobuf.FieldOptions <font
color="#FF0000">{</font>
+ <b><font color="#0000FF">optional</font></b> <font
color="#009900">float</font> my_field_option <font color="#990000">=</font>
<font color="#993399">50002</font><font color="#990000">;</font>
+<font color="#FF0000">}</font>
+<b><font color="#0000FF">extend</font></b> google.protobuf.EnumOptions <font
color="#FF0000">{</font>
+ <b><font color="#0000FF">optional</font></b> <font
color="#009900">bool</font> my_enum_option <font color="#990000">=</font> <font
color="#993399">50003</font><font color="#990000">;</font>
+<font color="#FF0000">}</font>
+<b><font color="#0000FF">extend</font></b> google.protobuf.EnumValueOptions
<font color="#FF0000">{</font>
+ <b><font color="#0000FF">optional</font></b> <font
color="#009900">uint32</font> my_enum_value_option <font
color="#990000">=</font> <font color="#993399">50004</font><font
color="#990000">;</font>
+<font color="#FF0000">}</font>
+<b><font color="#0000FF">extend</font></b> google.protobuf.ServiceOptions
<font color="#FF0000">{</font>
+ <b><font color="#0000FF">optional</font></b> MyEnum my_service_option <font
color="#990000">=</font> <font color="#993399">50005</font><font
color="#990000">;</font>
+<font color="#FF0000">}</font>
+<b><font color="#0000FF">extend</font></b> google.protobuf.MethodOptions <font
color="#FF0000">{</font>
+ <b><font color="#0000FF">optional</font></b> MyMessage my_method_option
<font color="#990000">=</font> <font color="#993399">50006</font><font
color="#990000">;</font>
+<font color="#FF0000">}</font>
+
+<b><font color="#000080">option</font></b> <font
color="#990000">(</font>my_file_option<font color="#990000">)</font> <font
color="#990000">=</font> <font color="#FF0000">"Hello world!"</font><font
color="#990000">;</font>
+
+<b><font color="#0000FF">message</font></b> <font
color="#008080">MyMessage</font> <font color="#FF0000">{</font>
+ <b><font color="#000080">option</font></b> <font
color="#990000">(</font>my_message_option<font color="#990000">)</font> <font
color="#990000">=</font> <font color="#993399">1234</font><font
color="#990000">;</font>
+
+ <b><font color="#0000FF">optional</font></b> <font
color="#009900">int32</font> foo <font color="#990000">=</font> <font
color="#993399">1</font> <font color="#990000">[(</font>my_field_option<font
color="#990000">)</font> <font color="#990000">=</font> <font
color="#993399">4.5</font><font color="#990000">];</font>
+ <b><font color="#0000FF">optional</font></b> <font
color="#009900">string</font> bar <font color="#990000">=</font> <font
color="#993399">2</font><font color="#990000">;</font>
+<font color="#FF0000">}</font>
+
+<b><font color="#0000FF">enum</font></b> MyEnum <font color="#FF0000">{</font>
+ <b><font color="#000080">option</font></b> <font
color="#990000">(</font>my_enum_option<font color="#990000">)</font> <font
color="#990000">=</font> <b><font color="#0000FF">true</font></b><font
color="#990000">;</font>
+
+ FOO <font color="#990000">=</font> <font color="#993399">1</font> <font
color="#990000">[(</font>my_enum_value_option<font color="#990000">)</font>
<font color="#990000">=</font> <font color="#993399">321</font><font
color="#990000">];</font>
+ BAR <font color="#990000">=</font> <font color="#993399">2</font><font
color="#990000">;</font>
+<font color="#FF0000">}</font>
+
+<b><font color="#0000FF">service</font></b> <font
color="#008080">MyService</font> <font color="#FF0000">{</font>
+ <b><font color="#000080">option</font></b> <font
color="#990000">(</font>my_service_option<font color="#990000">)</font> <font
color="#990000">=</font> FOO<font color="#990000">;</font>
+
+ <b><font color="#0000FF">method</font></b> MyMethod<font
color="#990000">()</font> <font color="#FF0000">{</font>
+ <i><font color="#9A1900">// Note: my_method_option has type MyMessage.
We can set each field</font></i>
+ <i><font color="#9A1900">// within it using a separate "option"
line.</font></i>
+ <b><font color="#000080">option</font></b> <font
color="#990000">(</font>my_method_option<font color="#990000">)</font>.foo
<font color="#990000">=</font> <font color="#993399">567</font><font
color="#990000">;</font>
+ <b><font color="#000080">option</font></b> <font
color="#990000">(</font>my_method_option<font color="#990000">)</font>.bar
<font color="#990000">=</font> <font color="#FF0000">"Some string"</font><font
color="#990000">;</font>
+ <font color="#FF0000">}</font>
+<font color="#FF0000">}</font>
+</tt></pre>
- [Help-source-highlight] Support for Google Protocol Buffers protobuf language (.proto),
Joel Smith <=