...

Source file src/github.com/alecthomas/chroma/lexers/m/myghty.go

Documentation: github.com/alecthomas/chroma/lexers/m

     1  package m
     2  
     3  import (
     4  	. "github.com/alecthomas/chroma" // nolint
     5  	"github.com/alecthomas/chroma/lexers/internal"
     6  	. "github.com/alecthomas/chroma/lexers/p" // nolint
     7  )
     8  
     9  // Myghty lexer.
    10  var Myghty = internal.Register(MustNewLazyLexer(
    11  	&Config{
    12  		Name:      "Myghty",
    13  		Aliases:   []string{"myghty"},
    14  		Filenames: []string{"*.myt", "autodelegate"},
    15  		MimeTypes: []string{"application/x-myghty"},
    16  	},
    17  	myghtyRules,
    18  ))
    19  
    20  func myghtyRules() Rules {
    21  	return Rules{
    22  		"root": {
    23  			{`\s+`, Text, nil},
    24  			{`(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, Text, NameFunction, NameTag, UsingSelf("root"), NameTag), nil},
    25  			{`(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)`, ByGroups(NameTag, NameFunction, NameTag, Using(Python2), NameTag), nil},
    26  			{`(<&[^|])(.*?)(,.*?)?(&>)`, ByGroups(NameTag, NameFunction, Using(Python2), NameTag), nil},
    27  			{`(<&\|)(.*?)(,.*?)?(&>)(?s)`, ByGroups(NameTag, NameFunction, Using(Python2), NameTag), nil},
    28  			{`</&>`, NameTag, nil},
    29  			{`(<%!?)(.*?)(%>)(?s)`, ByGroups(NameTag, Using(Python2), NameTag), nil},
    30  			{`(?<=^)#[^\n]*(\n|\Z)`, Comment, nil},
    31  			{`(?<=^)(%)([^\n]*)(\n|\Z)`, ByGroups(NameTag, Using(Python2), Other), nil},
    32  			{`(?sx)
    33                   (.+?)               # anything, followed by:
    34                   (?:
    35                    (?<=\n)(?=[%#]) |  # an eval or comment line
    36                    (?=</?[%&]) |      # a substitution or block or
    37                                       # call start or end
    38                                       # - don't consume
    39                    (\\\n) |           # an escaped newline
    40                    \Z                 # end of string
    41                   )`, ByGroups(Other, Operator), nil},
    42  		},
    43  	}
    44  }
    45  

View as plain text