Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cbd67991
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cbd67991
编写于
7月 15, 2014
作者:
C
Corey Richardson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lexer tests: makefile/configure
上级
188d889a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
84 addition
and
2 deletion
+84
-2
Makefile.in
Makefile.in
+13
-0
configure
configure
+3
-0
mk/grammar.mk
mk/grammar.mk
+43
-0
src/grammar/check.sh
src/grammar/check.sh
+21
-0
src/grammar/verify.rs
src/grammar/verify.rs
+4
-2
未找到文件。
Makefile.in
浏览文件 @
cbd67991
...
...
@@ -252,6 +252,19 @@ ifneq ($(findstring clean,$(MAKECMDGOALS)),)
include
$(CFG_SRC_DIR)mk/clean.mk
endif
# Grammar tests
ifneq
($(findstring lexer,$(MAKECMDGOALS)),)
ifdef
CFG_JAVAC
ifdef
CFG_ANTLR4
ifdef
CFG_GRUN
CFG_INFO
:=
$
(
info cfg: including grammar tests
)
include
$(CFG_SRC_DIR)mk/grammar.mk
endif
endif
endif
endif
# CTAGS building
ifneq
($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
$(findstring
TAGS.vi,$(MAKECMDGOALS))),)
...
...
configure
浏览文件 @
cbd67991
...
...
@@ -493,6 +493,9 @@ probe CFG_VALGRIND valgrind
probe CFG_PERF perf
probe CFG_ISCC iscc
probe CFG_LLNEXTGEN LLnextgen
probe CFG_JAVAC javac
probe CFG_ANTLR4 antlr4
probe CFG_GRUN grun
probe CFG_PANDOC pandoc
probe CFG_PDFLATEX pdflatex
probe CFG_XELATEX xelatex
...
...
mk/grammar.mk
0 → 100644
浏览文件 @
cbd67991
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.
BG
=
$(CFG_BUILD_DIR)
/grammar/
SG
=
$(S)
src/grammar/
B
=
$(CFG_BUILD_DIR)
/
$(CFG_BUILD)
/stage2/
L
=
$(B)
lib/rustlib/
$(CFG_BUILD)
/lib
LD
=
$(CFG_BUILD)
/stage2/lib/rustlib/
$(CFG_BUILD)
/lib/
RUSTC
=
$(B)
bin/rustc
# Run the reference lexer against libsyntax and compare the tokens and spans.
# If "// ignore-lexer-test" is present in the file, it will be ignored.
#
# $(1) is the file to test.
define
LEXER_TEST
grep
"// ignore-lexer-test"
$(1)
;
\
if
[
$$?
-eq
1
];
then
\
CLASSPATH
=
$(B)
grammar
$(CFG_GRUN)
RustLexer tokens
-tokens
<
$(1)
\
|
$(B)
grammar/verify
$(1)
;
\
fi
endef
$(BG)
:
$(Q)
mkdir
-p
$(BG)
$(BG)RustLexer.class
:
$(SG)RustLexer.g4
$(Q)$(CFG_ANTLR4)
-o
$(B)
grammar
$(SG)
RustLexer.g4
$(Q)$(CFG_JAVAC)
-d
$(BG)
$(BG)
RustLexer.java
$(BG)verify
:
$(SG)verify.rs rustc-stage2-H-$(CFG_BUILD) $(LD)stamp.regex_macros $(LD)stamp.rustc
$(Q)$(RUSTC)
-O
--out-dir
$(BG)
-L
$(L)
$(SG)
verify.rs
check-lexer
:
$(BG) $(BG)RustLexer.class $(BG)verify
$
(
info Verifying libsyntax against the reference lexer ...
)
$(Q)
find
$(S)
-iname
'*.rs'
-exec
"
$(SG)
check.sh"
{}
"
$(BG)
"
\
"
$(CFG_GRUN)
"
"
$(BG)
verify"
"
$(BG)
RustLexer.tokens"
"
$(VERBOSE)
"
\;
src/grammar/check.sh
0 → 100755
浏览文件 @
cbd67991
#!/bin/sh
# Run the reference lexer against libsyntax and compare the tokens and spans.
# If "// ignore-lexer-test" is present in the file, it will be ignored.
#
# Argument $1 is the file to check, $2 is the classpath to use, $3 is the path
# to the grun binary, $4 is the path to the verify binary, $5 is the path to
# RustLexer.tokens
if
[
"
${
VERBOSE
}
"
==
"1"
]
;
then
set
-x
fi
grep
-q
"// ignore lexer-test"
$1
;
if
[
$?
-eq
1
]
;
then
cd
$2
# This `cd` is so java will pick up RustLexer.class. I couldn't
# figure out how to wrangle the CLASSPATH, just adding build/grammr didn't
# seem to have anny effect.
$3
RustLexer tokens
-tokens
<
$1
|
$4
$1
$5
fi
src/grammar/verify.rs
浏览文件 @
cbd67991
...
...
@@ -223,11 +223,13 @@ fn next(r: &mut lexer::StringReader) -> TokenAndSpan {
r
.next_token
()
}
let
token_map
=
parse_token_list
(
File
::
open
(
&
Path
::
new
(
"RustLexer.tokens"
))
.unwrap
()
.read_to_string
()
.unwrap
()
.as_slice
());
let
args
=
std
::
os
::
args
();
let
token_map
=
parse_token_list
(
File
::
open
(
&
Path
::
new
(
args
.get
(
2
)
.as_slice
()))
.unwrap
()
.read_to_string
()
.unwrap
()
.as_slice
());
let
mut
stdin
=
std
::
io
::
stdin
();
let
mut
antlr_tokens
=
stdin
.lines
()
.map
(|
l
|
parse_antlr_token
(
l
.unwrap
()
.as_slice
()
.trim
(),
&
token_map
));
let
code
=
File
::
open
(
&
Path
::
new
(
std
::
os
::
args
()
.get
(
1
)
.as_slice
()))
.unwrap
()
.read_to_string
()
.unwrap
();
let
code
=
File
::
open
(
&
Path
::
new
(
args
.get
(
1
)
.as_slice
()))
.unwrap
()
.read_to_string
()
.unwrap
();
let
options
=
config
::
basic_options
();
let
session
=
session
::
build_session
(
options
,
None
,
syntax
::
diagnostics
::
registry
::
Registry
::
new
([]));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录