Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #34 from petems/fix_variables_starting_with_unders…
Browse files Browse the repository at this point in the history
…core

Allows variables starting with underscores
  • Loading branch information
Wliu authored and Wliu committed Mar 15, 2016
2 parents 4f5b7a1 + 880801c commit c2cf946
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion grammars/puppet.cson
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@
'captures':
'1':
'name': 'punctuation.definition.variable.puppet'
'match': '(\\$)([a-zA-Zx7f-xff\\$]|::)([a-zA-Z0-9_x7f-xff\\$]|::)*\\b'
'match': '(\\$)((::)?[a-z]\\w*)*((::)?[a-z_]\\w*)\\b'
'name': 'variable.other.readwrite.global.puppet'
}
{
Expand Down
17 changes: 17 additions & 0 deletions spec/puppet-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,20 @@ describe "Puppet grammar", ->
it "tokenizes require => variable as a parameter", ->
{tokens} = grammar.tokenizeLine("require => Class['foo']")
expect(tokens[0]).toEqual value: 'require ', scopes: ['source.puppet', 'constant.other.key.puppet']

it "tokenizes regular variables", ->
{tokens} = grammar.tokenizeLine('$foo')
expect(tokens[0]).toEqual value: '$', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet', 'punctuation.definition.variable.puppet']
expect(tokens[1]).toEqual value: 'foo', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet']

{tokens} = grammar.tokenizeLine('$_foo')
expect(tokens[0]).toEqual value: '$', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet', 'punctuation.definition.variable.puppet']
expect(tokens[1]).toEqual value: '_foo', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet']

{tokens} = grammar.tokenizeLine('$_foo_')
expect(tokens[0]).toEqual value: '$', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet', 'punctuation.definition.variable.puppet']
expect(tokens[1]).toEqual value: '_foo_', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet']

{tokens} = grammar.tokenizeLine('$::foo')
expect(tokens[0]).toEqual value: '$', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet', 'punctuation.definition.variable.puppet']
expect(tokens[1]).toEqual value: '::foo', scopes: ['source.puppet', 'variable.other.readwrite.global.puppet']

0 comments on commit c2cf946

Please sign in to comment.