Changeset 290 for trunk/enki

Show
Ignore:
Timestamp:
03/31/08 14:50:53 (9 months ago)
Author:
h3r3tic
Message:

incorporated bobef's Tango patch for enki.d; thanks!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/enki/BaseParser.d

    r289 r290  
    8080    /** error handling **/ 
    8181    protected void setError(String text){ 
    82         debug writefln("[%d] Error: %s",pos,text); 
     82        debug Stdout.formatln("[{}] Error: {}",pos,text); 
    8383        ErrorData data; 
    8484        data.pos = pos; 
  • trunk/enki/enki.d

    r235 r290  
    11/+ 
    2     Copyright (c) 2006 Eric Anderton 
     2    Copyright (c) 2006 Eric Anderton 
    33 
    4     Permission is hereby granted, free of charge, to any person 
    5     obtaining a copy of this software and associated documentation 
    6     files (the "Software"), to deal in the Software without 
    7     restriction, including without limitation the rights to use, 
    8     copy, modify, merge, publish, distribute, sublicense, and/or 
    9     sell copies of the Software, and to permit persons to whom the 
    10     Software is furnished to do so, subject to the following 
    11     conditions: 
     4    Permission is hereby granted, free of charge, to any person 
     5    obtaining a copy of this software and associated documentation 
     6    files (the "Software"), to deal in the Software without 
     7    restriction, including without limitation the rights to use, 
     8    copy, modify, merge, publish, distribute, sublicense, and/or 
     9    sell copies of the Software, and to permit persons to whom the 
     10    Software is furnished to do so, subject to the following 
     11    conditions: 
    1212 
    13     The above copyright notice and this permission notice shall be 
    14     included in all copies or substantial portions of the Software. 
     13    The above copyright notice and this permission notice shall be 
     14    included in all copies or substantial portions of the Software. 
    1515 
    16     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    17     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
    18     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    19     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
    20     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
    21     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
    22     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
    23     OTHER DEALINGS IN THE SOFTWARE. 
     16    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
     17    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
     18    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
     19    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
     20    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 
     21    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
     22    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
     23    OTHER DEALINGS IN THE SOFTWARE. 
    2424+/ 
    2525module enki.enki; 
     
    3131private import utils.ArgParser; 
    3232 
    33 private import std.stdio; 
    34 private import std.file; 
     33private import tango.io.FilePath; 
     34private import tango.io.File; 
     35private import tango.io.Console; 
     36private import tango.io.Stdout; 
    3537 
    36 char[] helpText =  
    37 `Enki - Frontend Parser Generator - V1.2 Build %d 
     38char[] helpText = 
     39`Enki - Frontend Parser Generator - V1.2 Build {} 
    3840Copyright(c) 2006 Eric Anderton 
    3941 
     
    4244 
    4345Usage: 
    44   enki <source ebnf file> { -switch } 
    45    
    46   -f<file>  Specify output filename  
     46  enki <source ebnf file> {{ -switch } 
     47  
     48  -f<file>  Specify output filename 
    4749  -b<file>  Specify output ebnf filename 
    48   -t        Test Mode (output everything to console) 
    49    
     50  -t         Test Mode (output everything to console) 
     51  
    5052The -b option is used primarily as a sanity check of 
    5153enki's internal workings.  The generated output is 
     
    5961void main(char[][] args){ 
    6062    if(args.length == 1){ 
    61         writefln(helpText,auto_build_number); 
     63        Stdout.format(helpText,auto_build_number); 
    6264        return 0; 
    6365    } 
     
    98100        throw new Exception("No filename specified."); 
    99101    } 
    100      
    101     if(!isfile(inputFilename)){ 
     102 
     103    auto fp=FilePath(inputFilename); 
     104    if(!fp.exists || fp.isFolder){ 
    102105        throw new Exception("File '" ~ inputFilename ~ "' doesn't exist."); 
    103106    } 
     
    115118    // run the Enki Parser 
    116119    auto parser = new EnkiParser(); 
    117     parser.initalize(cast(char[])std.file.read(inputFilename)); 
     120    parser.initalize(cast(char[])File(inputFilename).read); 
    118121    auto result = parser.parse_Syntax(); 
    119122     
     
    122125         
    123126        if(testMode){ 
    124             writefln("Parser:\n %s",parser.render()); 
     127            Cout("Parser:\n ")(parser.render()); 
    125128        } 
    126129        else{ 
    127             std.file.write(outputFilename,parser.render()); 
     130            File(outputFilename).write(parser.render()); 
    128131        } 
    129132         
    130133        if(ebnfFilename){ 
    131134            if(testMode){ 
    132                 writefln("\nBNF:\n %s",parser.toBNF()); 
     135                Cout("\nBNF:\n ")(parser.toBNF()); 
    133136            } 
    134137            else{ 
    135                 std.file.write(ebnfFilename,parser.toBNF()); 
     138                File(ebnfFilename).write(parser.toBNF()); 
    136139            } 
    137140        } 
    138141    } 
    139142    else{ 
    140         writefln("\nErrors:\n%s",parser.getErrorReport());     
     143        Cout("\nErrors:\n")(parser.getErrorReport());  
    141144    } 
    142145}