lua# lua5.1.4 源码文件作用一览

写了个脚本列出lua源码C文件头部的注释,作为我有一搭没一搭以Lua为对象学习编译原理的开端。

lua5.1.4全部的源码有35个C文件,17216行代码。每个文件基本的功能如下

./output_lua_sources_comments.sh ~/resources/sources/lua/src                                                                                  myarch/others (master ⚡) mattPC
     1    52    lctype.c       'ctype' functions for Lua
     2    67    linit.c        Initialization of libraries for lua.c and other clients
     3    76    lzio.c         Buffered streams
     4    77    ltm.c          Tag methods
     5    99    lmem.c         Interface to Memory Manager
     6    107   lopcodes.c     Opcodes for Lua virtual machine
     7    155   lcorolib.c     Coroutine Library
     8    161   lfunc.c        Auxiliary functions to manipulate prototypes and closures
     9    173   ldump.c        save precompiled Lua chunks
    10    185   lstring.c      String table (keeps all strings handled by Lua)
    11    209   lbitlib.c      Standard library for bitwise operations
    12    258   lundump.c      load precompiled Lua chunks
    13    283   lmathlib.c     Standard mathematical library
    14    283   ltablib.c      Library for Table Manipulation
    15    289   lobject.c      Some generic functions over Lua objects
    16    322   lstate.c       Global State
    17    323   loslib.c       Standard Operating System library
    18    398   ldblib.c       Interface from Lua to its debug API
    19    432   luac.c         Lua compiler (saves bytecodes to files; also list bytecodes)
    20    459   lbaselib.c     Basic library
    21    496   lua.c          Lua stand-alone interpreter
    22    527   llex.c         Lexical Analyzer
    23    580   ldebug.c       Debug Interface
    24    588   ltable.c       Lua tables (hash)
    25    657   liolib.c       Standard I/O (and system) library
    26    668   ldo.c          Stack and Call structure of Lua
    27    725   loadlib.c      Dynamic library loader for Lua
    28    766   loadlib_rel.c  Dynamic library loader for Lua
    29    868   lvm.c          Lua virtual machine
    30    882   lcode.c        Code generator for Lua
    31    958   lauxlib.c      Auxiliary functions for building Lua libraries
    32    972   lstrlib.c      Standard library for string operations and pattern-matching
    33    1205  lgc.c          Garbage Collector
    34    1281  lapi.c         Lua API
    35    1635  lparser.c      Lua Parser
----------------------------------------------------------------------------------------
        17216

以下是bash脚本,内容也算丰富。

 1 [[ "$#" == 0 ]] &&  {
 2     echo "usage: $0 path"
 3     exit 1
 4 }
 5 
 6 src_dir="$1"
 7 pos=$((${#src_dir}+2))
 8 
 9 outline ()
10 {
11     printf "%-6d%-15s%s\n" "$1" "$2" "$3" 
12 }
13 
14 {
15 for file in `ls -1 "$src_dir""/*.c"` ; do
16     comment=`sed -n "3p" $file | cut -d" " -f2-`
17     filename=`basename $file`
18     lines=`wc -l $file | cut -d" " -f1`
19     outline "$lines" "$filename" "$comment" 
20 done
21 } | sort -nk 1| cat  -b  | awk  '{ if(l<length($0)){ l=length($0)}; s+=$2; print $0}
22     END { while(l--){ sp=sp"-"} print sp ;printf("%8s%-6d\n","",s)}'

 

 

 

 

posted @ 2012-12-08 12:35  倚楼无语F5  阅读(573)  评论(0编辑  收藏  举报