Se dovessi attraversare codice come questo nei tuoi viaggi, i nomi brevi ti infastidirebbero?
let setPropertyAssignment =
parser {
let! a = setIdentifierName
let! b = propertyName
let! c = openParenthesis
let! d = propertySetParameterList
let! e = closeParenthesis
let! f = openCurlyBracket
let! g = functionBody
let! h = closeCurlyBracket
return Node(NodeType.PropertyAssignment, [a;b;c;d;e;f;g;h])
}
Ecco il parser più grande nel progetto:
let iterationStatement =
parser {
let! a = doKeyWord
let! b = statement
let! c = whileKeyWord
let! d = openParenthesis
let! e = expression
let! f = closeParenthesis
let! g = statementTerminator
let symbols = [a; b; c; d; e; f; g]
return Node(NodeType.IterationStatement, symbols)
} +++ parser {
let! a = whileKeyWord
let! b = openParenthesis
let! c = expression
let! d = closeParenthesis
let! e = statement
let symbols = [a; b; c; d; e]
return Node(NodeType.IterationStatement, symbols)
} +++ parser {
let! a = forKeyWord
let! b = openParenthesis
let! c = maybeOne expressionNoIn
let! d = semiColon
let! e = maybeOne expression
let! f = semiColon
let! g = maybeOne expression
let! h = closeParenthesis
let! i = statement
let symbols = [a;b] @ c @ [d] @ e @ [f] @ g @ [h;i]
return Node(NodeType.IterationStatement, symbols)
} +++ parser {
let! a = forKeyWord
let! b = openParenthesis
let! c = varKeyWord
let! d = variableDeclarationListNoIn
let! e = semiColon
let! f = maybeOne expression
let! g = semiColon
let! h = maybeOne expression
let! i = closeParenthesis
let! j = statement
let symbols = [a;b;c;d;e] @ f @ [g] @ h @ [i;j]
return Node(NodeType.IterationStatement, symbols)
} +++ parser {
let! a = forKeyWord
let! b = openParenthesis
let! c = leftHandSideExpression
let! d = inKeyWord
let! e = expression
let! f = closeParenthesis
let! g = statement
let symbols = [a;b;c;d;e;f;g]
return Node(NodeType.IterationStatement, symbols)
} +++ parser {
let! a = forKeyWord
let! b = openParenthesis
let! a = varKeyWord
let! c = variableDeclarationNoIn
let! a = inKeyWord
let! c = expression
let! d = closeParenthesis
let! e = statement
let symbols = [a; b; c; d; e]
return Node(NodeType.IterationStatement, symbols)
}