Modeling ASTs with FAST (mooseday13)

Modeling ASTs with FAST (mooseday13)

9847702de1f7f19db8c3e158325baa8e?s=128

Yuriy Tymchuk

April 04, 2013
Tweet

Transcript

  1. 2.
  2. 3.
  3. 4.
  4. 6.

    PROBLEM? • Calculating metrics • Rule checking • Detecting duplication

    • Representing (eg. visualizing) • Language conversions • And more…
  5. 8.
  6. 10.
  7. 12.
  8. 13.

    GENERAL FAST DIAGRAM FASTBehaviouralEntity 0..* statements 0..1 parentStatementBlock FASTStatement FASTNamedEntity

    name : String 0..* parameters 0..* localVariables FAMIXBehaviouralEntity 0..1 fastNamedBehaviouralEntity 0..1 famixBehaviouralEntity FAMIXNamedEntity 0..* fastNamedEntities 0..1 famixNamedEntity FASTNamedBehaviouralEntity name : String FASTExpression 0..1 parentBehaviouralEntity 0..1 parentExpression** 0..1 parentStatement** FASTStatementBlock 0..1 parentBehaviouralEntity 0..1 statementBlock FASTVariableExpression 0..1 parentVariableExpression 0..1 variable FASTLiteral signature : string
  9. 14.

    SMALLTALK FAST DIAGRAM FASTBehaviouralEntity 0..* statements 0..1 parentStatementBlock FASTVariableExpression FASTLiteral

    signature : String FASTMessageSend kind selector isUnary() isBinary() isKey() cascaded() receiver() FASTStatement 0..1 parentExpression 0..* arguments FASTAssignmentExpression 0..1 parentAssignmentExpression 0..1 variable FASTExpression 0..1 parentStatement 0..1 expression FASTArrayExpression FASTCascade 0..1 parentCascade 0..* messages 0..1 parentExpression 0..1 concreteReceiver 0..1 parentExpression 0..1 block FASTSmalltalkReturnStatement FASTSmalltalkExpressionStatement 0..1 parentStatement 0..1 expression 0..1 parentExpression 0..1 expression FASTNamedEntity name : String 0..* parameters 0..* localVariables 0..1 parentVariableExpression 0..1 variable FASTBlockDefinition FAMIXBehaviouralEntity 0..1 fastNamedBehaviouralEntity 0..1 famixBehaviouralEntity FAMIXNamedEntity 0..* fastNamedEntities 0..1 famixNamedEntity FASTNamedBehaviouralEntity name : String FASTNumberLiteral value : Number FASTCharacterLiteral value : Object FASTStringLiteral value : String FASTSymbolLiteral value : Object FASTArrayLiteral FASTByteArrayLiteral 0..* contents 0..* contents FASTBlockExpression 0..1 parentExpression 0..* contents FASTBooleanLiteral value : Boolean FASTUndefinedLiteral 0..1 parentExpression 0..1 receiver 0..1 parentBehaviouralEntity FAMIXInvocation 0..1 messageSend 0..1 invocation FASTStatementBlock 0..1 parentBehaviouralEntity 0..1 statementBlock
  10. 19.

    JAVA FAST DIAGRAM FASTBehaviouralEntity 0..* statements 0..1 parentStatementBlock FASTStatement FASTNamedEntity

    name : String 0..* parameters 0..* localVariables FAMIXBehaviouralEntity 0..1 fastNamedBehaviouralEntity 0..1 famixBehaviouralEntity FAMIXNamedEntity 0..* fastNamedEntities 0..1 famixNamedEntity FASTNamedBehaviouralEntity name : String FASTExpression 0..1 parentBehaviouralEntity StatementBlock 0..1 parentBehaviouralEntity 0..1 statementBlock FASTVariableExpression 0..1 parentVariableExpression 0..1 variable FASTLiteral signature : string FASTJavaExpressionStatement FASTJavaReturnStatement 0..1 parentStatement 0..1 expression 0..1 parentStatement 0..1 expression FASTWhileStatement 0..1 parentStatement 0..1 condition 0..1 parentStatement 0..1 body FASTVariableDeclarationStatement FASTVariableDeclarator 0..1 parentStatement 0..* declarators 0..1 variable 0..1 initializer FASTJavaIntegerLiteral FASTJavaBooleanLiteral FASTJavaStringLiteral FASTInfixOperation 0..1 parentExpression 0..1 leftOperand 0..1 parentExpression 0..1 rightOperand
  11. 21.

    SYMBOL RESOLUTION #middleOf:and: b a sum ^st st := sum

    + a b / sum 2 middleOf: a and: b | sum | sum := a + b. ^ sum / 2
  12. 24.

    RESOLVING SYMBOLS Scope • name-variable dictionary • parent scope •

    owner entity Scope • name-variable dictionary • parent scope • owner entity
  13. 27.

    CYCLOMATIC COMPLEXITY Each node knows it’s complexity contribution • Class

    = 0 • ReturnStatement = 0 • IfStatement = 1 • WhileStatement = 1 • MessageSend (#ifTrue:) = 1! ! ! ! calculated at runtime • MessageSend (#detect:ifNone:) = 2 • “for ... else” statement = 2!! ! ! ! python
  14. 29.

    FAST GSOC FAST Java Model Tree models visualization The idea

    behind this project is to develop an inter active tree visualization that will gradually improve analysis of the underlying model. The goal of this project is to create a Java version of FAST.
  15. 31.