demangle.go
func (st *state) templateArg() AST {
	if len(st.str) == 0 {
		st.fail("missing template argument")
	}
	switch st.str[0] {
	case 'X':
		st.advance(1)
		expr := st.expression()
		if len(st.str) == 0 || st.str[0] != 'E' {
			st.fail("missing end of expression")
		}
		st.advance(1)
		return expr

	case 'L':
		return st.exprPrimary()

	case 'I', 'J':
		args := st.templateArgs()
		return &ArgumentPack{Args: args}

	default:
		return st.demangleType(false)
	}
}
func (st *state) templateArg() AST {
	if len(st.str) == 0 {
		st.fail("missing template argument")
	}
	switch st.str[0] {
	case 'X':
		st.advance(1)
		expr := st.expression()
		if len(st.str) == 0 || st.str[0] != 'E' {
			st.fail("missing end of expression")
		}
		st.advance(1)
		return expr

	case 'L':
		return st.exprPrimary()

	case 'I', 'J':
		args := st.templateArgs()
		return &ArgumentPack{Args: args}

	default:
		return st.demangleType(false)
	}
}
func ( st * state ) templateArg ( ) AST { if len ( st . str ) == 0 { st . fail ( " " ) } switch st . str [ 0 ] { case 'X' : st . advance ( 1 ) expr := st . expression ( ) if len ( st . str ) == 0 || st . str [ 0 ] != 'E' { st . fail ( " " ) } st . advance ( 1 ) return expr case 'L' : return st . exprPrimary ( ) case 'I' , 'J' : args := st . templateArgs ( ) return & ArgumentPack { Args : args } default : return st . demangleType ( false ) } }
// <template-arg> ::= <type>
//                ::= X <expression> E
//                ::= <expr-primary>
<template - arg > :: = <type > :: = X <expression > E :: = <expr - primary >