/**
* Copyright (c) 2008-2012, http://www.snakeyaml.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.yaml.snakeyaml.scanner;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.yaml.snakeyaml.error.Mark;
import org.yaml.snakeyaml.error.YAMLException;
import org.yaml.snakeyaml.reader.StreamReader;
import org.yaml.snakeyaml.tokens.AliasToken;
import org.yaml.snakeyaml.tokens.AnchorToken;
import org.yaml.snakeyaml.tokens.BlockEndToken;
import org.yaml.snakeyaml.tokens.BlockEntryToken;
import org.yaml.snakeyaml.tokens.BlockMappingStartToken;
import org.yaml.snakeyaml.tokens.BlockSequenceStartToken;
import org.yaml.snakeyaml.tokens.DirectiveToken;
import org.yaml.snakeyaml.tokens.DocumentEndToken;
import org.yaml.snakeyaml.tokens.DocumentStartToken;
import org.yaml.snakeyaml.tokens.FlowEntryToken;
import org.yaml.snakeyaml.tokens.FlowMappingEndToken;
import org.yaml.snakeyaml.tokens.FlowMappingStartToken;
import org.yaml.snakeyaml.tokens.FlowSequenceEndToken;
import org.yaml.snakeyaml.tokens.FlowSequenceStartToken;
import org.yaml.snakeyaml.tokens.KeyToken;
import org.yaml.snakeyaml.tokens.ScalarToken;
import org.yaml.snakeyaml.tokens.StreamEndToken;
import org.yaml.snakeyaml.tokens.StreamStartToken;
import org.yaml.snakeyaml.tokens.TagToken;
import org.yaml.snakeyaml.tokens.TagTuple;
import org.yaml.snakeyaml.tokens.Token;
import org.yaml.snakeyaml.tokens.ValueToken;
import org.yaml.snakeyaml.util.ArrayStack;
import org.yaml.snakeyaml.util.UriEncoder;
/**
* <pre>
* Scanner produces tokens of the following types:
* STREAM-START
* STREAM-END
* DIRECTIVE(name, value)
* DOCUMENT-START
* DOCUMENT-END
* BLOCK-SEQUENCE-START
* BLOCK-MAPPING-START
* BLOCK-END
* FLOW-SEQUENCE-START
* FLOW-MAPPING-START
* FLOW-SEQUENCE-END
* FLOW-MAPPING-END
* BLOCK-ENTRY
* FLOW-ENTRY
* KEY
* VALUE
* ALIAS(value)
* ANCHOR(value)
* TAG(value)
* SCALAR(value, plain, style)
* Read comments in the Scanner code for more details.
* </pre>
*/
public final class ScannerImpl implements Scanner {
/**
* A regular expression matching characters which are not in the hexadecimal
* set (0-9, A-F, a-f).
*/
private final static Pattern NOT_HEXA = Pattern.compile("[^0-9A-Fa-f]");
/**
* A mapping from an escaped character in the input stream to the character
* that they should be replaced with.
*
* YAML defines several common and a few uncommon escape sequences.
*
* @see http://www.yaml.org/spec/current.html#id2517668
*/
public final static Map<Character, String> ESCAPE_REPLACEMENTS = new HashMap<Character, String>();
/**
* A mapping from a character to a number of bytes to read-ahead for that
* escape sequence. These escape sequences are used to handle unicode
* escaping in the following formats, where H is a hexadecimal character:
*
* <pre>
* \xHH : escaped 8-bit Unicode character
* \uHHHH : escaped 16-bit Unicode character
* \UHHHHHHHH : escaped 32-bit Unicode character
* </pre>
*
* @see http://yaml.org/spec/1.1/current.html#id872840
*/
public final static Map<Character, Integer> ESCAPE_CODES = new HashMap<Character, Integer>();
static {
// ASCII null
ESCAPE_REPLACEMENTS.put(Character.valueOf('0'), "\0");
// ASCII bell
ESCAPE_REPLACEMENTS.put(Character.valueOf('a'), "\u0007");
// ASCII backspace
ESCAPE_REPLACEMENTS.put(Character.valueOf('b'), "\u0008");
// ASCII horizontal tab
ESCAPE_REPLACEMENTS.put(Character.valueOf('t'), "\u0009");
// ASCII newline (line feed; \n maps to 0x0A)
ESCAPE_REPLACEMENTS.put(Character.valueOf('n'), "\n");
// ASCII vertical tab
ESCAPE_REPLACEMENTS.put(Character.valueOf('v'), "\u000B");
// ASCII form-feed
ESCAPE_REPLACEMENTS.put(Character.valueOf('f'), "\u000C");
// carriage-return (\r maps to 0x0D)
ESCAPE_REPLACEMENTS.put(Character.valueOf('r'), "\r");
// ASCII escape character (Esc)
ESCAPE_REPLACEMENTS.put(Character.valueOf('e'), "\u001B");
// ASCII space
ESCAPE_REPLACEMENTS.put(Character.valueOf(' '), "\u0020");
// ASCII double-quote
ESCAPE_REPLACEMENTS.put(Character.valueOf('"'), "\"");
// ASCII backslash
ESCAPE_REPLACEMENTS.put(Character.valueOf('\\'), "\\");
// Unicode next line
ESCAPE_REPLACEMENTS.put(Character.valueOf('N'), "\u0085");
// Unicode non-breaking-space
ESCAPE_REPLACEMENTS.put(Character.valueOf('_'), "\u00A0");
// Unicode line-separator
ESCAPE_REPLACEMENTS.put(Character.valueOf('L'), "\u2028");
// Unicode paragraph separator
ESCAPE_REPLACEMENTS.put(Character.valueOf('P'), "\u2029");
// 8-bit Unicode
ESCAPE_CODES.put(Character.valueOf('x'), 2);
// 16-bit Unicode
ESCAPE_CODES.put(Character.valueOf('u'), 4);
// 32-bit Unicode (Supplementary characters are supported)
ESCAPE_CODES.put(Character.valueOf('U'), 8);
}
private final StreamReader reader;
// Had we reached the end of the stream?
private boolean done = false;
// The number of unclosed '{' and '['. `flow_level == 0` means block
// context.
private int flowLevel = 0;
// List of processed tokens that are not yet emitted.
private List<Token> tokens;
// Number of tokens that were emitted through the `get_token` method.
private int tokensTaken = 0;
// The current indentation level.
private int indent = -1;
// Past indentation levels.
private ArrayStack<Integer> indents;
// Variables related to simple keys treatment. See PyYAML.
/**
* <pre>
* A simple key is a key that is not denoted by the '?' indicator.
* Example of simple keys:
* ---
* block simple key: value
* ? not a simple key:
* : { flow simple key: value }
* We emit the KEY token before all keys, so when we find a potential
* simple key, we try to locate the corresponding ':' indicator.
* Simple keys should be limited to a single line and 1024 characters.
*
* Can a simple key start at the current position? A simple key may
* start:
* - at the beginning of the line, not counting indentation spaces
* (in block context),
* - after '{', '[', ',' (in the flow context),
* - after '?', ':', '-' (in the block context).
* In the block context, this flag also signifies if a block collection
* may start at the current position.
* </pre>
*/
private boolean allowSimpleKey = true;
/*
* Keep track of possible simple keys. This is a dictionary. The key is
* `flow_level`; there can be no more that one possible simple key for each
* level. The value is a SimpleKey record: (token_number, required, index,
* line, column, mark) A simple key may start with ALIAS, ANCHOR, TAG,
* SCALAR(flow), '[', or '{' tokens.
*/
private Map<Integer, SimpleKey> possibleSimpleKeys;
public ScannerImpl(StreamReader reader) {
this.reader = reader;
this.tokens = new ArrayList<Token>(100)
没有合适的资源?快使用搜索试试~ 我知道了~
YAML解析器 SnakeYAML.7z
共2000个文件
html:1505个
i:1366个
class:1023个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 37 浏览量
2022-07-06
12:47:35
上传
评论
收藏 12.14MB 7Z 举报
温馨提示
YAML解析器 SnakeYAML.7z
资源推荐
资源详情
资源评论
收起资源包目录
YAML解析器 SnakeYAML.7z (2000个子文件)
maven-theme.css 3KB
maven-base.css 2KB
main.css 2KB
stylesheet.css 2KB
stylesheet.css 2KB
stylesheet.css 1KB
stylesheet.css 1KB
source-viewer.css 1KB
sortabletable.css 979B
tooltip.css 845B
help.css 286B
print.css 222B
site.css 0B
org.yaml.snakeyaml.scanner.ScannerImpl.html 468KB
org.yaml.snakeyaml.emitter.Emitter.html 342KB
ScannerImpl.html 290KB
index-all.html 260KB
index-all.html 260KB
surefire-report.html 222KB
org.yaml.snakeyaml.parser.ParserImpl.html 188KB
Emitter.html 185KB
org.yaml.snakeyaml.constructor.Constructor.html 148KB
org.yaml.snakeyaml.Yaml.html 148KB
ParserImpl.html 117KB
org.yaml.snakeyaml.constructor.SafeConstructor.html 116KB
Yaml.html 97KB
Constructor.html 92KB
changes-report.html 91KB
org.yaml.snakeyaml.constructor.BaseConstructor.html 85KB
org.yaml.snakeyaml.DumperOptions.html 82KB
org.yaml.snakeyaml.representer.SafeRepresenter.html 81KB
HumanTest.html 79KB
Yaml.html 70KB
SafeConstructor.html 69KB
UnicodeEscaper.html 69KB
Yaml.html 68KB
Mark.html 66KB
Mark.html 65KB
allclasses-frame.html 62KB
HumanGenericsTest.html 61KB
Node.html 58KB
Node.html 58KB
org.yaml.snakeyaml.representer.Representer.html 53KB
BaseConstructor.html 52KB
org.yaml.snakeyaml.composer.Composer.html 51KB
DumperOptions.html 50KB
org.yaml.snakeyaml.serializer.Serializer.html 48KB
SafeRepresenter.html 46KB
Tag.html 46KB
org.yaml.snakeyaml.reader.StreamReader.html 46KB
Tag.html 46KB
org.yaml.snakeyaml.representer.BaseRepresenter.html 46KB
BaseConstructor.html 45KB
org.yaml.snakeyaml.extensions.compactnotation.CompactConstructor.html 45KB
BaseConstructor.html 44KB
DumperOptionsTest.html 44KB
PropOrderInfluenceWhenAliasedInGenericCollectionTest.html 44KB
RagelMachine.html 43KB
Base64Coder.html 39KB
DumperOptions.html 39KB
DumperOptions.html 38KB
org.yaml.snakeyaml.nodes.Tag.html 38KB
PyStructureTest.html 38KB
CompactConstructor.html 38KB
CompactConstructor.html 37KB
PyEmitterTest.html 37KB
PercentEscaper.html 37KB
Representer.html 36KB
CanonicalScanner.html 36KB
Representer.html 36KB
org.yaml.snakeyaml.resolver.Resolver.html 35KB
Tag.html 34KB
org.yaml.snakeyaml.introspector.PropertyUtils.html 34KB
Example2_24Test.html 34KB
frame-summary-org.yaml.snakeyaml.html 34KB
Tag.html 34KB
overview-tree.html 34KB
overview-tree.html 33KB
TypeSafeSetImplementationsTest.html 33KB
org.yaml.snakeyaml.nodes.Node.html 33KB
BaseRepresenter.html 33KB
UnicodeEscaper.html 33KB
UnicodeEscaper.html 33KB
BaseRepresenter.html 33KB
Composer.html 32KB
Serializer.html 32KB
Representer.html 31KB
Constructor.html 31KB
PercentEscaper.html 31KB
BeanConstructorTest.html 31KB
Constructor.html 31KB
PercentEscaper.html 31KB
JavaBeanLoaderTest.html 30KB
org.yaml.snakeyaml.TypeDescription.html 30KB
PackageCompactConstructor.html 29KB
PackageCompactConstructor.html 29KB
StreamReader.html 29KB
SafeConstructor.html 28KB
BaseRepresenter.html 28KB
CompactConstructor.html 28KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
qq_38220914
- 粉丝: 603
- 资源: 4313
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功