Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add example to showcase semantic highlighting

  • Loading branch information...
commit 0249104d9b9ef115b0cec2cc3574e28ff2b1df8b 1 parent 7b15c4a
Peter Odding authored May 25, 2011

Showing 1 changed file with 41 additions and 0 deletions. Show diff stats Hide diff stats

  1. 41  example.lua
41  example.lua
... ...
@@ -0,0 +1,41 @@
  1
+-- A local variable masking a global one:
  2
+global_variable = '1st value'
  3
+do
  4
+  local global_variable = 'NOT ACTUALLY A GLOBAL!'
  5
+  print(global_variable)
  6
+end
  7
+global_variable = '2nd value'
  8
+
  9
+-- Highlighting for different types of locals:
  10
+local usedlocal = 'this is a local variable'
  11
+local mutated = "this one's assigned multiple times"
  12
+local unused = "and this one isn't referenced anywhere"
  13
+mutated = 'this is the second value of [mutated]'
  14
+print(usedlocal)
  15
+print(undefined)
  16
+
  17
+io.open('')
  18
+string.lower('')
  19
+local tinsert = table.insert
  20
+local test = { field = function(foo, bar, baz) print(baz) end }
  21
+
  22
+-- Highlighting for function arguments:
  23
+local function example(usedparam, mutatedparam, unusedparam)
  24
+  mutatedparam = 42
  25
+  print(usedparam)
  26
+end
  27
+
  28
+-- Argument count checking:
  29
+
  30
+  example(1)
  31
+
  32
+for k, v in pairs(_G) do print(k) end
  33
+
  34
+  example (
  35
+    1,
  36
+    2,
  37
+    3,
  38
+    4)
  39
+
  40
+-- Syntax errors:
  41
+-- example(..)

0 notes on commit 0249104

Please sign in to comment.
Something went wrong with that request. Please try again.