Compare commits

...

19 Commits

Author SHA1 Message Date
Derek Schmidt 41dca29833 Initial tree-sitter implimentation 2021-10-22 17:17:57 -07:00
theRemix 9bacfaa695 Merge pull request #34 from tong/master
Update CHANGELOG
2017-03-11 20:00:11 -10:00
theRemix 77e901fab7 Merge branch 'master' into master 2017-03-11 19:59:55 -10:00
Jon Borgonia 510965fefe Prepare 0.6.0 release 2017-03-11 19:58:59 -10:00
theRemix 65b71e0494 Merge pull request #32 from tong/dev
First line #! hashbang grammar and some minor snippet updates
2017-03-11 19:57:28 -10:00
tong b4a0bd085d Update CHANGELOG 2017-02-02 13:26:57 +01:00
Jon Borgonia 7ec41ac94b Prepare 0.5.4 release 2017-01-28 21:38:36 -10:00
theRemix 2a2fc2fd3f Merge pull request #33 from tong/haxe-3.4.0-RC1
Update hxml defines grammar to haxe 3.4.0-rc.1
2017-01-28 21:37:57 -10:00
tong 00d843fe8a Update hxml defines grammar to haxe 3.4.0-rc.1 2016-12-05 18:45:42 +01:00
tong f1c0f0ebe2 Add haxelib.json grammar extending json 2016-10-29 03:19:44 +02:00
tong 0281d182e4 Update CHANGELOG 2016-10-18 16:24:53 +02:00
tong ced3ed06a5 Grammar: recognize interpreter directives (hashbang), emac, vim mode 2016-10-18 16:18:56 +02:00
tong ec8ec0f138 Snippets: minor cleanup and additions 2016-10-18 15:43:19 +02:00
tong 09ca683171 Sniipe: fix `return snippet` 2016-10-18 15:23:44 +02:00
tong 350f2d2e75 Snippets: more keywords, documentation, std library core types 2016-10-18 15:19:31 +02:00
tong 12d4e775a9 Snippets: remove `continue` line break 2016-10-18 14:47:00 +02:00
tong 086a9dfed3 Merge branch 'master' into dev 2016-10-18 14:43:41 +02:00
tong b631dd3bf8 Merge branch 'master' into dev 2016-10-05 13:49:53 +02:00
tong 20527cab89 Snippets: remove parentheses for Array/List/Map 2016-10-05 13:48:31 +02:00
9 changed files with 254 additions and 20 deletions

View File

@ -1,3 +1,11 @@
## 0.6.0
* Snippets: cast, dynamic, using
* Snippets: std library top level definitions
* Grammars: recognises interpreter directives, emacs modelines, vim modelines
## 0.5.4
* Update grammar to haxe 3.4.0-rc.1
## 0.5.3
* Snippets: remove unnecessary line endings
* Snippets: description urls for Array/List/Map

View File

@ -2,6 +2,25 @@
'name': 'Haxe'
'comment': 'Haxe Syntax: version 3.3.0'
'fileTypes': ['hx']
'firstLineMatch': '''(?x)
# Hashbang
^\\#!.*(?:\\s|\\/)
haxe
(?:$|\\s)
|
# Modeline
(?i:
# Emacs
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
haxe
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*=
haxe
(?=\\s|:|$)
)
'''
'foldingStartMarker': '(\\{\\s*(//.*)?$|^\\s*// \\{\\{\\{|#if)'
'foldingStopMarker': '^\\s*(\\}|// \\}\\}\\}$|#end)'
'patterns': [

View File

@ -0,0 +1,6 @@
'scopeName': 'source.haxelib'
'fileTypes': ['json']
'name': 'haxelib'
'patterns': [
{ 'include': 'source.json' }
]

View File

@ -9,7 +9,7 @@
'name': 'keyword.compiler.arguments.hxml'
}
{
'match': '(absolute-path|advanced-telemetry|annotate-source|as3|check-xml-proxy|core-api|core-api-serialize|cppia|dce|dce-debug|debug|display|display-stdin|dll-export|dll-import|doc-gen|dump|dump-dependencies|dump-ignore-var-ids|dynamic-interface-closures|erase-generics|fast-cast|fdb|file-extension|flash-strict|flash-use-stage|force-lib-check|force-native-property|format-warning|gencommon-debug|haxe-boot|haxe-ver|hxcpp-api-level|include-prefix|interp|java-ver|jquery-ver|js-classic|js-es5|js-unflatten|keep-old-output|loop-unroll-max-cost|lua-jit|lua-ver|macro|macro-times|neko-source|neko-v1|net-target|net-ver|network-sandbox|no-analyzer|no-compilation|no-copt|no-debug|no-deprecation-warnings|no-flash-override|no-inline|no-macro-cache|no-opt|no-pattern-matching|no-root|no-simplify|no-swf-compress|no-traces|objc|php-prefix|real-position|replace-files|scriptable|shallow-expose|source-header|source-map-content|swc|swf-compress-level|swf-debug-password|swf-direct-blit|swf-gpu|swf-metadata|swf-preloader-frame|swf-protected|swf-script-timeout|swf-use-doabc|sys|unsafe|use-nekoc|use-rtti-doc|vcproj)'
'match': '(absolute-path|advanced-telemetry|annotate-source|as3|check-xml-proxy|core-api|core-api-serialize|cppia|dce|dce-debug|debug|display|display-stdin|dll-export|dll-import|doc-gen|dump|dump-dependencies|dump-ignore-var-ids|dynamic-interface-closures|erase-generics|fast-cast|fdb|file-extension|flash-strict|flash-use-stage|force-lib-check|force-native-property|format-warning|gencommon-debug|haxe-boot|haxe-ver|hxcpp-api-level|include-prefix|interp|java-ver|jquery-ver|js-classic|js-es|js-source-map|js-unflatten|keep-old-output|loop-unroll-max-cost|lua-jit|lua-ver|macro|macro-debug|macro-times|neko-source|neko-v1|net-target|net-ver|network-sandbox|no-analyzer|no-compilation|no-copt|no-debug|no-deprecation-warnings|no-flash-override|no-inline|no-macro-cache|no-opt|no-pattern-matching|no-root|no-swf-compress|no-traces|objc|php-prefix|real-position|replace-files|scriptable|shallow-expose|source-header|source-map-content|swc|swf-compress-level|swf-debug-password|swf-direct-blit|swf-gpu|swf-metadata|swf-preloader-frame|swf-protected|swf-script-timeout|swf-use-doabc|sys|unsafe|use-nekoc|use-rtti-doc|vcproj)'
'name': 'keyword.compiler.flags.hxml'
}
{

View File

@ -0,0 +1,63 @@
name: 'Haxe'
scopeName: 'source.haxe'
type: 'tree-sitter'
parser: 'tree-sitter-haxe'
fileTypes: ['hx']
firstLineMatch: '''(?x)
# Hashbang
^\\#!.*(?:\\s|\\/)
haxe
(?:$|\\s)
|
# Modeline
(?i:
# Emacs
-\\*-(?:\\s*(?=[^:;\\s]+\\s*-\\*-)|(?:.*?[;\\s]|(?<=-\\*-))mode\\s*:\\s*)
haxe
(?=[\\s;]|(?<![-*])-\\*-).*?-\\*-
|
# Vim
(?:(?:\\s|^)vi(?:m[<=>]?\\d+|m)?|\\sex)(?=:(?=\\s*set?\\s[^\\n:]+:)|:(?!\\s*set?\\s))(?:(?:\\s|\\s*:\\s*)\\w*(?:\\s*=(?:[^\\n\\\\\\s]|\\\\.)*)?)*[\\s:](?:filetype|ft|syntax)\\s*=
haxe
(?=\\s|:|$)
)
'''
folds: [
{ type: 'comment' }
]
comments:
start: '// '
scopes:
'module': 'source.haxe'
'comment': 'comment.line.double-slash.haxe'
'keyword': 'keyword.control'
'package_statement > keyword': 'keyword.package.haxe'
'import_statement > keyword': 'storage.import.haxe'
'import_statement > attribute > identifier': 'entity.name.type.import.haxe'
'class_declaration > keyword': 'storage.class.haxe'
'class_declaration > identifier': 'entity.name.type.class.haxe'
'class_declaration > attribute > identifier': 'entity.other.inherited-class.haxe'
'function_declaration > keyword': 'keyword.function.haxe'
'function_declaration > identifier': 'entity.name.type.function.haxe'
'variable_declaration > keyword': 'keyword.variable.haxe'
'call > attribute:nth-child(0) > identifier': [
{ match: 'super|trace', scopes: 'support.function.haxe'},
{ match: '^[A-Z]', scopes: 'support.type.contructor' },
'entity.name.function',
]
'attribute > identifier': [
{ match: '^[A-Z]', scopes: 'entity.name.type.package' },
{ match: 'this|super', scopes: 'variable.language.haxe' },
]
'type > identifier': 'support.storage.type'

21
package-lock.json generated Normal file
View File

@ -0,0 +1,21 @@
{
"name": "language-haxe",
"version": "0.6.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"nan": {
"version": "2.15.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.15.0.tgz",
"integrity": "sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ=="
},
"tree-sitter-haxe": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/tree-sitter-haxe/-/tree-sitter-haxe-0.1.0.tgz",
"integrity": "sha512-uhzG4GtA21mZhc38dstae3XLmiFYF0HfW82PLqIZ7E7nUZV3un208BiB0iOTv/uLHv3VyvNPOAVeEQ1eNL+ulQ==",
"requires": {
"nan": "^2.14.2"
}
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "language-haxe",
"version": "0.5.3",
"version": "0.6.0",
"description": "Haxe language support in Atom",
"keywords": [
"haxe",
@ -19,5 +19,7 @@
"atom": ">=1.5.0 <2.0.0",
"node": "*"
},
"dependencies": {}
"dependencies": {
"tree-sitter-haxe": "^0.1.0"
}
}

View File

@ -2,36 +2,30 @@
'#if':
'prefix': '#if'
'body': '#if ${1:define}\n#end\n$0'
'body': '#if ${1:<flag>}\n#end$0'
'description': 'Conditional Compilation'
'descriptionMoreURL': 'http://haxe.org/manual/lf-condition-compilation.html'
'#else':
'prefix': '#else'
'body': '#else\n$0'
'body': '#else$0'
'description': 'Conditional Compilation'
'descriptionMoreURL': 'http://haxe.org/manual/lf-condition-compilation.html'
'#elseif':
'prefix': '#elseif'
'body': '#elseif ${1:define}\n${2}$0'
'body': '#elseif ${1:<flag>}$0'
'description': 'Conditional Compilation'
'descriptionMoreURL': 'http://haxe.org/manual/lf-condition-compilation.html'
'#end':
'prefix': '#end'
'body': '#end\n$0'
'body': '#end$0'
'description': 'Conditional Compilation'
'descriptionMoreURL': 'http://haxe.org/manual/lf-condition-compilation.html'
'#else error':
'prefix': '#error'
'body': '#error "${1:define}"$0'
'body': '#error "${1:<flag>}"$0'
'description': 'Conditional Compilation'
'descriptionMoreURL': 'http://haxe.org/manual/lf-condition-compilation.html'
'trace':
'prefix': 'trace'
'body': 'trace( $1 );$0'
'description': 'Print information'
'descriptionMoreURL': 'http://haxe.org/manual/lf-trace-log.html'
'Line Comment Start':
'prefix': '//'
'body': '// ${1:}$0'
@ -40,6 +34,12 @@
'body': '/**\n\t$1\n*/$0'
'description': 'Block comment'
'trace':
'prefix': 'trace'
'body': 'trace( $1 )$0'
'description': 'Print information'
'descriptionMoreURL': 'http://haxe.org/manual/lf-trace-log.html'
'true':
'prefix': 'true'
'body': 'true'
@ -64,6 +64,11 @@
'body': 'import ${1:<package>};$0'
'description': 'Allow omitting the package name when using a type'
'descriptionMoreURL': 'http://haxe.org/manual/type-system-import.html'
'using':
'prefix': 'using'
'body': 'using ${1:<package>};$0'
'description': 'Pseudo-extend existing types without modifying their source'
'descriptionMoreURL': 'https://haxe.org/manual/lf-static-extension.html'
'private':
'prefix': 'private'
'body': 'private '
@ -73,6 +78,8 @@
'inline':
'prefix': 'inline'
'body': 'inline '
'description': 'Allow insert function body in place'
'descriptionMoreURL': 'https://haxe.org/manual/class-field-inline.html'
'static':
'prefix': 'static'
'body': 'static '
@ -101,28 +108,27 @@
'body': 'default:\n\t${1:statement}'
'return':
'prefix': 'return'
'body': 'return $1;$0'
'body': 'return$0'
'while':
'prefix': 'while'
'body': 'while( ${1:true} ) {\n\t$2\n}$0'
'do..while':
'prefix': 'do '
'body': 'do {\n\t$1\n} while( ${2:true} );$0'
'continue':
'prefix': 'continue'
'body': 'continue;\n$0'
'body': 'continue;$0'
'break':
'prefix': 'break'
'body': 'break;'
'for i in 0...end':
'prefix': 'fori'
'body': 'for( ${1:var} in ${2:0}...${3:end} ) {\n\t${4:expr}\n}\n$0'
'body': 'for( ${1:var} in ${2:0}...${3:end} ) {\n\t${4:expr}\n}$0'
'for a in b':
'prefix': 'for'
'body': 'for( $1 in $2 ) {\n\t$3\n}\n$0'
'body': 'for( ${1:value} in ${2:iterable} ) {\n\t$3\n}\n$0'
'try':
'prefix': 'try'
@ -134,6 +140,13 @@
'prefix': 'throw'
'body': 'throw ${1:expr};$0'
'cast':
'prefix': 'cast'
'body': 'cast( ${1:expr}, ${2:type} )$0'
'cast ':
'prefix': 'cast '
'body': 'cast ${1:expr}$0'
'autotyped var':
'prefix': 'v'
'body': 'var ${1:name} ${2:: ${3:Type}}${4: = }$5;$0'
@ -169,6 +182,9 @@
'prefix': 'set_'
'body': 'function set_${1:name}(${2:v}:${3:Type}) : ${3:Type} \{\n\treturn $4;\n\}$0'
'dynamic':
'prefix': 'dynamic function'
'body': 'dynamic function ${1:<name>}($2) {}$0'
'function':
'prefix': 'function'
'body': 'function ${1:name}( ${2:params} )${3: : ${4:Void}} \{\n\t$5\n\}$0'
@ -255,16 +271,83 @@
'body': 'Array<${1:T}>$0'
'description': 'Collection of elements'
'descriptionMoreURL': 'http://api.haxe.org/Array.html'
'ArrayAccess<T>':
'prefix': 'ArrayAccess<T>'
'body': 'ArrayAccess<${1:T}>$0'
'Bool':
'prefix': 'Bool'
'body': 'Bool$0'
'Class<T>':
'prefix': 'Class'
'body': 'Class<${1:T}>$0'
'Date':
'prefix': 'Date'
'body': 'Date$0'
'Dynamic':
'prefix': 'Dynamic'
'body': 'Dynamic$0'
'EReg':
'prefix': 'EReg'
'body': 'EReg( ${1:r}, ${2:opt} )$0'
'Float':
'prefix': 'Float'
'body': 'Float$0'
'Int':
'prefix': 'Int'
'body': 'Int$0'
'List<T>':
'prefix': 'List'
'body': 'List<${1:T}>$0'
'description': 'A linked-list of elements'
'descriptionMoreURL': 'http://api.haxe.org/List.html'
'Map<K,V>':
'prefix': 'Map'
'prefix': 'Map<K,V>'
'body': 'Map<${1:K},${2:V}>$0'
'description': 'Key to value mapping for arbitrary value types'
'descriptionMoreURL': 'http://api.haxe.org/Map.html'
'Math':
'prefix': 'Math'
'body': 'Math$0'
'Null<T>':
'prefix': 'Null<T>'
'body': 'Null<${1:T}>$0'
'Reflect':
'prefix': 'Reflect'
'body': 'Reflect.$0'
'description': 'Runtime reflection of types and fields'
'descriptionMoreURL': 'http://haxe.org/manual/std-reflection.html'
'Single':
'prefix': 'Single'
'body': 'Single$0'
'description': 'Single-precision IEEE 32bit float (4-byte)'
'Std':
'prefix': 'Std'
'body': 'Std.$0'
'description': 'Standard methods for manipulating basic types'
'String':
'prefix': 'String'
'body': 'String$0'
'StringBuf':
'prefix': 'StringBuf'
'body': 'StringBuf$0'
'StringTools':
'prefix': 'StringTools'
'body': 'StringTools$0'
'Type':
'prefix': 'Type'
'body': 'Type$0'
'UInt':
'prefix': 'UInt'
'body': 'UInt$0'
'ValueType':
'prefix': 'ValueType'
'body': 'ValueType$0'
'Void':
'prefix': 'Void'
'body': 'Void$0'
'Xml':
'prefix': 'Xml'
'body': 'Xml$0'
'XmlType':
'prefix': 'XmlType'
'body': 'XmlType$0'

