目录

  • 1 Chapter 1 Introduction
    • 1.1 1.0 Course Contents
    • 1.2 1.1 Basic Conception
      • 1.2.1 Lecture 1
      • 1.2.2 Lecture 2
    • 1.3 1.2 Compiler Structure
      • 1.3.1 Lecture 1
      • 1.3.2 Lecture 2
      • 1.3.3 Lecture 3
    • 1.4 1.3 The Technique of Compiler Developing
  • 2 Chapter 2 Conspectus of Formal Language
    • 2.1 2.1 Alphabets and Strings
      • 2.1.1 Lecture 1
      • 2.1.2 Lecture 2
    • 2.2 2.2 Grammars and its Categories
      • 2.2.1 Lecture 1
      • 2.2.2 Lecture 2
    • 2.3 2.3 Languages and Parse Tree
      • 2.3.1 Lecture 1
      • 2.3.2 Lecture 2
    • 2.4 2.4 Notes of Formal Language
    • 2.5 2.5 Basic Parsing Techniques
      • 2.5.1 Lecture 1
      • 2.5.2 Lecture 2
  • 3 Chapter 3 Finite Automata
    • 3.1 3.1 Formal Definition of FA
      • 3.1.1 Lecture 1
      • 3.1.2 Lecture 2
    • 3.2 3.2 Transition from NDFA to DFA
      • 3.2.1 Lecture 1
      • 3.2.2 Lecture 2
      • 3.2.3 Lecture 3
    • 3.3 3.3 RG and FA
    • 3.4 3.4 Regular Expression & Regular Set
      • 3.4.1 Lecture 1
      • 3.4.2 Lecture 2
  • 4 Chapter 4 Scanner(Lexical Analyzer)
    • 4.1 4.1 Lexical Analyzer and Tokens
      • 4.1.1 Lecture 1
      • 4.1.2 Lecture 2
    • 4.2 4.2 Step for developing a lexical analyzer
    • 4.3 4.3  Dealing with Identifier
    • 4.4 4.4  Using Regular Expressions
    • 4.5 4.5 Using Flex
      • 4.5.1 Lecture 1
      • 4.5.2 Lecture 2
  • 5 Chapter 5 Top-Down Parsing
    • 5.1 5.0 Push Down Automata (PDA, Added)
      • 5.1.1 Lecture 1
      • 5.1.2 Lecture 2
      • 5.1.3 Lecture 3
    • 5.2 5.1 Elimination Left-Recursion
    • 5.3 5.2 LL(k) Grammar
      • 5.3.1 Lecture 1
      • 5.3.2 Lecture 2
    • 5.4 5.3 Deterministic LL(1) Analyzer Construction
    • 5.5 5.4 Recursive-descent (Non-backtracking) parsing
    • 5.6 5.5 复习与结课
      • 5.6.1 Lecture1 结课感言
      • 5.6.2 Lecture 2 关于复习
      • 5.6.3 Lecture 3 习题讲解
  • 6 Chapter 6 bottom-up Parsing and precedence analyzer
    • 6.1 6.1 Bottom-Up Parsing
    • 6.2 6.2 Phrase, Simple Phrase and Handle
    • 6.3 6.3 A Shift-Reduce Parser
    • 6.4 6.4 Some Relations on Grammar
    • 6.5 6.5 Simple Precedence Parsing
    • 6.6 6.6 Operator-Precedence Parsing
      • 6.6.1 Lecture 1
      • 6.6.2 Lecture 2
      • 6.6.3 Lecture 3
    • 6.7 6.7 Precedence Functions and Construction
  • 7 Chapter 7  LR Parsing
    • 7.1 7.1 LR Parsers
      • 7.1.1 Lecture 1
      • 7.1.2 Lecture 2
    • 7.2 7.2 Building a LR(0) parse table
      • 7.2.1 Lecture 1
      • 7.2.2 Lecture 2
    • 7.3 7.3 SLR Parse Table Construction
    • 7.4 7.4 Constructing Canonical LR(1) Parsing Tables
    • 7.5 7.5 LALR Parsing Tables Construction
    • 7.6 7.6 Using Ambiguous Grammars
    • 7.7 7.7 Yacc/Bison Overview
  • 8 Chapter 8 Syntax-Directed Translation
    • 8.1 8.1 Syntax-Directed Translation
      • 8.1.1 Lecture1
      • 8.1.2 Lecture 2
      • 8.1.3 Lecture 3
    • 8.2 8.2 Abstract Syntax Tree
    • 8.3 8.3 Intermediate Representation
      • 8.3.1 Lecture 1
      • 8.3.2 Lecture 2
  • 9 Chapter 9 Run-Time Environment
    • 9.1 9.1 Data Area & Attribute
    • 9.2 Section 9.2~9.4 & Section 9.8~9.9
    • 9.3 9.5 Parameter Passing
    • 9.4 9.6 Stack Allocation
    • 9.5 9.7 Heap allocation
  • 10 Chapter 10 Symbol Tables
    • 10.1 10.1 A symbol Table Class
    • 10.2 10.2 Basic Implementation Techniques
    • 10.3 10.3 Block-structured Symbol Table
    • 10.4 10.4 Implicit Declaration
    • 10.5 10.5 Overloading
  • 11 Chapter 11 Code Optimization
    • 11.1 11.1 Control Flow Graph
    • 11.2 11.2 Redundancies
    • 11.3 11.3 Loop Optimizations
    • 11.4 11.4 Instruction Dispatch
      • 11.4.1 Lecture 1
      • 11.4.2 Lecture 2
  • 12 Chapter 12 Code Generation
    • 12.1 12.1 Code generation issues
    • 12.2 12.2 Simple Stack Machine
    • 12.3 12.3 Register Machine
    • 12.4 12.4 A Simple Code Generator
  • 13 13 Extended Reading扩展阅读1 斯坦福大学公开课
    • 13.1 Lecture 1
    • 13.2 Lecture 2
    • 13.3 Lecture 3
    • 13.4 Lecture 4
    • 13.5 Lecture 5
    • 13.6 Lecture 6
    • 13.7 Lecture 7
    • 13.8 Lecture 8
    • 13.9 Lecture 9
    • 13.10 Lecture 10
    • 13.11 Lecture 11
    • 13.12 More sources
  • 14 14 Extended Reading 2 扩展阅读2 illinois.edu lectures
    • 14.1 Lecture 1 Overview
    • 14.2 Lecture 2 Strings, Languages, DFAs
    • 14.3 Lecture 3 More on DFAs
    • 14.4 Lecture 4 Regular Expressions and Product Construction
    • 14.5 Lecture 5 Nondeterministic Automata
    • 14.6 Lecture 6 Closure properties
    • 14.7 Lecture 7 NFAs are equivalent to DFAs
    • 14.8 Lecture 8 From DFAs/NFAs to Regular Expressions
    • 14.9 Lecture 9 Proving non-regularity
    • 14.10 Lecture 10 DFA minimization
    • 14.11 Lecture 11 Context-free grammars
    • 14.12 Lecture 12 Cleaning up CFGs and Chomsky Normal form
    • 14.13 Lecture 13 Even More on Context-Free Grammars
    • 14.14 Lecture 14 Repetition in context free languages
    • 14.15 Lecture 15 CYK Parsing Algorithm
    • 14.16 Lecture 16 Recursive automatas
    • 14.17 Lecture 17 Computability and Turing Machines
    • 14.18 Lecture 18 More on Turing Machines
    • 14.19 Lecture 19 Encoding problems and decidability
    • 14.20 Lecture 20 More decidable problems, and simulating TM and “real” computers
    • 14.21 Lecture 21 Undecidability, halting and diagonalization
    • 14.22 Lecture 22 Reductions
    • 14.23 Lecture 23 Rice Theorem and Turing machine behavior properties
    • 14.24 Lecture 24 Dovetailing and non-deterministic Turing machines
    • 14.25 Lecture 25 Linear Bounded Automata and Undecidability for CFGs
  • 15 15 Extended Reading3 扩展阅读3 Extended  Reference Books
    • 15.1 15.1 English Text Book
    • 15.2 15.2 编译原理(何炎祥,伍春香,王汉飞 2010.04)
    • 15.3 15.3 编译原理(陈光建主编;贾金玲,黎远松,罗玉梅,万新副主编 2013.10)
    • 15.4 15.4 编译原理((美)Alfred V. Aho等著;李建中,姜守旭译 2003.08)
    • 15.5 15.5 编译原理学习与实践指导(金登男主编 2013.11)
    • 15.6 15.6 编译原理及编译程序构造 第2版(薛联凤,秦振松编著 2013.02)
    • 15.7 15.7 编译原理学习指导(莫礼平编 2012.01)
    • 15.8 15.8 JavaScript动态网页开发案例教程
  • 16 16 中文版课件(pdf)辅助学习
    • 16.1 第1章 引论
    • 16.2 第2章 形式语言概论
    • 16.3 第3章 有穷自动机
    • 16.4 第4章 词法分析
    • 16.5 第5章 自上而下分析
    • 16.6 第6章 优先分析方法
    • 16.7 第7章 自下而上的LR(k)分析方法
    • 16.8 第8章 语法制导翻译法
    • 16.9 第9章 运行时的存储组织与管理
    • 16.10 第10章 符号表的组织与查找
    • 16.11 第11章 优化
    • 16.12 第12章 代码生成
  • 17 17 Extended Reading4 扩展阅读4 Static Single Assignment
    • 17.1 17.1 SSA-based Compiler Design
    • 17.2 17.2 A Simple, Fast Dominance Algorithm (Rice Computer Science TR-06-33870)
    • 17.3 17.3 The Development of Static Single Assignment Form(KennethZadeck-Presentation on the History of SSA at the SSA'09 Seminar, Autrans, France, April 2009)
    • 17.4 17.4 SPIR-V Specification(John Kessenich, Google and Boaz Ouriel, Intel Version 1.00, Revision 12 January 16, 2018)
    • 17.5 17.5 Efficiently Computing Static Single Assignment Form and the Control Dependence Graph
    • 17.6 17.6 Global Value Numbers and Redundant Computations
  • 18 18 Extended Reading4 扩展阅读5 Computer Science
    • 18.1 1 实地址模式和保护模式的理解
    • 18.2 2 实模式和保护模式
    • 18.3 3 实模式和保护模式区别及寻址方式
    • 18.4 计算机专业术语
    • 18.5 Bit Math in c Language
    • 18.6 Auto-generating subtitles for any video file
    • 18.7 Autosub
    • 18.8 C语言中的内联函数(inline)与宏定义(#define)
  • 19 19 相关学习
    • 19.1 龙书、鲸书和虎书
    • 19.2 Complexity
    • 19.3 MPC Complexity
    • 19.4 NP-completeness
    • 19.5 Computational complexity theory
  • 20 20 全球战疫-武汉战疫延伸与扩展
    • 20.1 Extraordinary G20 Leaders’ Summit Statement on COVID-19
    • 20.2 Experts urge proactive measures to fight virus
    • 20.3 covid-19病毒下贫穷国家
    • 20.4 正确理解病亡率、压平曲线、疫情高峰术语
    • 20.5 为什么全球经济可能陷入长期衰退
    • 20.6 为何新冠病毒检测会出现“假阴性”
    • 20.7 在纽约,几乎每个人身边都有人感染病毒
    • 20.8 An Address by Her Majesty The Queen
    • 20.9 Boris Johnson admitted to hospital over virus sympto
    • 20.10 Edinburgh festivals cancelled due to coronavirus
    • 20.11 US set to recommend wearing of masks
    • 20.12 Boris Johnson in self-isolation after catching coronavirus
    • 20.13 Covid-19:The porous borders where the virus cannot be controlled
    • 20.14 当欧洲人开始戴上口罩
    • 20.15 Lockdown and ‘Intimate Terrorism’
    • 20.16 Us Election 2020: Bernie Sanders Suspends Presidential Campaign
    • 20.17 The aircraft carrier being infected with the coronavirus
    • 20.18 Spent to the W.H.O.
    • 20.19 Unemployment
    • 20.20 The beat of a heart the glimmer of a soul
    • 20.21 Coronavirus pandemic: EU agrees €500bn rescue package
    • 20.22 the world after coronavirus冠状病毒之后的世界
  • 21 21 课程思政方案
    • 21.1 21.1 课程思政
    • 21.2 21.2 实施方案
Auto-generating subtitles for any video file

Install AutoSub Step to Step in Windows with Translate subtitle 

Requeriments
Windows 32 or 64 bits.
Connection Internet.
Links Downloads
Python
FFMPEG
AutoInstall autosub_app 0.3.12.zip
SampleVideos Spanish - English.zip
Subtitle Editor Aegisub
For Version autosub 0.3.9
Note: Uninstall Python 3.x
Tutorial Video Youtube


Step 1. Install Python 2.7 (32 bits)
https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi
python

## Note: Check Add Python.exe to Path

Step 2. Run cmd (Win+R)
C:\Python27\Scripts\pip.exe install autosub
Or
C:\Python27\Scripts\pip.exe install https://pypi.python.org/packages/35/7b/9d5361c0f7abfcc6d826a5279b1c4501f7616505629f6c54857587ec6e37/autosub-0.3.9.tar.gz
or
(Download Last version autosub https://pypi.python.org/pypi/autosub)
C:\Python27\Scripts\pip.exe install "c:\youdownloaded\autosub-0.3.9.tar.gz"

Message Output Normal

Installing collected packages: autosub
Successfully installed autosub-0.3.9


Step 3. Change Name File "autosub" to "autosub_app.py"

Rename C:\Python27\Scripts\autosub autosub_app.py


Step 4.  Modify with notepad.exe or Notepad++(Edit Text) autosub_app.py

4.1 In line 48 add ", delete=False"
temp = tempfile.NamedTemporaryFile(suffix='.flac')
by
temp = tempfile.NamedTemporaryFile(suffix='.flac', delete=False)
4.2 Eliminate line 53 os.system('stty sane'). (Optional)
UPDATE For last Version Autosub (23 May 2017)
In Windows xp,7,8,10
With Program Notepad change lines :
Line 127 change
exe_file = os.path.join(path, program)
exe_file = os.path.join(path, program + ".exe")
Line 47 change
temp = tempfile.NamedTemporaryFile(suffix='.flac')
temp = tempfile.NamedTemporaryFile(suffix='.flac', delete=False)


Step 5. Download(https://ffmpeg.zeranoe.com/builds/) and
Copy ffmpeg.exe to C:\Python27\


Step 6. Restart Windows


Step 7. Test Script C:\Python27\python.exe C:\Python27\scripts\autosub_app.py --list-languages

SampleVideos Spanish - English.zip
autosub_app 0.3.12.zip

Auto-generating subtitles for any video file

Spanish
C:\Python27\python.exe C:\Python27\scripts\autosub_app.py -S es -D es TuVideo.mp4
English
C:\Python27\python.exe C:\Python27\scripts\autosub_app.py -S en -D en YouVideo.mp4
Japanese
C:\Python27\python.exe C:\Python27\scripts\autosub_app.py -S ja -D ja YouAnimeVideo.mp4
cmd

Optional
Compile script Python(Exe Executable)
C:\Python27\python.exe -m compileall C:\Python27\scripts\autosub_app.py
Run
C:\Python27\scripts\autosub_app.pyc YouVideo.mp4 (English Default)
Upgrade Pip
python -m pip install --upgrade pip

One-Click EASY with SENDTO.

autosub_app.zip
Create batch by language (JA) AutoSub_Jap.bat  and copy to directory SendTo
"shell:sendto"
"%APPDATA%\Microsoft\Windows\SendTo"
AutoSub_Jap.bat
C:\Python27\python.exe C:\Python27\Scripts\autosub_app.py -C 2 -S ja -D ja %1
sendto
sendto

http://www.howtogeek.com/howto/windows-vista/customize-the-windows-vista-send-to-menu/
7.- Translate your Subtitles
Download Subtitle Edit https://github.com/SubtitleEdit/subtitleedit/releases
SubtitleEdit-3.4.13-Setup.zip Or VersionPortable SE3413PL.zip

  • Run SubtitleEdit.exe

  • Open Subtitle (TuVideo.srt,YouAnimeVideo.srt,YouVideo)

  • Menu-Auto-Translate-(PowerbyGoogle)

  • From(Japanese) To:English

  • Translate
    SUBTITLEEdit

Or

https://sourceforge.net/projects/srt-tran/
SRTTRANSLATOR



Results:

Link Video Youtube Test

Comparison

Auto-Generated by Youtube
President Obama Addresses the Nation on the BP Oil Spill (inglés).Youtube.srt.txt
Generated by Script AutoSub
President Obama Addresses the Nation on the BP Oil Spill (inglés).AutoSub.srt.txt
Time Process: 01:15 Abot Minute
Times are best generated by AUTOSUB.

Errors Commons in Windows

-Error install pip
"python setup.py egg_info"
Solution
Install Python 2.7 uninstall 3.x

"WindowsError [Error 2]"

C:\Python27>python.exe C:\Python27\scripts\autosub_app.py -S en -D en test.mp4
Traceback (most recent call last):
  File "C:\Python27\scripts\autosub_app.py", line 284, in <module>
    sys.exit(main())
  File "C:\Python27\scripts\autosub_app.py", line 210, in main
    audio_filename, audio_rate = extract_audio(args.source_path)
  File "C:\Python27\scripts\autosub_app.py", line 120, in extract_audio
    subprocess.check_output(command)
  File "C:\Python27\lib\subprocess.py", line 566, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2]

Solution.
Copy ffmpeg.exe to C:\Python27\
or
Or ADD Path (Directory) File ffmpeg.
Examples: c:\ffmpeg\ ,  c:\Program Files\ffmpeg, c:\Mydownloads
Link Help Add Path(Directory)
http://www.computerhope.com/issues/ch000549.htm
python

Error infinite loop

"File "C:\Python27\lib\multiprocessing\forking.py", line 380"
"File "C:\Python27\lib\multiprocessing\forking.py", line 503"
ImportError : prepare(preparation_data)

Solution
Change name script C:\Python27\Scripts\autosub autosub_app.py

Error Permission denied Files Flac
c:...local\temp\tmpksjd.flac Permission denied
Solution:
Modify Script, close file. Link
#15

----------------------Before - Original-------------------------

class FLACConverter(object):
    def __init__(self, source_path, include_before=0.25, include_after=0.25):
        self.source_path = source_path
        self.include_before = include_before
        self.include_after = include_after

    def __call__(self, region):
        try:
            start, end = region
            start = max(0, start - self.include_before)
            end += self.include_after
            temp = tempfile.NamedTemporaryFile(suffix='.flac')
            command = ["ffmpeg", "-y", "-i", self.source_path,
                       "-ss", str(start), "-t", str(end - start),
                       "-loglevel", "error", temp.name]
            subprocess.check_output(command)
            os.system('stty sane')
            return temp.read()

----------------------After - Modified Option 1 ------------------------

class FLACConverter(object):
    def __init__(self, source_path, include_before=0.25, include_after=0.25):
        self.source_path = source_path
        self.include_before = include_before
        self.include_after = include_after

    def __call__(self, region):
        try:
            start, end = region
            start = max(0, start - self.include_before)
            end += self.include_after
            temp = tempfile.NamedTemporaryFile(suffix='.flac')      
            temp.close()
            command = ["ffmpeg", "-y", "-i", self.source_path,
                       "-ss", str(start), "-t", str(end - start),
                       "-loglevel", "error", temp.name]
            subprocess.check_output(command)
            return open(temp.name, "rb").read()

----------------------after - Modified Option 2 ------------------------

class FLACConverter(object):
    def __init__(self, source_path, include_before=0.25, include_after=0.25):
        self.source_path = source_path
        self.include_before = include_before
        self.include_after = include_after

    def __call__(self, region):
        try:
            start, end = region
            start = max(0, start - self.include_before)
            end += self.include_after
            temp = tempfile.NamedTemporaryFile(suffix='.flac', delete=False)
            command = ["ffmpeg", "-y", "-i", self.source_path,
                       "-ss", str(start), "-t", str(end - start),
                       "-loglevel", "error", temp.name]
            subprocess.check_output(command)
            return temp.read()

        except KeyboardInterrupt:
            return

Message Normal Output Pip install autosub

Collecting autosub
  Downloading autosub-0.3.9.tar.gz
Collecting google-api-python-client>=1.4.2 (from autosub)
  Downloading google_api_python_client-1.5.1-py2.py3-none-any.whl (50kB)
Collecting requests>=2.3.0 (from autosub)
  Downloading requests-2.11.0-py2.py3-none-any.whl (514kB)
Collecting pysrt>=1.0.1 (from autosub)
  Downloading pysrt-1.1.1.tar.gz (104kB)
Collecting progressbar>=2.3 (from autosub)
  Downloading progressbar-2.3.tar.gz
Collecting six<2,>=1.6.1 (from google-api-python-client>=1.4.2->autosub)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting uritemplate<1,>=0.6 (from google-api-python-client>=1.4.2->autosub)
  Downloading uritemplate-0.6.tar.gz
Collecting httplib2<1,>=0.8 (from google-api-python-client>=1.4.2->autosub)
  Downloading httplib2-0.9.2.zip (210kB)
Collecting oauth2client (from google-api-python-client>=1.4.2->autosub)
  Downloading oauth2client-3.0.0.tar.gz (77kB)
Collecting chardet (from pysrt>=1.0.1->autosub)
  Downloading chardet-2.3.0.tar.gz (164kB)
Collecting simplejson>=2.5.0 (from uritemplate<1,>=0.6->google-api-python-client>=1.4.2->autosub)
  Downloading simplejson-3.8.2-cp27-cp27m-win32.whl (65kB)
Collecting pyasn1>=0.1.7 (from oauth2client->google-api-python-client>=1.4.2->autosub)
  Downloading pyasn1-0.1.9-py2.py3-none-any.whl
Collecting pyasn1-modules>=0.0.5 (from oauth2client->google-api-python-client>=1.4.2->autosub)
  Downloading pyasn1_modules-0.0.8-py2.py3-none-any.whl
Collecting rsa>=3.1.4 (from oauth2client->google-api-python-client>=1.4.2->autosub)
  Downloading rsa-3.4.2-py2.py3-none-any.whl (46kB)
Installing collected packages: six, simplejson, uritemplate, httplib2, pyasn1, pyasn1-modules, rsa, oauth2client, google-api-python-client, requests, chardet, pysrt, progressbar, autosub
  Running setup.py install for uritemplate: started
    Running setup.py install for uritemplate: finished with status 'done'
  Running setup.py install for httplib2: started
    Running setup.py install for httplib2: finished with status 'done'
  Running setup.py install for oauth2client: started
    Running setup.py install for oauth2client: finished with status 'done'
  Running setup.py install for chardet: started
    Running setup.py install for chardet: finished with status 'done'
  Running setup.py install for pysrt: started
    Running setup.py install for pysrt: finished with status 'done'
  Running setup.py install for progressbar: started
    Running setup.py install for progressbar: finished with status 'done'
  Running setup.py install for autosub: started
    Running setup.py install for autosub: finished with status 'done'
Successfully installed autosub-0.3.9 chardet-2.3.0 google-api-python-client-1.5.1 httplib2-0.9.2 oauth2client-3.0.0 progressbar-2.3 pyasn1-0.1.9 pyasn1-modules-0.0.8 pysrt-1.1.1 requests-2.11.0 rsa-3.4.2 simplejson-3.8.2 six-1.10.0 uritemplate-0.6

For Version autosub 0.3.9
File For Windows Modified. Rename autosub_app.py.txt to autosub_app.py, and copy

C:\Python27\Scripts

autosub_app.py.txt
SampleVideos Spanish - English.zip
autosub_app 0.3.12.zip


      From: https://github.com/agermanidis/autosub/issues/31