Skip to content

Instantly share code, notes, and snippets.

@cgewecke
Created June 12, 2017 22:44
Show Gist options
  • Save cgewecke/6cec3b3d2356c5533fa6f696a809ffa9 to your computer and use it in GitHub Desktop.
Save cgewecke/6cec3b3d2356c5533fa6f696a809ffa9 to your computer and use it in GitHub Desktop.

AST output for:

Voter airbnb = Voter({
    weight: 2,
    voted: true,
  });
{
 "type": "StateVariableDeclaration",
 "name": "airbnb",
 "literal": {
  "type": "Type",
  "literal": "Voter",
  "members": [],
  "array_parts": [],
  "start": 8812,
  "end": 8817
 },
 "visibility": null,
 "is_constant": false,
 "value": {
  "type": "CallExpression",
  "callee": {
   "type": "Identifier",
   "name": "Voter",
   "start": 8827,
   "end": 8832
  },
  "arguments": [
   {
    "type": "NameValueAssignment",
    "name": {
     "type": "Identifier",
     "name": "weight",
     "start": 8841,
     "end": 8847
    },
    "value": {
     "type": "Literal",
     "value": 2,
     "start": 8849,
     "end": 8850
    },
    "start": 8841,
    "end": 8850
   },
   {
    "type": "NameValueAssignment",
    "name": {
     "type": "Identifier",
     "name": "voted",
     "start": 8858,
     "end": 8863
    },
    "value": {
     "type": "Literal",
     "value": true,
     "start": 8865,
     "end": 8869
    },
    "start": 8858,
    "end": 8869
   }
  ],
  "start": 8827,
  "end": 8877
 },
 "start": 8812,
 "end": 8878
}

AST output for:

Voter me = Voter({
    weight: 2,
    voted: abstain()
});
{
 "type": "StateVariableDeclaration",
 "name": "me",
 "literal": {
  "type": "Type",
  "literal": "Voter",
  "members": [],
  "array_parts": [],
  "start": 8736,
  "end": 8741
 },
 "visibility": null,
 "is_constant": false,
 "value": {
  "type": "CallExpression",
  "callee": {
   "type": "Identifier",
   "name": "Voter",
   "start": 8747,
   "end": 8752
  },
  "arguments": [
   {
    "type": "NameValueAssignment",
    "name": {
     "type": "Identifier",
     "name": "weight",
     "start": 8763,
     "end": 8769
    },
    "value": {
     "type": "Literal",
     "value": 2,
     "start": 8771,
     "end": 8772
    },
    "start": 8763,
    "end": 8772
   },
   {
    "type": "NameValueAssignment",
    "name": {
     "type": "Identifier",
     "name": "voted",
     "start": 8782,
     "end": 8787
    },
    "value": {
     "type": "CallExpression",
     "callee": {
      "type": "Identifier",
      "name": "abstain",
      "start": 8789,
      "end": 8796
     },
     "arguments": [],
     "start": 8789,
     "end": 8798
    },
    "start": 8782,
    "end": 8803
   }
  ],
  "start": 8747,
  "end": 8805
 },
 "start": 8736,
 "end": 8806
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment