###############################################################################
#
# parser2.eagle --
#
# Extensible Adaptable Generalized Logic Engine (Eagle)
#
# 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: $
#
###############################################################################

source [file join [file normalize [file dirname [info script]]] prologue.eagle]

###############################################################################

#
# NOTE: *MONO* Disabled due to Enum.ToString() differences.
#
runTest {test parser-2.1 {scripting of command parser} -body {
  parse command {set a 2; set b [set a]; version; # comment}
} -cleanup {
  unset -nocomplain a b
} -constraints {eagle dotNet} -result {{NotReady False} {IsImmutable False}\
{Flags Default} {FileName {}} {CurrentLine 1} {CommentStart -1} {CommentLength\
0} {CommandStart 0} {CommandLength 8} {CommandWords 3} {Tokens 6} {IsImmutable\
False} {Type SimpleWord} {SyntaxType None} {Flags None} {FileName {}}\
{StartLine 1} {EndLine 1} {ViaSource False} {Start 0} {Length 3} {Components 1}\
{Text set} {ClientData {}} {IsImmutable False} {Type Text} {SyntaxType None}\
{Flags None} {FileName {}} {StartLine 1} {EndLine 1} {ViaSource False} {Start\
0} {Length 3} {Components 0} {Text set} {ClientData {}} {IsImmutable False}\
{Type SimpleWord} {SyntaxType None} {Flags None} {FileName {}} {StartLine 1}\
{EndLine 1} {ViaSource False} {Start 4} {Length 1} {Components 1} {Text a}\
{ClientData {}} {IsImmutable False} {Type Text} {SyntaxType None} {Flags None}\
{FileName {}} {StartLine 1} {EndLine 1} {ViaSource False} {Start 4} {Length 1}\
{Components 0} {Text a} {ClientData {}} {IsImmutable False} {Type SimpleWord}\
{SyntaxType None} {Flags None} {FileName {}} {StartLine 1} {EndLine 1}\
{ViaSource False} {Start 6} {Length 1} {Components 1} {Text 2} {ClientData {}}\
{IsImmutable False} {Type Text} {SyntaxType None} {Flags None} {FileName {}}\
{StartLine 1} {EndLine 1} {ViaSource False} {Start 6} {Length 1} {Components 0}\
{Text 2} {ClientData {}}}}

###############################################################################

runTest {test parser-2.2 {parse command result processing} -body {
  set result [list]
  set output false

  foreach pair [parse command {set a 2}] {
    foreach {name value} $pair {
      if {$name eq "Type" && $value eq "Text"} then {
        set output true
      } elseif {$output && $name eq "Text"} then {
        set output false
        lappend result $value
      }
    }
  }

  set result
} -cleanup {
  unset -nocomplain result output value name pair
} -constraints {eagle} -result {set a 2}}

###############################################################################

source [file join [file normalize [file dirname [info script]]] epilogue.eagle]
