2
0
Эх сурвалжийг харах

Merge branch 'master' of https://github.com/vladfolts/oberonjs

Vladislav Folts 11 жил өмнө
parent
commit
ba3c67aadf
2 өөрчлөгдсөн 163 нэмэгдсэн , 0 устгасан
  1. 125 0
      Oberon.tmLanguage
  2. 38 0
      OberonAssistant.py

+ 125 - 0
Oberon.tmLanguage

@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>fileTypes</key>
+	<array>
+		<string>ob</string>
+		<string>ob07</string>
+	</array>
+	<key>keyEquivalent</key>
+	<string>^~@o</string>
+	<key>name</key>
+	<string>Oberon</string>
+	<key>patterns</key>
+	<array>
+		<dict>
+			<key>match</key>
+			<string>\b(FOR|REPEAT|IF|ELSIF|UNTIL|WHILE|DO|ELSE|THEN|CASE|BY|RETURN|TO)\b</string>
+			<key>name</key>
+			<string>keyword.control.oberon</string>
+		</dict>
+		<dict>
+			<key>match</key>
+			<string>\b(IS|DIV|MOD|OR|IN)\b</string>
+			<key>name</key>
+			<string>keyword.operator.oberon</string>
+		</dict>
+		<dict>
+			<key>match</key>
+			<string>\b(IMPORT|BEGIN|TYPE|CONST|MODULE|VAR|PROCEDURE|END)\b</string>
+			<key>name</key>
+			<string>keyword.other.oberon</string>
+		</dict>
+		<dict>
+			<key>match</key>
+			<string>\b(POINTER|RECORD|ARRAY|OF)\b</string>
+			<key>name</key>
+			<string>storage.type.oberon</string>
+		</dict>
+		<dict>
+			<key>match</key>
+			<string>\b(FALSE|NIL|TRUE)\b</string>
+			<key>name</key>
+			<string>constant.language.oberon</string>
+		</dict>
+		<dict>
+			<key>match</key>
+			<string>\b(ABS|ASR|CHR|FLT|INC|LSL|NEW|ROR|ASSERT|DEC|EXCL|FLOOR|INCL|LEN|ODD|ORD|PACK|UNPK)\b</string>
+			<key>name</key>
+			<string>support.function.oberon</string>
+		</dict>
+		<dict>
+			<key>match</key>
+			<string>\b(CHAR|REAL|BYTE|INTEGER|SET|BOOLEAN)\b</string>
+			<key>name</key>
+			<string>support.type.oberon</string>
+		</dict>
+		<dict>
+			<key>match</key>
+			<string>\b(([0-9][0-9A-F]*[H])|([0-9]+[.][0-9]*([ED][+-]?[0-9]+)?)|([0-9]+))\b</string>
+			<key>name</key>
+			<string>constant.numeric.oberon</string>
+		</dict>
+		<dict>
+			<key>begin</key>
+			<string>"</string>
+			<key>beginCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.string.begin.oberon</string>
+				</dict>
+			</dict>
+			<key>end</key>
+			<string>"</string>
+			<key>endCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.string.end.oberon</string>
+				</dict>
+			</dict>
+			<key>name</key>
+			<string>string.quoted</string>
+			<key>patterns</key>
+			<array>
+				<dict>
+					<key>match</key>
+					<string>\\([ntrf\\'"]|([0-7]{3}))</string>
+					<key>name</key>
+					<string>constant.character.escape.oberon</string>
+				</dict>
+			</array>
+		</dict>
+		<dict>
+			<key>match</key>
+			<string>\b([0-9][0-9A-F]+[X])\b</string>
+			<key>name</key>
+			<string>string.other.oberon</string>
+		</dict>
+		<dict>
+			<key>begin</key>
+			<string>\(\*</string>
+			<key>captures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.comment.oberon</string>
+				</dict>
+			</dict>
+			<key>end</key>
+			<string>\*\)</string>
+			<key>name</key>
+			<string>comment.block.oberon</string>
+		</dict>
+	</array>
+	<key>scopeName</key>
+	<string>source.oberon</string>
+	<key>uuid</key>
+	<string>81362E6A-0A64-42AD-9C72-E39330258444</string>
+</dict>
+</plist>

+ 38 - 0
OberonAssistant.py

@@ -0,0 +1,38 @@
+import sublime, sublime_plugin
+
+class OberonAssistant(sublime_plugin.EventListener):
+	rs = {}
+	inProcess = False
+
+	keywords = ['ARRAY', 'IMPORT', 'THEN', 'BEGIN', 'IN', 'TO', 'BY', 'IS', 'TRUE', 'CASE', 'MOD', 'TYPE', 'CONST', 'MODULE', 'UNTIL', 'DIV', 'NIL', 'VAR', 'DO', 'OF', 'WHILE', 'ELSE', 'OR', 'ELSIF', 'POINTER', 'END', 'PROCEDURE', 'FALSE', 'RECORD', 'FOR', 'REPEAT', 'IF', 'RETURN', 'ABS', 'ASR', 'ASSERT', 'BOOLEAN', 'BYTE', 'CHAR', 'CHR', 'DEC', 'EXCL', 'FLOOR', 'FLT', 'INC', 'INCL', 'INTEGER', 'LEN', 'LSL', 'NEW', 'ODD', 'ORD', 'PACK', 'REAL', 'ROR', 'SET', 'UNPK']
+
+	def on_modified(self,view):
+		if len(view.sel())==1 and not self.inProcess:
+			if self.rs != {}:
+				self.rs = view.sel()
+				curr = self.rs[0]
+				scope = view.scope_name(curr.a)
+				if not "oberon" in scope or "string" in scope or "comment" in scope:
+					return
+				ch = view.substr(sublime.Region(curr.a-1,curr.a))
+				if ch==" " or ch=="\n" or ch==";" or ch=="(" or ch==")" :
+					word = view.substr(view.word(sublime.Region(curr.a-1,curr.a-1)))
+					shift = 1
+					if ")" in word :
+						word = view.substr(view.word(sublime.Region(curr.a-2,curr.a-2)))
+						sublime.status_message(word)
+						shift = 2					
+					if word.upper() in self.keywords:
+						edit = view.begin_edit()
+						view.replace(edit, view.word(sublime.Region(curr.a-shift,curr.a-shift)), word.upper())
+						self.inProcess = True
+						view.end_edit(edit)
+						self.inProcess = False
+			else:
+				self.rs = view.sel()
+
+	def on_selection_modified(self,view):
+			self.rs = view.sel()
+			curr = self.rs[0]
+			#sublime.status_message(view.scope_name(curr.a))
+