Commit 13d69745 authored by Zachary Goldstein's avatar Zachary Goldstein
Browse files

Initial commit

parents
How to Install the Sublime uSmallTalk Syntax Package
Author: Zachary Goldstein (zgolds01), Tufts University
Created: 14 Nov 2020
Last Modified: 14 Nov 2020
Procedure:
1) If you don't already have Sublime installed, you can download it here:
https://www.sublimetext.com/3
2) Sublime allows you to use SFTP or a Remote-Folder to access your files
on the Halligan servers. To enable Sublime to connect to Halligan, you
will need to install a package. I recommend the "SFTP for Sublime Text"
package, which you can install as the the directions here:
https://codexns.io/products/sftp_for_sublime/install
3) Quit Sublime
4) Once you've installed Sublime and a suitable SFTP package, you have to
install the uSmallTalk package. Since this package is not officially
supported, you'll have to install it manually.
Move the uSmallTalk package directory inside Sublime's "Packages" folder.
The location of this folder varies based on your operating system:
(a) Windows: $APPDATA/Sublime Text 3/Packages
(b) OSX: ~/Library/Application\ Support/Sublime\ Text\ 3/Packages
(c) Linux: ~/.config/sublime-text-3/Packages
(I may be wrong about the Windows/Linux locations)
5) If you forgot to quit Sublime before installing the uSmallTalk package,
restart Sublime now.
6) That's it, you're done!
Now, any ".ums" files that you open in Sublime should have uSmallTalk-specific
syntax highlighting automatically applied. If your uSmallTalk code still looks
bland, you may have to manually change the syntax settings by going to:
(View) -> (Syntax) -> (uSmallTalk)
MIT License
Copyright (c) 2020, Zachary E. Goldstein
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
'OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\ No newline at end of file
uSmallTalk Syntax Package
Author: Zachary Goldstein (zgolds01), Tufts University
Created: 23 Apr 2020
Last Modified: 14 Nov 2020
Purpose:
- highlight uSmallTalk source according to grammar specification
- facilitate (relatively) painless uSmallTalk programming
Acknowledgements
- the color scheme is inspired by Sublime's default syntax
highlighter for C
- the uSmallTalk grammar specification was provided by the COMP 0040
course staff at Tufts University
- http://www.sublimetext.com/docs/3/syntax.html
- https://www.sublimetext.com/docs/3/color_schemes.html
- https://sublime-text-unofficial-documentation.readthedocs.io/en/latest/reference/comments.html
File Overview:
- README
See README, section 'File Overview'
- usmalltalk-comments.tmPreferences
This file contains a description of how uSmallTalk programs are commented,
which enables uSmallTalk programmers to use the native Sublime 'primary+/'
shortcut to conveniently comment-out highlighted text.
On Windows/Linux machines, the 'primary' key is CONTROL
On OSX machines, the 'primary' key is COMMAND
- usmalltalk.sublime-color-scheme
This file contains the styling data for each scope defined in the
'sublime-syntax' for uSmallTalk. If you want to change the color and/or
styling for a particular scope, that can be done in this file.
You can read up on Sublime Text 3 color schemes here:
https://www.sublimetext.com/docs/3/color_schemes.html
- usmalltalk.sublime-settings
This file contains settings for this package. Crucially, it links the
'sublime-syntax' with the 'sublime-color-scheme'.
- usmalltalk.sublime-syntax
This file contains all the syntax highlighting rules. Scopes are
specified using 'regular expression' pattern matching (and since
Sublime in built on Python, we have access to a robust set of
'regex' tools). If you want to add additional scopes, that can be
done in this file.
Additional Notes
- On the use of XML in "usmalltalk-comments.tmPreferences":
One advantge of Sublime 3 (over Sublime 2) is the ability to use
YAML in package development instead of XML. Confusingly, certain
Sublime 3 functionalities (like the native comment shortcut) are
not reliably supported by the considerly friendlier YAML.
Consequently, the native comment shortcut support must be implemented
in XML -- an unfortuante and archaic vestige of Sublime 2 package
development.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Comments</string>
<key>scope</key>
<string>source.usmalltalk</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key>
<string>TM_COMMENT_START</string>
<key>value</key>
<string>; </string>
</dict>
</array>
</dict>
</dict>
</plist>
{
"name": "uSmallTalk",
"author": "Zachary Goldstein",
"variables":
{
"black": "hsl(0, 0%, 0%)",
"black2": "hsl(60, 17%, 11%)",
"black3": "hsl(70, 8%, 15%)",
"blue": "hsl(190, 81%, 67%)",
"green": "hsl(81, 100%, 45%)",
"grey": "hsl(55, 8%, 26%)",
"lightgrey": "hsl(55, 8%, 60%)",
"orange": "hsl(32, 98%, 56%)",
"orange2": "hsl(30, 83%, 34%)",
"orange3": "hsl(47, 100%, 79%)",
"purple": "hsl(261, 100%, 75%)",
"purple2": "hsl(261, 100%, 40%)",
"red": "hsl(0, 93%, 59%)",
"red2": "hsl(338, 95%, 56%)",
"white": "hsl(0, 0%, 97%)",
"white2": "hsl(60, 36%, 96%)",
"white3": "hsl(60, 30%, 96%)",
"yellow": "hsl(54, 70%, 68%)",
"yellow2": "hsl(80, 76%, 53%)",
"yellow3": "hsl(60, 12%, 79%)",
"yellow4": "hsl(55, 11%, 22%)",
"yellow5": "hsl(50, 11%, 41%)"
},
"globals":
{
"foreground": "var(white3)",
"background": "var(black3)",
"caret": "color(var(white2) alpha(0.9))",
"block_caret": "color(var(white2) alpha(0.4))",
"invisibles": "color(var(white3) alpha(0.35))",
"line_highlight": "var(yellow4)",
"selection": "var(grey)",
"selection_border": "var(black2)",
"misspelling": "var(red2)",
"active_guide": "color(var(orange2) alpha(0.69))",
"find_highlight_foreground": "var(black)",
"find_highlight": "var(orange3)",
"brackets_options": "underline",
"brackets_foreground": "color(var(white3) alpha(0.65))",
"bracket_contents_options": "underline",
"bracket_contents_foreground": "color(var(white3) alpha(0.65))",
"tags_options": "stippled_underline"
},
"rules":
[
{
"name": "Class",
"scope": "keyword.class",
"foreground": "var(blue)",
"font_style": "italic"
},
{
"name": "ClassName",
"scope": "entity.name.class",
"foreground": "var(green)",
"font_style": "italic"
},
{
"name": "SubclassOf",
"scope": "keyword.subclass-of",
"foreground": "var(red2)"
},
{
"name": "ParentClass",
"scope": "entity.name.parent-class",
"foreground": "var(green)",
"font_style": "italic"
},
{
"name": "ivars",
"scope": "keyword.ivars",
"foreground": "var(red2)"
},
{
"name": "Method",
"scope": "keyword.method",
"foreground": "var(blue)",
"font_style": "italic"
},
{
"name": "MethodName",
"scope": "entity.name.method",
"foreground": "var(green)"
//"font_style": "italic"
},
{
"name": "Paramter",
"scope": "variable.paramter",
"foreground": "var(yellow5)"
},
{
"name": "LanguageVariable",
"scope": "variable.language",
"foreground": "var(orange)"
},
{
"name": "InstanceVariable",
"scope": "variable.other",
"foreground": "var(orange)"
},
{
"name": "Comment",
"scope": "comment",
"foreground": "var(yellow5)"
},
{
"name": "Number",
"scope": "literal.numeric",
"foreground": "var(purple)"
},
{
"name": "Character",
"scope": "literal.character",
"foreground": "var(yellow)"
},
{
"name": "String",
"scope": "string",
"foreground": "var(yellow)"
},
{
"name": "UnitTest",
"scope": "unit-test",
"foreground": "var(blue)"
},
{
"name": "Assignment",
"scope": "operator.assignment",
"foreground": "var(red2)"
},
{
"name": "Relational",
"scope": "operator.relational",
},
{
"name": "Binary",
"scope": "operator.binary"
},
{
"name": "Unary",
"scope": "operator.unary",
},
{
"name": "Keyword",
"scope": "keyword",
"foreground": "var(red2)"
},
{
"name": "InvalidSyntax",
"scope": "invalid.illegal.syntax",
"foreground": "var(white2)",
"background": "var(red2)"
},
{
"name": "Stray-Bracket-End",
"scope": "invalid.illegal.stray-bracket-end",
"foreground": "var(white2)",
"background": "var(red2)"
},
]
}
\ No newline at end of file
{
"color_scheme": "usmalltalk.sublime-color-scheme",
"auto_complete": false,
"auto_complete_commit_on_tab": false,
"auto_match_enabled": false
}
\ No newline at end of file
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
name: uSmallTalk
file_extensions:
- smt
scope: source.usmalltalk
variables:
bracket: |-
(?x)
(?: \( | \) | \[ | \] | \{ | \})
boundary: |-
(?x)
(?: {{bracket}} | \s)
reserved: |-
(?x)
(?:
set | begin | block | return | primitive | compiled-method |
define | class | subclass-of | ivars | locals | use |
check-expect | check-assert | check-error | check-print |
class-method | method | subclassResponsibility
)
unit_test: |-
(?x)
(?:
check-expect | check-assert | check-error | check-print
)
method_definition: |-
(?x)
(?:
class-method | method
)
integer_literal: '\b(\+|-)?[0-9]+\b'
name: |-
(?x)
(?!(\d+))
([^{{boundary}}]|:|x|=)*
class_name: |-
(?x)
\b
(?!(\d+))
[A-Z]
([^{{boundary}}]|:|x|=)*
contexts:
# The prototype context is prepended to all contexts but those setting
# meta_include_prototype: false.
prototype:
- include: comments
main:
- include: brackets
- include: keyword
- include: literal
# - include: operator
keyword:
# - match: \b{{register}}\b
# scope: register
# - match: '{{label}}(?=:)'
# scope: label
# - match: '\.{{directive}}\b'
# scope: directive
# - match : '(?s)\b(class)\s+({{name}})(\b)?'
# captures :
# 1 : keyword.class
# 2 : entity.name.class
- match : '\b(self|super)\b'
scope : variable.language
- match : '\bclass\s+'
scope : keyword.class
push :
- match : '{{name}}'
scope : entity.name.class
pop : true
- match : '{{class_name}}'
scope : entity.name.class
- match : '\bsubclass-of\s+'
scope : keyword.subclass-of
push :
- match : '{{name}}'
scope : entity.name.parent-class
pop : true
- match : '\bivars\s+'
scope : keyword.ivars
push :
- match : '{{name}}'
scope : variable.other
- match : '(?={{bracket}})'
pop : true
- match : '\b{{method_definition}}\s+'
scope : keyword.method
push :
- match : '{{name}}'
scope : entity.name.method
pop : true
- match : ({{unit_test}})
scope : unit-test
- match: \b{{reserved}}\b
scope: keyword
literal:
- match : '{{integer_literal}}'
scope : literal.numeric
- match: \'\(
scope: punctuation.definition.array.begin
push: array_literal
- match: \'
scope: punctuation.definition.string.begin
push: quoted_literal
# string-literals begin and end with quotes, and use backslashes as an escape character.
# - match: '"'
# scope: punctuation.definition.string.begin
# push: inside_string
quoted_literal:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match: '(?={{boundary}})'
scope: punctuation.definition.string.end
pop: true
array_literal:
- meta_include_prototype: false
- meta_scope: string.quoted.single
- match : '{{integer_literal}}'
scope : literal.numeric
- match: \(
scope: punctuation.definition.array.begin
push: array_literal
- match: \)
scope: punctuation.definition.array.end
pop: true
# inside_string:
# - meta_include_prototype: false
# - meta_scope: string.quoted.double
# - match: '\.'
# scope: constant.character.escape
# - match: '"'
# scope: punctuation.definition.string.end
# pop: true
# operator:
# # assignment operator
# - match: \:\=
# scope: operator.assignment
# - match: '{{relop}}'
# scope: operator.relational
# - match: '{{binop}}'
# scope: operator.binary
# - match: '{{unop}}'
# scope: operator.unary
comments:
# Comments begin with a ';' and finish at the end of the line.
#- meta_include_prototype: false
- match: ';'
scope: punctuation.definition.comment
push:
- meta_scope: comment.line.semicolon
- match: $\n?
pop: true
brackets:
- match: \(
push: round_bracket
- match: \)
scope: invalid.illegal.stray-bracket-end
- match: \[
push: square_bracket
- match: \]
scope: invalid.illegal.stray-bracket-end
- match: \{
push: curly_bracket
- match: \}
scope: invalid.illegal.stray-bracket-end
round_bracket:
- match: \)
pop: true
- include: main
square_bracket:
- match: \]
pop: true
- include: main
curly_bracket:
- match: \}
pop: true
- include: main
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment