ALDT (Arnulf's LaTeX Documentation Tool)

Check-in [f9d868063d]
Login

Check-in [f9d868063d]

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

Overview
Comment:fixes and new code
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f9d868063d29e1b0adca8c0be02c1fcc5646bc29
User & Date: arnulf 2012-08-26 14:28:37.182
Context
2012-08-26
14:48
initial version check-in: 18a41385d9 user: arnulf tags: trunk
14:28
fixes and new code check-in: f9d868063d user: arnulf tags: trunk
13:31
initial version check-in: 081f7049b9 user: arnulf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Interp.tcl.
11
12
13
14
15
16
17



18



19

20




































21
22
23
# *
# * Copyright 2012 Arnulf P. Wiedemann
#=====================================================

namespace eval :: {

::itcl::class Interp {



  public common string_obj_type [::Parser::StringObjType #auto]





  constructor {} {}




































}

}







>
>
>
|
>
>
>

>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# *
# * Copyright 2012 Arnulf P. Wiedemann
#=====================================================

namespace eval :: {

::itcl::class Interp {
  public common obj_type2string
  public common string2obj_type

  public common string_obj_type [uplevel #0 ::Parser::StringObjType #auto]
  public common source_obj_type [uplevel #0 ::Parser::SourceObjType #auto]
  public common script_obj_type [uplevel #0 ::Parser::ScriptObjType #auto]
  public common script_line_obj_type [uplevel #0 ::Parser::ScriptLineObjType #auto]

  public common current_dir "."

  public proc Init {}
  public proc objType2String {val}
  public proc string2ObjType {val}

}

::itcl::body Interp::Init {} {
  set obj_type2string(0) "OBJ_TYPE_SCRIPT"
  set obj_type2string(1) "OBJ_TYPE_SCRIPT_LINE"
  set obj_type2string(2) "OBJ_TYPE_SOURCE"
  set obj_type2string(3) "OBJ_TYPE_STRING"

  set string2obj_type(OBJ_TYPE_SCRIPT) 0
  set string2obj_type(OBJ_TYPE_SCRIPT_LINE) 1
  set string2obj_type(OBJ_TYPE_SOURCE) 2
  set string2obj_type(OBJ_TYPE_STRING) 3
}

::itcl::body Interp::objType2String {val} {
  if {[info exists obj_type2string($val)]} {
    return $obj_type2string($val)
  } else {
puts stderr "objType2String no such ObjType!$val!"
parray obj_type2string
    return ""
  }
}

::itcl::body Interp::string2ObjType {val} {
  if {[info exists string2obj_type($val)]} {
    return $string2obj_type($val)
  } else {
puts stderr "string2ObjType no such ObjType!$val!"
parray string2obj_type
    return ""
  }
}

}
Changes to LatexObj.tcl.
38
39
40
41
42
43
44














45
46
47
48
49
50
51
  public variable ref_count
  public variable obj_type

  constructor {} {}
  public method mySelf {}
  public method toString {}
  public method toDebugString {}














  public method isShared {}
  public method isListObj {}
  public method getIntRepPtr {}
  public method incrRefCount {where}
  public method decrRefCount {where}
  public method getString {}
  public method getStringLength {}







>
>
>
>
>
>
>
>
>
>
>
>
>
>







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  public variable ref_count
  public variable obj_type

  constructor {} {}
  public method mySelf {}
  public method toString {}
  public method toDebugString {}
  public method scriptLineValue_GetLine {}
  public method scriptLineValue_SetLine {val}
  public method scriptLineValue_GetArgc {}
  public method scriptLineValue_SetArgc {val}
  public method scriptValue_GetScript {}
  public method scriptValue_SetScript {script}
  public method sourceValue_GetFileNameObj {}
  public method sourceValue_SetFileNameObj {file_name_obj}
  public method sourceValue_GetLineNumber {}
  public method sourceValue_SetLineNumber {line_number}
  public method strValue_GetCharLength {}
  public method strValue_SetCharLength {char_length}
  public method strValue_GetMaxLength {}
  public method strValue_SetMaxLength {max_length}
  public method isShared {}
  public method isListObj {}
  public method getIntRepPtr {}
  public method incrRefCount {where}
  public method decrRefCount {where}
  public method getString {}
  public method getStringLength {}
68
69
70
71
72
73
74
75
76
77
78




79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    incr oid
    set id $oid

    set bytes ""
    set len 0;
    set allocated ""
    set freed ""
    set obj_type_base [ObjTypeBase #auto]
    set incr_lst [list]
    set decr_lst [list]
    set check_allocate true




  }

  # ==================== mySelf ==================================
::itcl::body LatexObj::mySelf {} {
    set str "LatexObj!$id!"
    return $str
  }

  # ==================== toString =====================================
::itcl::body LatexObj::toString {} {
    return "[mySelf]!"
  }

  # ==================== toDebugString ===================================== 
::itcl::body LatexObj::toDebugString {} {
    set str "[mySelf]\n"
    append str "  ref_count: $ref_count\n"
    append str "  len: $len\n"
    append str "  obj_type: [getObjTypeString $obj_type]\n"
    append str "  allocated: $allocated\n"
    append str "  freed: $freed\n"
    append str "  incr: $incr_lst\n"
    append str "  decr: $decr_lst\n"
    append str "  value1: $value1\n"
    append str "  value2: $value2\n"
    append str "  value3: $value3\n"
    append str "  bytes: $bytes\n"
    if {$obj_type > 0} {
      switch $obj_type {
      OBJ_TYPE_LIST {
#        str.append("  list_elem: "+listValue_GetElem()+"\n");
        }
      OBJ_TYPE_INT {
    	append str "  value: [wideValue_GetValue]\n");
        }
      }







|



>
>
>
>


















|









|







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    incr oid
    set id $oid

    set bytes ""
    set len 0;
    set allocated ""
    set freed ""
    set obj_type_base [::Parser::ObjTypeBase #auto]
    set incr_lst [list]
    set decr_lst [list]
    set check_allocate true
    set ref_count 0
    set value1 ""
    set value2 ""
    set value3 ""
  }

  # ==================== mySelf ==================================
::itcl::body LatexObj::mySelf {} {
    set str "LatexObj!$id!"
    return $str
  }

  # ==================== toString =====================================
::itcl::body LatexObj::toString {} {
    return "[mySelf]!"
  }

  # ==================== toDebugString ===================================== 
::itcl::body LatexObj::toDebugString {} {
    set str "[mySelf]\n"
    append str "  ref_count: $ref_count\n"
    append str "  len: $len\n"
    append str "  obj_type: [::Interp::objType2String $obj_type]\n"
    append str "  allocated: $allocated\n"
    append str "  freed: $freed\n"
    append str "  incr: $incr_lst\n"
    append str "  decr: $decr_lst\n"
    append str "  value1: $value1\n"
    append str "  value2: $value2\n"
    append str "  value3: $value3\n"
    append str "  bytes: $bytes\n"
    if {$obj_type > 0} {
      switch [::Interp::objType2String $obj_type] {
      OBJ_TYPE_LIST {
#        str.append("  list_elem: "+listValue_GetElem()+"\n");
        }
      OBJ_TYPE_INT {
    	append str "  value: [wideValue_GetValue]\n");
        }
      }
449
450
451
452
453
454
455
456

457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549

550
551
552
553
554
555
556

  /* ==================== returnCodeValue_SetReturnCode ================================== */
  public int returnCodeValue_SetReturnCode(int return_code) {
//print("returnCodeValue_SetReturnCode!"+this.mySelf()+"!");
    value1 = (Object)return_code;
    return return_code;
  }


  /* ==================== scriptLineValue_GetLine ================================== */
  public int scriptLineValue_GetLine() {
    return (Integer)value1;
  }

  /* ==================== scriptLineValue_SetLine ================================== */
  public int scriptLineValue_SetLine(int val) {
//print("scriptLineValue_SetLine!"+this.mySelf()+"!");
    value1 = (Object)val;
    return val;
  }

  /* ==================== scriptLineValue_GetArgc ================================== */
  public int scriptLineValue_GetArgc() {
    return (Integer)value2;
  }

  /* ==================== scriptLineValue_SetArgc ================================== */
  public int scriptLineValue_SetArgc(int val) {
//print("scriptLineValue_SetArgc!"+this.mySelf()+"!");
    value2 = (Object)val;
    return val;
  }

  /* ==================== scriptValue_GetScript ================================== */
  public Script scriptValue_GetScript() {
//print("scriptValue_GetScript!"+value1+"!");
    return (Script)value1;
  }

  /* ==================== scriptValue_SetScript ================================== */
  public Script scriptValue_SetScript(Script script) {
//print("scriptValue_SetScript!"+this.mySelf()+"!");
    value1 = (Object)script;
    return script;
  }

  /* ==================== sourceValue_GetFileNameObj ================================== */
  public LatexObj sourceValue_GetFileNameObj() {
    return (LatexObj)value1;
  }

  /* ==================== sourceValue_SetFileNameObj ================================== */
  public LatexObj sourceValue_SetFileNameObj(LatexObj file_name_obj) {
//print("sourceValue_SetFileNameObj!"+this.mySelf()+"!");
    value1 = (Object)file_name_obj;
    return file_name_obj;
  }

  /* ==================== sourceValue_GetLineNumber ================================== */
  public int sourceValue_GetLineNumber() {
    return (Integer)value2;
  }

  /* ==================== sourceValue_SetLineNumber ================================== */
  public int sourceValue_SetLineNumber(int line_number) {
//print("sourceValue_SetLineNumber!"+this.mySelf()+"!");
    value2 = (Object)line_number;
    return line_number;
  }

  /* ==================== strValue_GetCharLength ================================== */
  public int strValue_GetCharLength() {
    if (value2 == null) {
print("strValue_GetCharLength fix value2!");
      value2 = len;
    }
    return (Integer)value2;
  }

  /* ==================== strValue_SetCharLength ================================== */
  public int strValue_SetCharLength(int char_length) {
//print("strValue_SetCharLength!"+this.mySelf()+"!");
    value2 = (Object)char_length;
    return char_length;
  }

  /* ==================== strValue_GetMaxLength ================================== */
  public int strValue_GetMaxLength() {
//print("strValue_GetMaxLength!"+value1+"!");
    if (value1 == null) {
      return (Integer)0;
    }
    return (Integer)value1;
  }

  /* ==================== strValue_SetMaxLength ================================== */
  public int strValue_SetMaxLength(int max_length) {
//print("strValue_SetMaxLength!"+this.mySelf()+"!"+max_length);
    value1 = (Object)max_length;
    return max_length;
  }


  /* ==================== twoPtrValue_GetPtr1 ================================== */
  public Object twoPtrValue_GetPtr1() {
    return value1;
  }

  /* ==================== twoPtrValue_SetPtr1 ================================== */
  public Object twoPtrValue_SetPtr1(Object ptr1) {







|
>
|
|
|


|
|
|
|
|


|
|
|


|
|
|
|
|


|
|
|
|


|
|
|
|
|


|
|
|


|
|
|
|
|


|
|
|


|
|
|
|
|


|
|
|
|
|

|


|
|
|
|
|


|
|
|
|
|

|


|
|
|
|
|


>







467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576

  /* ==================== returnCodeValue_SetReturnCode ================================== */
  public int returnCodeValue_SetReturnCode(int return_code) {
//print("returnCodeValue_SetReturnCode!"+this.mySelf()+"!");
    value1 = (Object)return_code;
    return return_code;
  }
}

  # ==================== scriptLineValue_GetLine ================================== 
::itcl::body LatexObj::scriptLineValue_GetLine {} {
    return $value1
  }

  # ==================== scriptLineValue_SetLine ==================================
::itcl::body LatexObj::scriptLineValue_SetLine {val} {
#puts "scriptLineValue_SetLine![mySelf]!"
    set value1 $val
    return $val
  }

  # ==================== scriptLineValue_GetArgc ==================================
::itcl::body LatexObj::scriptLineValue_GetArgc {} {
    return $value2
  }

  # ==================== scriptLineValue_SetArgc ==================================
::itcl::body LatexObj::scriptLineValue_SetArgc {val} {
#puts "scriptLineValue_SetArgc![mySelf]!"
    set value2 $val
    return $val
  }

  # ==================== scriptValue_GetScript ==================================
::itcl::body LatexObj::scriptValue_GetScript {} {
#puts "scriptValue_GetScript!$value1!"
    return $value1
  }

  # ==================== scriptValue_SetScript ==================================
::itcl::body LatexObj::scriptValue_SetScript {script} {
#puts "scriptValue_SetScript![mySelf]!"
    set value1 $script
    return $script
  }

  # ==================== sourceValue_GetFileNameObj ==================================
::itcl::body LatexObj::sourceValue_GetFileNameObj {} {
    return $value1
  }

  # ==================== sourceValue_SetFileNameObj ==================================
::itcl::body LatexObj::sourceValue_SetFileNameObj {file_name_obj} {
#pits "sourceValue_SetFileNameObj![mySelf]!"
    set value1 $file_name_obj
    return $file_name_obj
  }

  # ==================== sourceValue_GetLineNumber ==================================
::itcl::body LatexObj::sourceValue_GetLineNumber {} {
    return $value2
  }

  # ==================== sourceValue_SetLineNumber ==================================
::itcl::body LatexObj::sourceValue_SetLineNumber {line_number} {
#puts "sourceValue_SetLineNumber![mySelf]!"
    set value2 $line_number
    return $line_number
  }

  # ==================== strValue_GetCharLength ==================================
::itcl::body LatexObj::strValue_GetCharLength {} {
    if {$value2 == ""} {
puts "strValue_GetCharLength fix value2!"
      set value2 $len
    }
    return $value2
  }

  # ==================== strValue_SetCharLength ==================================
::itcl::body LatexObj::strValue_SetCharLength {char_length} {
#puts "strValue_SetCharLength![mySelf]!"
    set value2 $char_length
    return $char_length
  }

  # ==================== strValue_GetMaxLength ==================================
::itcl::body LatexObj::strValue_GetMaxLength {} {
#puts "strValue_GetMaxLength!$value1!"
    if {$value1 == ""} {
      return 0
    }
    return $value1
  }

  # ==================== strValue_SetMaxLength ==================================
::itcl::body LatexObj::strValue_SetMaxLength {max_length} {
#puts "strValue_SetMaxLength![mySelf]!max_length);
    set value1 $max_length;
    return $max_length;
  }

if {0} {
  /* ==================== twoPtrValue_GetPtr1 ================================== */
  public Object twoPtrValue_GetPtr1() {
    return value1;
  }

  /* ==================== twoPtrValue_SetPtr1 ================================== */
  public Object twoPtrValue_SetPtr1(Object ptr1) {
Changes to SourceObjType.tcl.
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  public method freeInternalRep {obj_ptr}
  public method dupInternalRep {src_ptr dup_ptr}
  public method setSourceInfo {obj_ptr file_name_ptr line_number}
  }

  # ==================== constructor ==================================
::itcl::body SourceObjType::constructor {} {
    inr oid
    set id $oid
  }

  # ==================== mySelf ==================================
::itcl::body SourceObjType::mySelf {} {
    set str "SourceObjType!$id!"
    return $str







|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  public method freeInternalRep {obj_ptr}
  public method dupInternalRep {src_ptr dup_ptr}
  public method setSourceInfo {obj_ptr file_name_ptr line_number}
  }

  # ==================== constructor ==================================
::itcl::body SourceObjType::constructor {} {
    incr oid
    set id $oid
  }

  # ==================== mySelf ==================================
::itcl::body SourceObjType::mySelf {} {
    set str "SourceObjType!$id!"
    return $str
Changes to StringObjType.tcl.
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  # ==================== getStringLength ==================================
::itcl::body StringObjType::getStringLength {obj_ptr} {
    return [$obj_ptr getLen]
  }

  # ==================== newStringObjNoAlloc ================================== 
::itcl::body StringObjType::newStringObjNoAlloc {str len where} {
    set obj_ptr [::Parser::LatexObj #auto]
    if {$len == -1} {
      set len [string length $str]
    }
    $obj_ptr setStringRep $obj_ptr $str $len
    $obj_ptr setObjType OBJ_TYPE_STRING
    $obj_ptr setAllocated $where
    $obj_ptr setFreed ""
    return $obj_ptr;
  }

  # ==================== newStringObj ================================== 
  # len is in bytes -- see also newStringObjUtf8() 
::itcl::body StringObjType::newStringObj {str len where} {
    set obj_ptr [::Parser::LatexObj #auto]

    # Need to find out how many bytes the string requires 
    if {$len == -1} {
      set len [string length $str]
    }
    $obj_ptr strValue_SetCharLength $len
    $obj_ptr strValue_SetMaxLength $len
    if {len == 0} {
      $obj_ptr setLen 0
      $obj_ptr setBbytes ""
    } else {
      $obj_ptr setBytes ""
      $obj_ptr setBytes "[$obj_ptr getBytes][string range $str 0 $len]"
      $obj_ptr setLen $len
    }

    # No obj_type field for the vanilla string object. 
    $obj_ptr setObjType OBJ_TYPE_STRING
    $obj_ptr setAllocated $where
    $obj_ptr setFreed ""
    return $obj_ptr;
  }

  # ==================== newEmptyStringObj ==================================
::itcl::body StringObjType::newEmptyStringObj {where} {







|




|








|







|









|







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
  # ==================== getStringLength ==================================
::itcl::body StringObjType::getStringLength {obj_ptr} {
    return [$obj_ptr getLen]
  }

  # ==================== newStringObjNoAlloc ================================== 
::itcl::body StringObjType::newStringObjNoAlloc {str len where} {
    set obj_ptr [uplevel #0 ::Parser::LatexObj #auto]
    if {$len == -1} {
      set len [string length $str]
    }
    $obj_ptr setStringRep $obj_ptr $str $len
    $obj_ptr setObjType [::Interp::string2ObjType OBJ_TYPE_STRING]
    $obj_ptr setAllocated $where
    $obj_ptr setFreed ""
    return $obj_ptr;
  }

  # ==================== newStringObj ================================== 
  # len is in bytes -- see also newStringObjUtf8() 
::itcl::body StringObjType::newStringObj {str len where} {
    set obj_ptr [uplevel #0 ::Parser::LatexObj #auto]

    # Need to find out how many bytes the string requires 
    if {$len == -1} {
      set len [string length $str]
    }
    $obj_ptr strValue_SetCharLength $len
    $obj_ptr strValue_SetMaxLength $len
    if {$len == 0} {
      $obj_ptr setLen 0
      $obj_ptr setBbytes ""
    } else {
      $obj_ptr setBytes ""
      $obj_ptr setBytes "[$obj_ptr getBytes][string range $str 0 $len]"
      $obj_ptr setLen $len
    }

    # No obj_type field for the vanilla string object. 
    $obj_ptr setObjType [::Interp::string2ObjType OBJ_TYPE_STRING]
    $obj_ptr setAllocated $where
    $obj_ptr setFreed ""
    return $obj_ptr;
  }

  # ==================== newEmptyStringObj ==================================
::itcl::body StringObjType::newEmptyStringObj {where} {
Changes to latex_parse.tcl.
25
26
27
28
29
30
31

32
33
34
35
36
37
38
source ./ScriptLineObjType.tcl
source ./SourceObjType.tcl
source ./StringObjType.tcl
source ./LatexObj.tcl
source ./ObjTypeBase.tcl
source ./Script.tcl
source ./ScriptObjType.tcl

source ./latex_parse_fcn.tcl
source ./latex_cmds.tcl

global gState
global gCmds
global gPackages
global gCurr







>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
source ./ScriptLineObjType.tcl
source ./SourceObjType.tcl
source ./StringObjType.tcl
source ./LatexObj.tcl
source ./ObjTypeBase.tcl
source ./Script.tcl
source ./ScriptObjType.tcl
source ./Interp.tcl
source ./latex_parse_fcn.tcl
source ./latex_cmds.tcl

global gState
global gCmds
global gPackages
global gCurr
339
340
341
342
343
344
345

346
347
348


349
350
351
352
353
354
355
  }
  return true
}

buildCmdList $latex_cmds_info

::Parser::Token::Init

::LaTeX::CommandInfo::Init
set parser [::Parser::Parser #auto]
set str "\\begin\[pf1\]{document}\n abc \n\\end{document}"


$parser parserInit $str [string length $str] 1
while {true} {
  if {[$parser isEof]} {
    break
  }
  if {! [$parser parseScript]} {
    puts stderr "Error in parsing!"







>



>
>







340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
  }
  return true
}

buildCmdList $latex_cmds_info

::Parser::Token::Init
::Interp::Init
::LaTeX::CommandInfo::Init
set parser [::Parser::Parser #auto]
set str "\\begin\[pf1\]{document}\n abc \n\\end{document}"
set script [$::Interp::string_obj_type newStringObj "::set dir $::Interp::current_dir\n$str" -1 "BASE_2"]
puts "SCRIPT![$script toDebugString]!"
$parser parserInit $str [string length $str] 1
while {true} {
  if {[$parser isEof]} {
    break
  }
  if {! [$parser parseScript]} {
    puts stderr "Error in parsing!"