View File

@ -81,3 +81,35 @@ describe "Haxe Grammar", ->
{tokens} = grammar.tokenizeLine('a.push(' + delim + 'x' + delim + ' + y + ' + delim + ':function()' + delim + ');')
expect(tokens[0]).toEqual value: 'a', scopes: ['source.haxe'] #,'meta.scope.field-completions.haxe']
#expect(tokens[1]).toEqual value: '.', scopes: ['source.haxe']
describe "firstLineMatch", ->
it "recognises interpreter directives", ->
valid = """
#!/usr/sbin/haxe
#!/usr/bin/haxe foo=bar/
#!/usr/sbin/haxe
#!/usr/sbin/haxe foo bar baz
#!/usr/bin/haxe perl
#!/usr/bin/haxe bin/perl
#!/usr/bin/haxe
#!/bin/haxe
#!/usr/bin/haxe --script=usr/bin
#! /usr/bin/env A=003 B=149 C=150 D=xzd E=base64 F=tar G=gz H=head I=tail haxe
#!\t/usr/bin/env --foo=bar haxe --quu=quux
#! /usr/bin/haxe
#!/usr/bin/env haxe
"""
for line in valid.split /\n/
expect( grammar.firstLineRegex.scanner.findNextMatchSync( line ) ).not.toBeNull()
invalid = """
\x20#!/usr/sbin/haxe
\t#!/usr/sbin/haxe
#!/usr/bin/env-haxe/node-env/
#!/usr/bin/env-haxe
#! /usr/binhaxe
#!\t/usr/bin/env --haxe=bar
"""
for line in invalid.split /\n/
expect( grammar.firstLineRegex.scanner.findNextMatchSync( line ) ).toBeNull()
#it "recognises Emacs modelines", ->
#it "recognises Vim modelines", ->