public static SExpression readProgram ( List < String > filenames , IndexedList < String > symbolTable ) { StringBuilder programBuilder = new StringBuilder ( ) ; programBuilder . append ( "(begin " ) ; for ( String filename : filenames ) { for ( String line : IoUtils . readLines ( filename ) ) { line = line . replaceAll ( "^[ \t]*;.*" , "" ) ; programBuilder . append ( line ) ; programBuilder . append ( " " ) ; } } programBuilder . append ( " )" ) ; String program = programBuilder . toString ( ) ; ExpressionParser < SExpression > parser = ExpressionParser . sExpression ( symbolTable ) ; SExpression programExpression = parser . parse ( program ) ; return programExpression ; }
Reads a program from a list of files . Lines starting with any amount of whitespace followed by ; are ignored as comments .