diff --git a/mode/puppet/puppet.js b/mode/puppet/puppet.js
index b407ded883b9bbbbe0b4f918caafd5fe645d3750..e7f799f78a3de993190c6a8809efa0e3b3d04303 100644
--- a/mode/puppet/puppet.js
+++ b/mode/puppet/puppet.js
@@ -140,11 +140,11 @@ CodeMirror.defineMode("puppet", function () {
       return words[word];
     }
     // Is there a match on a reference?
-    if (/(\s+)?[A-Z]/.test(word)) {
+    if (/(^|\s+)[A-Z][\w:_]+/.test(word)) {
       // Negate the next()
       stream.backUp(1);
       // Match the full reference
-      stream.match(/(\s+)?[A-Z][\w:_]+/);
+      stream.match(/(^|\s+)[A-Z][\w:_]+/);
       return 'def';
     }
     // Have we matched the prior resource regex?