function parse (input) {
  const result = {}
  const re = /(\w[\w-]*)(\([^\)]+\))?(?=:|$)/g
  let match
  while ((match = re.exec(input)) !== null) {
    if (match[2]) {
      const args = []
      for (const item of match[2].slice(1, -1).split(',')) {
        const number = parseInt(item, 10)
        args.push(Number.isNaN(number) ? item : number)
      }
      result[match[1]] = args
    } else {
      result[match[1]] = true
    }
  }
  return result
}

const input = 'abcd java:run(java:bar):foo(abc_1,-1)'
const ast = parse(input)
console.log(ast)
console.log('first = ', Object.keys(ast)[0])

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: