   return ret
 
 module.exports = (sami, options) ->
-  errors = []
-  definedLangs = {
-    KRCC: {
-      lang: 'ko'
-      reClassName: new RegExp("class[^=]*?=[\"'\S]*(KRCC)['\"\S]?", 'i')
-    },
-    ENCC: {
-      lang: 'en'
-      reClassName: new RegExp("class[^=]*?=[\"'\S]*(ENCC)['\"\S]?", 'i')
-    },
-    JPCC: {
-      lang: 'ja'
-      reClassName: new RegExp("class[^=]*?=[\"'\S]*(JPCC)['\"\S]?", 'i')
-    }
-  }
 
   parse = () ->
+    error = (error) ->
+      e = new Error(error)
+      e.line = lineNum
+      e.context = element
+      errors.push(e)
+
     lineNum = 1
     ret = []
     tempRet = {}

cssParse = require 'css-parse'
langCodes = require './lang_codes.js'
definedLangs = {}
# from http://coffeescriptcookbook.com/chapters/classes_and_objects/cloning
clone = (obj) ->
  if not obj? or typeof obj isnt 'object'

      errors.push error = new Error('ERROR_INVALID_LANGUAGE_DEFINITION')
      return

  errors = []
  definedLangs = {
    KRCC: {
      lang: 'ko'
      reClassName: new RegExp("class[^=]*?=[\"'\S]*(KRCC)['\"\S]?", 'i')
    },
    KR: {
      lang: 'ko'
      reClassName: new RegExp("class[^=]*?=[\"'\S]*(KR)['\"\S]?", 'i')
    },
    ENCC: {
      lang: 'en'
      reClassName: new RegExp("class[^=]*?=[\"'\S]*(ENCC)['\"\S]?", 'i')
    },
    EGCC: {
      lang: 'en'
      reClassName: new RegExp("class[^=]*?=[\"'\S]*(EGCC)['\"\S]?", 'i')
    },
    EN: {
      lang: 'en'
      reClassName: new RegExp("class[^=]*?=[\"'\S]*(EN)['\"\S]?", 'i')
    },
    JPCC: {
      lang: 'ja'
      reClassName: new RegExp("class[^=]*?=[\"'\S]*(JPCC)['\"\S]?", 'i')
    }
  }

  if options?.definedLangs
    for key, value of options.definedLangs
      definedLangs[key] = value

  sami = sami.trim()
  getDefinedLangs()
  result = parse()
  return {result, errors: errors}
