Function paren_lexar2(a_sts As String) As String
'再帰版
Dim token, peek, derived
token = Split(get_token(a_sts, peek:=True), ",")
If token(ATTR) = "(" Then
derived = par_exp()
Else
derived = PARSE_ERROR
End If
paren_lexar2 = derived
End Function
Function par_exp()
'括弧式
token = Split(get_token(""), ",")
peek = Split(get_token("", peek:=True), ",")
Select Case True
Case peek(CLASS) = "ALF"
derived = alf_exp()
Case peek(CLASS) = "NUM"
derived = num_exp()
Case peek(ATTR) Like "("
Case peek(ATTR) Like ")"
derived = ""
Case Else
End Select
par_exp = derived
Function alf_exp()
'アルファベット式
If token(CLASS) = "ALF" Then
If peek(ATTR) = "(" Then
derived = token(ATTR) & par_exp()
ElseIf peek(ATTR) = ")" Then
derived = token(ATTR)
Function paren_lexar2(a_sts As String) As String
'再帰版
Dim token, peek, derived
token = Split(get_token(a_sts, peek:=True), ",")
If token(ATTR) = "(" Then
derived = par_exp()
Else
derived = PARSE_ERROR
End If
paren_lexar2 = derived
End Function
Function par_exp()
'括弧式
Dim token, peek, derived
token = Split(get_token(""), ",")
If token(ATTR) = "(" Then
peek = Split(get_token("", peek:=True), ",")
Select Case True
Case peek(CLASS) = "ALF"
derived = alf_exp()
Case peek(CLASS) = "NUM"
derived = num_exp()
Case peek(ATTR) Like "("
derived = par_exp()
Case peek(ATTR) Like ")"
derived = ""
Case Else
derived = PARSE_ERROR
End Select
Else
derived = PARSE_ERROR
End If
par_exp = derived
End Function
Function alf_exp()
'アルファベット式
Dim token, peek, derived
token = Split(get_token(""), ",")
If token(CLASS) = "ALF" Then
peek = Split(get_token("", peek:=True), ",")
If peek(ATTR) = "(" Then
derived = token(ATTR) & par_exp()
ElseIf peek(ATTR) = ")" Then
derived = token(ATTR)
Else
derived = PARSE_ERROR
End If