diff options
author | Georg Brandl <georg@python.org> | 2013-01-09 11:54:52 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-01-09 11:54:52 +0100 |
commit | be6eb44b575e67e6fc89aebb91bec828aa6413ed (patch) | |
tree | c4458264df4d3c4e7bb8a742206c1486df63bc05 | |
parent | b35b8fcae23a5837e0fc0a72d9466a3274048b3f (diff) | |
parent | f7efa3703fed54ab8090b68769594554777abf5a (diff) | |
download | pygments-be6eb44b575e67e6fc89aebb91bec828aa6413ed.tar.gz |
Merged in waywardmonkeys/pygments-main (pull request #148: Additional Dylan fixes)
-rw-r--r-- | pygments/lexers/compiled.py | 15 | ||||
-rw-r--r-- | tests/examplefiles/classes.dylan | 1 | ||||
-rw-r--r-- | tests/examplefiles/nanomsg.intr | 95 |
3 files changed, 110 insertions, 1 deletions
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py index 279eb065..f8055fc5 100644 --- a/pygments/lexers/compiled.py +++ b/pygments/lexers/compiled.py @@ -1061,7 +1061,7 @@ class DylanLexer(RegexLexer): filenames = ['*.dylan', '*.dyl', '*.intr'] mimetypes = ['text/x-dylan'] - flags = re.DOTALL | re.IGNORECASE + flags = re.IGNORECASE builtins = set([ 'subclass', 'abstract', 'block', 'concrete', 'constant', 'class', @@ -1146,6 +1146,19 @@ class DylanLexer(RegexLexer): # single line comment (r'//.*?\n', Comment.Single), + # lid header + (r'([A-Za-z0-9-]+)(:)([ \t]*)(.*(?:\n[ \t].+)*)', + bygroups(Name.Attribute, Operator, Text, String)), + + ('', Text, 'code') # no header match, switch to code + ], + 'code': [ + # Whitespace + (r'\s+', Text), + + # single line comment + (r'//.*?\n', Comment.Single), + # multi-line comment (r'/\*', Comment.Multiline, 'comment'), diff --git a/tests/examplefiles/classes.dylan b/tests/examplefiles/classes.dylan index 90cafdf6..7bb88faa 100644 --- a/tests/examplefiles/classes.dylan +++ b/tests/examplefiles/classes.dylan @@ -1,5 +1,6 @@ module: sample comment: for make sure that does not highlight per word. + and it continues on to the next line. define class <car> (<object>) slot serial-number :: <integer> = unique-serial-number(); diff --git a/tests/examplefiles/nanomsg.intr b/tests/examplefiles/nanomsg.intr new file mode 100644 index 00000000..d21f62cc --- /dev/null +++ b/tests/examplefiles/nanomsg.intr @@ -0,0 +1,95 @@ +module: nanomsg +synopsis: generated bindings for the nanomsg library +author: Bruce Mitchener, Jr. +copyright: See LICENSE file in this distribution. + +define simple-C-mapped-subtype <C-buffer-offset> (<C-char*>) + export-map <machine-word>, export-function: identity; +end; + +define interface + #include { + "sp/sp.h", + "sp/fanin.h", + "sp/inproc.h", + "sp/pair.h", + "sp/reqrep.h", + "sp/survey.h", + "sp/fanout.h", + "sp/ipc.h", + "sp/pubsub.h", + "sp/tcp.h" + }, + + exclude: { + "SP_HAUSNUMERO", + "SP_PAIR_ID", + "SP_PUBSUB_ID", + "SP_REQREP_ID", + "SP_FANIN_ID", + "SP_FANOUT_ID", + "SP_SURVEY_ID" + }, + + equate: {"char *" => <c-string>}, + + rename: { + "sp_recv" => %sp-recv, + "sp_send" => %sp-send, + "sp_setsockopt" => %sp-setsockopt + }; + + function "sp_version", + output-argument: 1, + output-argument: 2, + output-argument: 3; + + function "sp_send", + map-argument: { 2 => <C-buffer-offset> }; + + function "sp_recv", + map-argument: { 2 => <C-buffer-offset> }; + +end interface; + +// Function for adding the base address of the repeated slots of a <buffer> +// to an offset and returning the result as a <machine-word>. This is +// necessary for passing <buffer> contents across the FFI. + +define function buffer-offset + (the-buffer :: <buffer>, data-offset :: <integer>) + => (result-offset :: <machine-word>) + u%+(data-offset, + primitive-wrap-machine-word + (primitive-repeated-slot-as-raw + (the-buffer, primitive-repeated-slot-offset(the-buffer)))) +end function; + +define inline function sp-send (socket :: <integer>, data :: <buffer>, flags :: <integer>) => (res :: <integer>) + %sp-send(socket, buffer-offset(data, 0), data.size, flags) +end; + +define inline function sp-recv (socket :: <integer>, data :: <buffer>, flags :: <integer>) => (res :: <integer>) + %sp-recv(socket, buffer-offset(data, 0), data.size, flags); +end; + +define inline method sp-setsockopt (socket :: <integer>, level :: <integer>, option :: <integer>, value :: <integer>) + with-stack-structure (int :: <C-int*>) + pointer-value(int) := value; + let setsockopt-result = + %sp-setsockopt(socket, level, option, int, size-of(<C-int*>)); + if (setsockopt-result < 0) + // Check error! + end; + setsockopt-result + end; +end; + +define inline method sp-setsockopt (socket :: <integer>, level :: <integer>, option :: <integer>, data :: <byte-string>) + let setsockopt-result = + %sp-setsockopt(socket, level, option, as(<c-string>, data), data.size); + if (setsockopt-result < 0) + // Check error! + end; + setsockopt-result +end; |