comparison trunk/src/cmd/Generate.d @ 755:90668b83ae5e

Introduced new module dil.SourceText and class SourceText.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 13 Feb 2008 20:21:25 +0100
parents 51e9dfe27f20
children e4b60543c5e8
comparison
equal deleted inserted replaced
754:c7a5499faa77 755:90668b83ae5e
10 dil.ast.Statement, 10 dil.ast.Statement,
11 dil.ast.Expression, 11 dil.ast.Expression,
12 dil.ast.Types; 12 dil.ast.Types;
13 import dil.lexer.Lexer; 13 import dil.lexer.Lexer;
14 import dil.parser.Parser; 14 import dil.parser.Parser;
15 import dil.File; 15 import dil.SourceText;
16 import common;
17
16 import tango.io.Print; 18 import tango.io.Print;
17 import common;
18 19
19 /// Options for the generate command. 20 /// Options for the generate command.
20 enum DocOption 21 enum DocOption
21 { 22 {
22 Empty, 23 Empty,
403 } 404 }
404 405
405 void syntaxToDoc(string filePath, Print!(char) print, DocOption options) 406 void syntaxToDoc(string filePath, Print!(char) print, DocOption options)
406 { 407 {
407 auto tags = options & DocOption.HTML ? html_tags : xml_tags; 408 auto tags = options & DocOption.HTML ? html_tags : xml_tags;
408 auto sourceText = loadFile(filePath); 409 auto parser = new Parser(new SourceText(filePath, true));
409 auto parser = new Parser(sourceText, filePath);
410 auto root = parser.start(); 410 auto root = parser.start();
411 auto lx = parser.lexer; 411 auto lx = parser.lexer;
412 412
413 auto builder = new TokenExBuilder(); 413 auto builder = new TokenExBuilder();
414 auto tokenExList = builder.build(root, lx.firstToken()); 414 auto tokenExList = builder.build(root, lx.firstToken());
448 448
449 /// Prints all tokens of a source file using the buffer print. 449 /// Prints all tokens of a source file using the buffer print.
450 void tokensToDoc(string filePath, Print!(char) print, DocOption options) 450 void tokensToDoc(string filePath, Print!(char) print, DocOption options)
451 { 451 {
452 auto tags = options & DocOption.HTML ? html_tags : xml_tags; 452 auto tags = options & DocOption.HTML ? html_tags : xml_tags;
453 auto sourceText = loadFile(filePath); 453 auto lx = new Lexer(new SourceText(filePath, true));
454 auto lx = new Lexer(sourceText, filePath);
455 lx.scanAll(); 454 lx.scanAll();
456 455
457 print(tags[DocPart.Head]~\n); 456 print(tags[DocPart.Head]~\n);
458 if (lx.errors.length) 457 if (lx.errors.length)
459 { 458 {