Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Serialization for AST #210

Closed
70 tasks done
turbolent opened this issue Jul 5, 2020 · 0 comments · Fixed by #307
Closed
70 tasks done

JSON Serialization for AST #210

turbolent opened this issue Jul 5, 2020 · 0 comments · Fixed by #307
Assignees

Comments

@turbolent
Copy link
Member

turbolent commented Jul 5, 2020

Context

To be able to process the AST outside of Go, for example to visualize it in an AST explorer, or use it for pretty-printing, the JSON representation must be improved:

  • Type information is necessary, e.g. to distinguish a boolean from a nil expression
  • Position information must be eagerly included. The internal representation computes it sometimes from child elements

Definition of Done

Implement and test json.MarshalJSON for the following types, adding a Type property where the element is polymorphic (e.g. expressions), and position information as StartPos and EndPos properties:

  • Access
  • Argument
  • Block
  • FunctionBlock
  • Condition
  • CompositeDeclaration
  • FieldDeclaration
  • ConditionKind
  • BoolExpression
  • NilExpression
  • StringExpression
  • IntegerExpression
  • FixedPointExpression
  • ArrayExpression
  • DictionaryExpression
  • IdentifierExpression
  • InvocationExpression
  • MemberExpression
  • IndexExpression
  • ConditionalExpression
  • UnaryExpression
  • BinaryExpression
  • FunctionExpression
  • CastingExpression
  • CreateExpression
  • DestroyExpression
  • ReferenceExpression
  • ForceExpression
  • PathExpression
  • FunctionDeclaration
  • SpecialFunctionDeclaration
  • ImportDeclaration
  • Identifier
  • IdentifierLocation
  • StringLocation
  • AddressLocation
  • InterfaceDeclaration
  • Members
  • Operation
  • Parameter
  • ParameterList
  • Program
  • ReturnStatement
  • BreakStatement
  • ContinueStatement
  • IfStatement
  • WhileStatement
  • ForStatement
  • EmitStatement
  • AssignmentStatement
  • SwapStatement
  • ExpressionStatement
  • TransactionDeclaration
  • Transfer
  • TransferOperation
  • TypeAnnotation
  • NominalType
  • OptionalType
  • VariableSizedType
  • ConstantSizedType
  • DictionaryType
  • FunctionType
  • ReferenceType
  • RestrictedType
  • InstantiationType
  • VariableDeclaration
  • VariableKind
  • DeclarationKind
  • CompositeKind
  • PragmaDeclaration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant