-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a lexer for the JMP Scripting Language.
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Create Distribution of Big Class | ||
dt = open( "$sample_data\big class.jmp" ); | ||
dt << Distribution( Column( :age ), Histograms Only( 1 ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- # | ||
# frozen_string_literal: true | ||
|
||
module Rouge | ||
module Lexers | ||
class JSL < RegexLexer | ||
title "JSL" | ||
desc "The JMP Scripting Language (JSL) (jmp.com)" | ||
|
||
tag 'jsl' | ||
filenames '*.jsl' | ||
|
||
state :root do | ||
rule %r/\s+/m, Text::Whitespace | ||
|
||
rule %r(//.*?$), Comment::Single | ||
rule %r(/\*.*?\*/)m, Comment::Multiline | ||
|
||
# messages | ||
rule %r/(<<)(.*?)(\(|;)/ do |m| | ||
groups Operator, Name::Function, Punctuation | ||
end | ||
|
||
# covers built-in and custom functions | ||
rule %r/([a-z_][\w\s'%.\\]*)(\()/i do |m| | ||
groups Keyword, Punctuation | ||
end | ||
|
||
rule %r/\b[+-]?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+|\.)(?:e[+-]?[0-9]+)?i?\b/i, Num | ||
|
||
rule %r/\d{2}(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d{2}(\d{2})?(:\d{2}:\d{2}(:\d{2}(\.\d*)?)?)?/i, Literal::Date | ||
|
||
rule %r/::[a-z_][\w\s'%.\\]*/i, Name::Variable | ||
rule %r/:\w+/, Name | ||
rule %r/[a-z_][\w\s'%.\\]*/i, Name::Variable | ||
rule %r/"(?:\\!"|[^"])*?"n/m, Name::Variable | ||
|
||
rule %r/(")(\\\[)(.*?)(\]\\)(")/m do | ||
groups Str::Double, Str::Escape, Str::Double, Str::Escape, Str::Double # escaped string | ||
end | ||
rule %r/"/, Str::Double, :dq | ||
|
||
rule %r/[-+*\/!%&<>\|=:]/, Operator | ||
rule %r/[\[\](){},;]/, Punctuation | ||
end | ||
|
||
state :dq do | ||
rule %r/\\![btrnNf0\\"]/, Str::Escape | ||
rule %r/\\/, Str::Double | ||
rule %r/"/, Str::Double, :pop! | ||
rule %r/[^\\"]*/m, Str::Double | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- # | ||
# frozen_string_literal: true | ||
|
||
describe Rouge::Lexers::JSL do | ||
let(:subject) { Rouge::Lexers::JSL.new } | ||
|
||
describe 'guessing' do | ||
include Support::Guessing | ||
|
||
it 'guesses by filename' do | ||
assert_guess :filename => 'foo.jsl' | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Single Line Comment | ||
dt = open( "$sample_data\big class.jmp" ); | ||
dt << Distribution( Column( :age ), Histograms Only( 1 ) ); | ||
/* | ||
Multi-line comment | ||
*/ | ||
|
||
escapeSequence = "This is an \!b escaped sequence"; | ||
escapeQuote = "This is a \!" quotation mark"; | ||
escapeStr = "\[This is """"""" an escaped string]\" | ||
|
||
list = List( 1, 3, 5 ); | ||
alsoAList = {7,9,11}; | ||
a name with spaces = 5; | ||
"a-name!with\!"special\characters"n = 5; | ||
|
||
scientificNotation = 5e9; | ||
decimal = 1.234; | ||
date = 01jan00; | ||
dateTime = 12dec1999:12:30:00.45; | ||
|
||
New Window( "Rouge Test", | ||
Text Box( "Syntax highlighting is great!" ) | ||
); |