编译原理
编译原理介绍
辕门骁骑
这个作者很懒,什么都没留下…
展开
-
编译器(Compiler)
编译器读取程序源代码,然后生成机器码(适合于CPU执行的格式的指令)、字节码或其他形式。在生成目标代码时,通常必须将生成的代码经过链接阶段以转换为可执行形式。词法分析器语法分析器代码生成器虚拟机解释器AST解释器...原创 2020-03-18 12:46:50 · 6720 阅读 · 1 评论 -
语法分析器(syntax analyzer)【Python实现】
from __future__ import print_functionimport sys, shlex, operator tk_EOI, tk_Mul, tk_Div, tk_Mod, tk_Add, tk_Sub, tk_Negate, tk_Not, tk_Lss, tk_Leq, tk_Gtr, \tk_Geq, tk_Eql, tk_Neq, tk_Assign, tk_A...原创 2020-03-10 10:44:12 · 3895 阅读 · 0 评论 -
语法分析器(syntax analyzer)【Perl实现】
【代码】语法分析器(syntax analyzer)【Perl实现】原创 2020-03-10 10:43:29 · 7456 阅读 · 1 评论 -
语法分析器(syntax analyzer)【Java实现】
import java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;import java.util.StringTokenizer;import java.util.List;import java.util.ArrayList;import java.util.Map;import j...原创 2020-03-10 10:42:46 · 5704 阅读 · 0 评论 -
语法分析器(syntax analyzer)【Go实现】
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings") type TokenType int const ( tkEOI TokenType = iota tkMul tkDiv tkMod tkAdd tkS...原创 2020-03-10 10:41:49 · 3283 阅读 · 0 评论 -
语法分析器(syntax analyzer)【C实现】
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <stdarg.h>#include <stdbool.h>#include <ctype.h> #define NELEMS(arr) (sizeof(arr) / sizeof(a...原创 2020-03-10 10:40:17 · 2628 阅读 · 0 评论 -
编译器之语法分析器(syntax analyzer)
语法分析器根据语法将标记流(来自词法分析器)转换为语法树。目标从“词法分析器” 任务中获取输出,并根据以下语法将其转换为抽象语法树(AST)。输出应为展平格式。程序应从文件和/或stdin读取输入,并将输出写入文件和/或stdout。如果使用的语言具有解析器模块/库/类,则提供两种版本的解决方案将是很好的选择:一个不带解析器模块,另一个带解析器模块。语法 stmt_list ...原创 2020-03-09 22:29:18 · 10524 阅读 · 0 评论 -
词法分析器(Lexical Analyzer)【Python实现】
正文内容from __future__ import print_functionimport sys # following two must remain in the same order tk_EOI, tk_Mul, tk_Div, tk_Mod, tk_Add, tk_Sub, tk_Negate, tk_Not, tk_Lss, tk_Leq, tk_Gtr, \tk_...原创 2019-12-16 19:13:47 · 8236 阅读 · 0 评论 -
词法分析器(Lexical Analyzer)【JavaScript实现】
正文内容/* Token: type, value, line, pos*/ const TokenType = { Keyword_if: 1, Keyword_else: 2, Keyword_print: 3, Keyword_putc: 4, Keyword_while: 5, Op_add: 6, Op_and: 7, Op_assign: 8, Op_d...原创 2019-12-16 19:13:12 · 2835 阅读 · 1 评论 -
词法分析器(Lexical Analyzer)【Java实现】
正文内容import java.io.File;import java.io.FileNotFoundException;import java.util.HashMap;import java.util.Map;import java.util.Scanner; public class Lexer { private int line; private int p...原创 2019-12-16 19:12:29 · 3366 阅读 · 0 评论 -
词法分析器(Lexical Analyzer)【Go实现】
正文内容package main import ( "bufio" "fmt" "log" "os") type TokenType int const ( tkEOI TokenType = iota tkMul tkDiv tkMod tkAdd tkSub tkNegate tkN...原创 2019-12-16 19:11:56 · 2447 阅读 · 0 评论 -
词法分析器(Lexical Analyzer)【C#实现】
正文内容using System;using System.IO;using System.Linq;using System.Collections.Generic; namespace Rosetta { public enum TokenType { End_of_input, Op_multiply, Op_divide, Op_mod, Op_...原创 2019-12-16 19:11:20 · 3250 阅读 · 0 评论 -
词法分析器(Lexical Analyzer)【C实现】
正文内容#include <stdlib.h>#include <stdio.h>#include <stdarg.h>#include <ctype.h>#include <string.h>#include <errno.h>#include <stdbool.h>#include <li...原创 2019-12-16 19:10:21 · 3688 阅读 · 0 评论 -
编译器之词法分析器(Lexical Analyzer)
定义(来自维基百科)词法分析(英语:lexical analysis)是计算机科学中将字符序列转换为标记(token)序列的过程。进行词法分析的程序或者函数叫作词法分析器(lexical analyzer,简称lexer),也叫扫描器(scanner)。词法分析器一般以函数的形式存在,供语法分析器调用。目标为下面指定的简单编程语言创建一个词法分析器。 程序应从文件和/或stdin读取输入,...原创 2019-12-16 19:03:10 · 12811 阅读 · 0 评论