
1 // 2 // Copyright (c) 2006, Brian Frank and Andy Frank 3 // Licensed under the Academic Free License version 3.0 4 // 5 // History: 6 // 15 Sep 05 Brian Frank Creation 7 // 3 Jun 06 Brian Frank Ported from Java to Fan - Megan's b-day! 8 // 9 10 ** 11 ** Node is the base class of all classes which represent a node 12 ** in the abstract syntax tree generated by the parser. 13 ** 14 abstract class Node 15 { 16 17 ////////////////////////////////////////////////////////////////////////// 18 // Construction 19 ////////////////////////////////////////////////////////////////////////// 20 21 ** 22 ** All Node's must have a valid location in a source file. 23 ** 24 new make(Location location) 25 { 26 if (location == null) 27 throw NullErr.make("null location") 28 29 this.location = location 30 } 31 32 ////////////////////////////////////////////////////////////////////////// 33 // Debug 34 ////////////////////////////////////////////////////////////////////////// 35 36 ** 37 ** Print to std out 38 ** 39 Void dump() 40 { 41 print(AstWriter.make) 42 } 43 44 ** 45 ** Pretty print this node and it's descendants. 46 ** 47 abstract Void print(AstWriter out) 48 49 ////////////////////////////////////////////////////////////////////////// 50 // Fields 51 ////////////////////////////////////////////////////////////////////////// 52 53 readonly Location location 54 55 }