###############################################################################
#
# StrExtractor.tcl --
#
# Extensible Adaptable Generalized Logic Engine (Eagle)
# String Extraction Tool (UNFINISHED)
#
# Copyright (c) 2007-2012 by Joe Mistachkin.  All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: $
#
###############################################################################

set path [file normalize [file dirname [info script]]]
set lib_path [file join $path ".." ".." "lib"]

lappend auto_path $lib_path
package require Eagle.Library 1.0
namespace import -force ::Eagle::*

set inner {(([^\"]|[\\\"])*)}

set pattern(1) {result = \"} $inner {\";\s*}
set pattern(2) {error = \"} $inner {\";\s*}
set pattern(3) {localResult = \"} $inner {\";\s*}
set pattern(4) {localError = \"} $inner {\";\s*}

set pattern(5) {result = String.Format\((.*)\);\s*}
set pattern(6) {error = String.Format\((.*)\);\s*}
set pattern(7) {localResult = String.Format\((.*)\);\s*}
set pattern(8) {localError = String.Format\((.*)\);\s*}

set subSpec(1) {result = ResourceOps.GetString(\1);}
set subSpec(2) {error = ResourceOps.GetString(\1);}
set subSpec(3) {localResult = ResourceOps.GetString(\1);}
set subSpec(4) {localError = ResourceOps.GetString(\1);}

if {$argc == 1} then {
  #
  # TODO: Make this work.
  #

  # match the patterns in the pattern array...
  # extract string, generate ID, and add to internal dictionary (if not already there).
  # post-process extracted string to normalize \" to " and to concat 
  # replace extracted string with call to ResourceOps.GetString(interpreter, id, ...)

} else {
  puts stderr "usage: [file tail [info nameofexecutable]] [file tail [info script]] <path>"
}
