ALDT (Arnulf's LaTeX Documentation Tool)

Check-in [fc88728dc3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:fixes
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fc88728dc3252b8ce19ed7206d21ed2ec4c85590
User & Date: arnulf 2012-09-01 14:15:43
Context
2012-09-01
16:20
fixes for parsing check-in: eaf5e42fca user: arnulf tags: trunk
14:15
fixes check-in: fc88728dc3 user: arnulf tags: trunk
2012-08-29
19:23
fixes and new code check-in: f41e96b23b user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to EvalStatement.tcl.

14
15
16
17
18
19
20



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

namespace eval ::Parser {

::itcl::class EvalStatement {
  private common oid 0

  private variable id



  public variable level
  public variable eval_level
  public variable eval_stmt_debug
  public variable macro_cmd_level
  public variable eval_subst_debug
  public variable eval_ipol_debug
  private variable in_quotes
  private variable had_macro_cmd
  public variable call_frames;

  constructor {} {}
  public method mySelf {}
  public method toString {}
  public method toDebugString {}
  public method substOneToken {script idx result_ptr}







>
>
>






<
<







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29


30
31
32
33
34
35
36

namespace eval ::Parser {

::itcl::class EvalStatement {
  private common oid 0

  private variable id
  private variable in_quotes
  private variable had_macro_cmd

  public variable level
  public variable eval_level
  public variable eval_stmt_debug
  public variable macro_cmd_level
  public variable eval_subst_debug
  public variable eval_ipol_debug


  public variable call_frames;

  constructor {} {}
  public method mySelf {}
  public method toString {}
  public method toDebugString {}
  public method substOneToken {script idx result_ptr}

Changes to Parse.tcl.

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
...
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
...
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
...
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
...
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
...
890
891
892
893
894
895
896
897
898
899
900

::itcl::body Parse::isEof {} {
  return [$parse_info getEof]
}

# =============================== parseScript ==================================
::itcl::body Parse::parseScript {} {
puts "parseScript![$parse_info getCur]![$parse_info getLen]!"
  while {true} {              # the while is used to reiterate with continue if needed 
    if {[$parse_info getLen] <= 0} {
      if {[$parse_info getCur] == "\""} {
        if {[$parse_info getState] ne [::Parser::Token::string2ParserState "PARSER_STATE_QUOTE"]} {
          $parse_result setMissing "\""
          return false
        } else {
................................................................................
        $parse_info setToken [::Parser::Token::string2Token "TOKEN_ESC"]
      } else {
        $parse_info setToken [::Parser::Token::string2Token "TOKEN_EOL"]
      }
      $parse_info setEof true
      return true
    }
puts "cur![$parse_info getCur]!"
    switch [$parse_info getCur] {
    "\\" {
      if {[lindex [$parse_info getText] [expr {[$parse_info getIndex] + 1}]] eq "\n" && [$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_DEFAULT"]} {
        return [parseWordSep];
      } else {
        if {[lindex [$parse_info getText] [expr {[$parse_info getIndex] + 1}]] eq "\\" && [$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_DEFAULT"]} {
          $parse_info setWordSep false
................................................................................
      if {[$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_DEFAULT"]} {
        return [parseEol]
      } else {
        return [parseString]
      }
      }
    "\{" {
puts "ARG1![$parse_info getArgument]![$parse_info getWordSep]!"
      if {[$parse_info getArgument]} {
        if {[$parse_info getWordSep]} {
          # we have to simulate a TOKEN_ESC here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!
	  $parse_info setStart [$parse_info getIndex]
	  $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
................................................................................
      if {[$parse_info getArgument]} {
        $parse_info setWordSep true
      }
      $parse_info setComment false
      return [parseBrace]
      }
    "\[" {
puts "BRK1![$parse_info getArgument]![$parse_info getWordSep]!"
      if {[$parse_info getArgument]} {
        if {[$parse_info getWordSep]} {
          # we have to simulate a TOKEN_ESC here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!
	  $parse_info setStart [$parse_info getIndex]
	  $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_WORD_SEP"]
puts "BRK![$parse_info getText]!"
          $parse_info setWordSep false
          return true
        }
      }
      if {[$parse_info getArgument]} {
          $parse_info setWordSep true
      }
................................................................................
        }
      }
      if {[$parse_info getArgument]} {
        $parse_info setWordSep true
      }
      $parse_info setComment false
      return [parseParen]
      }
    "$" {
      $parse_info setWordSep false
      $parse_info setComment false
      if {[parseVar] == false} {
        $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
        $parse_info setLen [expr {[$parse_info getLen] - 1}]
        $parse_info setLine [$parse_info getLineNo]
        $parse_info setToken [::Parser::Token::string2Token "TOKEN_STR"]
        return true
      } else {
        return true
      }
      }
    "&" {
      $parse_info setWordSep false
      $parse_info setComment false
      $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
      $parse_info setToken [::Parser::Token::string2Token "TOKEN_AMPERSAND"]
      return true
................................................................................
        parseSubBracket
        set token "TOKEN_QUOTE_ESC"
        continue
        }
      "\n" {
        $parse_info setLineNo [expr {[$parse_info getLineNo] + 1}]
        }
      "$" {
        set token "TOKEN_QUOTE_ESC"
        }
      }
      feedChar
    }
    $parse_result setMissing "\""
    $parse_result setMissingLine $line;
    $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
    return [::Parser::Token::string2Token $token]
................................................................................
          if {[string range [$parse_info getText] [expr {[$parse_info getIndex] + 1}] [expr {[$parse_info getIndex] + 1}]] eq "\n"} {
            $parse_info setLineNo [expr {[$parse_info getLineNo] + 1}]
          }
          feedChar
        }
        }
      "(" {
        # If the following token is not '$' just keep going
        if {[$parse_info getLen] > 1 && [string range [$parse_info getText] [expr {[$parse_info getIndex] + 1}] [expr {[$parse_info getIndex] + 1}]] ne "$"} {
          break
        }
        }
      ")" {
        # Only need a separate ')' token if the previous was a var 
        if {[$parse_info getCur] eq "(" || [$parse_info getToken] == [::Parser::Token::string2Token "TOKEN_VAR"]} {
          if {[$parse_info getIndex] == [$parse_info getStart]} {
................................................................................
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_QUOTE_ESC"]
        } else {
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_ESC"]
        }
        return true
        }
      "&" -
      "$" -
      "\[" {
        $parse_info setEnd [expr {[$parse_info getIndex] -1}]
        if {[$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_QUOTE"]} {
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_QUOTE_ESC"]
        } else {
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_ESC"]
        }
................................................................................
  $parse_info setIndex [expr {[$parse_info getIndex] + 1}]
  $parse_info setLen [expr {[$parse_info getLen] -1}]
  if {[$parse_info getLen] < 0} {
#      throw new PanicException("End of file reached");
    puts stderr "PANIC! End of file reached"
  }
  $parse_info setCur [string range [$parse_info getText] [$parse_info getIndex] [$parse_info getIndex]]
puts "FDCH![$parse_info getLen]![$parse_info getIndex]![$parse_info getCur]![getText]!"
}

}







|







 







|







 







<







 







<








<







 







<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<







 







|
|







 







<







 







|



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
...
142
143
144
145
146
147
148

149
150
151
152
153
154
155
...
161
162
163
164
165
166
167

168
169
170
171
172
173
174
175

176
177
178
179
180
181
182
...
197
198
199
200
201
202
203













204
205
206
207
208
209
210
...
450
451
452
453
454
455
456



457
458
459
460
461
462
463
...
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
...
748
749
750
751
752
753
754

755
756
757
758
759
760
761
...
870
871
872
873
874
875
876
877
878
879
880

::itcl::body Parse::isEof {} {
  return [$parse_info getEof]
}

# =============================== parseScript ==================================
::itcl::body Parse::parseScript {} {
#puts "parseScript![$parse_info getCur]![$parse_info getLen]!"
  while {true} {              # the while is used to reiterate with continue if needed 
    if {[$parse_info getLen] <= 0} {
      if {[$parse_info getCur] == "\""} {
        if {[$parse_info getState] ne [::Parser::Token::string2ParserState "PARSER_STATE_QUOTE"]} {
          $parse_result setMissing "\""
          return false
        } else {
................................................................................
        $parse_info setToken [::Parser::Token::string2Token "TOKEN_ESC"]
      } else {
        $parse_info setToken [::Parser::Token::string2Token "TOKEN_EOL"]
      }
      $parse_info setEof true
      return true
    }
#puts "cur![$parse_info getCur]!"
    switch [$parse_info getCur] {
    "\\" {
      if {[lindex [$parse_info getText] [expr {[$parse_info getIndex] + 1}]] eq "\n" && [$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_DEFAULT"]} {
        return [parseWordSep];
      } else {
        if {[lindex [$parse_info getText] [expr {[$parse_info getIndex] + 1}]] eq "\\" && [$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_DEFAULT"]} {
          $parse_info setWordSep false
................................................................................
      if {[$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_DEFAULT"]} {
        return [parseEol]
      } else {
        return [parseString]
      }
      }
    "\{" {

      if {[$parse_info getArgument]} {
        if {[$parse_info getWordSep]} {
          # we have to simulate a TOKEN_ESC here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!
	  $parse_info setStart [$parse_info getIndex]
	  $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
................................................................................
      if {[$parse_info getArgument]} {
        $parse_info setWordSep true
      }
      $parse_info setComment false
      return [parseBrace]
      }
    "\[" {

      if {[$parse_info getArgument]} {
        if {[$parse_info getWordSep]} {
          # we have to simulate a TOKEN_ESC here so 
          # EvalStatement will use the optional and mandatory arguments
          # as those and not as a combined string!!
	  $parse_info setStart [$parse_info getIndex]
	  $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_WORD_SEP"]

          $parse_info setWordSep false
          return true
        }
      }
      if {[$parse_info getArgument]} {
          $parse_info setWordSep true
      }
................................................................................
        }
      }
      if {[$parse_info getArgument]} {
        $parse_info setWordSep true
      }
      $parse_info setComment false
      return [parseParen]













      }
    "&" {
      $parse_info setWordSep false
      $parse_info setComment false
      $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
      $parse_info setToken [::Parser::Token::string2Token "TOKEN_AMPERSAND"]
      return true
................................................................................
        parseSubBracket
        set token "TOKEN_QUOTE_ESC"
        continue
        }
      "\n" {
        $parse_info setLineNo [expr {[$parse_info getLineNo] + 1}]
        }



      }
      feedChar
    }
    $parse_result setMissing "\""
    $parse_result setMissingLine $line;
    $parse_info setEnd [expr {[$parse_info getIndex] - 1}]
    return [::Parser::Token::string2Token $token]
................................................................................
          if {[string range [$parse_info getText] [expr {[$parse_info getIndex] + 1}] [expr {[$parse_info getIndex] + 1}]] eq "\n"} {
            $parse_info setLineNo [expr {[$parse_info getLineNo] + 1}]
          }
          feedChar
        }
        }
      "(" {
        # just keep going
        if {[$parse_info getLen] > 1} {
          break
        }
        }
      ")" {
        # Only need a separate ')' token if the previous was a var 
        if {[$parse_info getCur] eq "(" || [$parse_info getToken] == [::Parser::Token::string2Token "TOKEN_VAR"]} {
          if {[$parse_info getIndex] == [$parse_info getStart]} {
................................................................................
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_QUOTE_ESC"]
        } else {
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_ESC"]
        }
        return true
        }
      "&" -

      "\[" {
        $parse_info setEnd [expr {[$parse_info getIndex] -1}]
        if {[$parse_info getState] eq [::Parser::Token::string2ParserState "PARSER_STATE_QUOTE"]} {
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_QUOTE_ESC"]
        } else {
          $parse_info setToken [::Parser::Token::string2Token "TOKEN_ESC"]
        }
................................................................................
  $parse_info setIndex [expr {[$parse_info getIndex] + 1}]
  $parse_info setLen [expr {[$parse_info getLen] -1}]
  if {[$parse_info getLen] < 0} {
#      throw new PanicException("End of file reached");
    puts stderr "PANIC! End of file reached"
  }
  $parse_info setCur [string range [$parse_info getText] [$parse_info getIndex] [$parse_info getIndex]]
#puts "FDCH![$parse_info getLen]![$parse_info getIndex]![$parse_info getCur]![getText]!"
}

}