コード例 #1
0
ファイル: scanner.py プロジェクト: namacha/dotfiles
 def scan_plain(self):
     chunks = []
     start_mark = self.get_mark()
     spaces = []
     while True:
         length = 0
         while True:
             if self.peek(length) not in 'eE.0123456789nul-tr+fas':
                 break
             length += 1
         if length == 0:
             break
         self.allow_simple_key = False
         chunks.extend(spaces)
         chunks.append(self.prefix(length))
         self.forward(length)
     end_mark = self.get_mark()
     return tokens.ScalarToken(''.join(chunks), True, start_mark, end_mark)
コード例 #2
0
ファイル: scanner.py プロジェクト: neuroradiology/powerline
	def scan_flow_scalar(self):
		# See the specification for details.
		# Note that we loose indentation rules for quoted scalars. Quoted
		# scalars don't need to adhere indentation because " and ' clearly
		# mark the beginning and the end of them. Therefore we are less
		# restrictive then the specification requires. We only need to check
		# that document separators are not included in scalars.
		chunks = []
		start_mark = self.get_mark()
		quote = self.peek()
		self.forward()
		chunks.extend(self.scan_flow_scalar_non_spaces(start_mark))
		while self.peek() != quote:
			chunks.extend(self.scan_flow_scalar_spaces(start_mark))
			chunks.extend(self.scan_flow_scalar_non_spaces(start_mark))
		self.forward()
		end_mark = self.get_mark()
		return tokens.ScalarToken(unicode().join(chunks), False, start_mark, end_mark, '"')