{
  "_comment": "Configuración del lenguaje AVAP para el chunker genérico. Basada en el LRM (Language Reference Manual) de AVAP.",

  "language": "avap",
  "version": "1.0",
  "file_extensions": [".avap"],

  "lexer": {
    "string_delimiters": ["\"", "'"],
    "escape_char": "\\",
    "comment_line":  ["///", "//"],
    "comment_block": { "open": "/*", "close": "*/" },
    "line_oriented": true
  },

  "blocks": [
    {
      "name": "function",
      "doc_type": "code",
      "opener_pattern": "^\\s*function\\s+(\\w+)\\s*\\(([^)]*)",
      "closer_pattern": "^\\s*\\}\\s*$",
      "extract_signature": true,
      "signature_template": "function {group1}({group2})"
    },
    {
      "name": "if",
      "doc_type": "code",
      "opener_pattern": "^\\s*if\\s*\\(",
      "closer_pattern": "^\\s*end\\s*\\(\\s*\\)"
    },
    {
      "name": "startLoop",
      "doc_type": "code",
      "opener_pattern": "^\\s*startLoop\\s*\\(",
      "closer_pattern": "^\\s*endLoop\\s*\\(\\s*\\)"
    },
    {
      "name": "try",
      "doc_type": "code",
      "opener_pattern": "^\\s*try\\s*\\(\\s*\\)",
      "closer_pattern": "^\\s*end\\s*\\(\\s*\\)"
    }
  ],

  "statements": [
    { "name": "registerEndpoint", "pattern": "^\\s*registerEndpoint\\s*\\(" },
    { "name": "addVar",           "pattern": "^\\s*addVar\\s*\\(" },
    { "name": "io_command",       "pattern": "^\\s*(addParam|getListLen|addResult|getQueryParamList)\\s*\\(" },
    { "name": "http_command",     "pattern": "^\\s*(RequestPost|RequestGet)\\s*\\(" },
    { "name": "orm_command",      "pattern": "^\\s*(ormDirect|ormCheckTable|ormCreateTable|ormAccessSelect|ormAccessInsert|ormAccessUpdate)\\s*\\(" },
    { "name": "util_command",     "pattern": "^\\s*(variableToList|itemFromList|variableFromJSON|AddVariableToJSON|encodeSHA256|encodeMD5|getRegex|getDateTime|stampToDatetime|getTimeStamp|randomString|replace)\\s*\\(" },
    { "name": "async_command",    "pattern": "^\\s*(\\w+\\s*=\\s*go\\s+|gather\\s*\\()" },
    { "name": "connector",        "pattern": "^\\s*\\w+\\s*=\\s*avapConnector\\s*\\(" },
    { "name": "modularity",       "pattern": "^\\s*(import|include)\\s+" },
    { "name": "assignment",       "pattern": "^\\s*\\w+\\s*=\\s*" }
  ],

  "semantic_tags": [
    { "tag": "uses_orm",             "pattern": "\\b(ormDirect|ormCheckTable|ormCreateTable|ormAccessSelect|ormAccessInsert|ormAccessUpdate)\\s*\\(" },
    { "tag": "uses_http",            "pattern": "\\b(RequestPost|RequestGet)\\s*\\(" },
    { "tag": "uses_connector",       "pattern": "\\bavapConnector\\s*\\(" },
    { "tag": "uses_async",           "pattern": "\\bgo\\s+\\w+\\s*\\(|\\bgather\\s*\\(" },
    { "tag": "uses_crypto",          "pattern": "\\b(encodeSHA256|encodeMD5)\\s*\\(" },
    { "tag": "uses_auth",            "pattern": "\\b(addParam|_status)\\b" },
    { "tag": "uses_error_handling",  "pattern": "\\btry\\s*\\(\\s*\\)" },
    { "tag": "uses_loop",            "pattern": "\\bstartLoop\\s*\\(" },
    { "tag": "uses_json",            "pattern": "\\b(variableFromJSON|AddVariableToJSON)\\s*\\(" },
    { "tag": "uses_list",            "pattern": "\\b(variableToList|itemFromList|getListLen)\\s*\\(" },
    { "tag": "uses_regex",           "pattern": "\\bgetRegex\\s*\\(" },
    { "tag": "uses_datetime",        "pattern": "\\b(getDateTime|getTimeStamp|stampToDatetime)\\s*\\(" },
    { "tag": "returns_result",       "pattern": "\\baddResult\\s*\\(" },
    { "tag": "registers_endpoint",   "pattern": "\\bregisterEndpoint\\s*\\(" }
  ]
}
