Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

parse-cst.d.ts 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import { Type, YAMLSyntaxError } from './util'
  2. export default function parseCST(str: string): ParsedCST
  3. export interface ParsedCST extends Array<CST.Document> {
  4. setOrigRanges(): boolean
  5. }
  6. export namespace CST {
  7. interface Range {
  8. start: number
  9. end: number
  10. origStart?: number
  11. origEnd?: number
  12. isEmpty(): boolean
  13. }
  14. interface ParseContext {
  15. /** Node starts at beginning of line */
  16. atLineStart: boolean
  17. /** true if currently in a collection context */
  18. inCollection: boolean
  19. /** true if currently in a flow context */
  20. inFlow: boolean
  21. /** Current level of indentation */
  22. indent: number
  23. /** Start of the current line */
  24. lineStart: number
  25. /** The parent of the node */
  26. parent: Node
  27. /** Source of the YAML document */
  28. src: string
  29. }
  30. interface Node {
  31. context: ParseContext | null
  32. /** if not null, indicates a parser failure */
  33. error: YAMLSyntaxError | null
  34. /** span of context.src parsed into this node */
  35. range: Range | null
  36. valueRange: Range | null
  37. /** anchors, tags and comments */
  38. props: Range[]
  39. /** specific node type */
  40. type: Type
  41. /** if non-null, overrides source value */
  42. value: string | null
  43. readonly anchor: string | null
  44. readonly comment: string | null
  45. readonly hasComment: boolean
  46. readonly hasProps: boolean
  47. readonly jsonLike: boolean
  48. readonly rangeAsLinePos: null | {
  49. start: { line: number; col: number }
  50. end?: { line: number; col: number }
  51. }
  52. readonly rawValue: string | null
  53. readonly tag:
  54. | null
  55. | { verbatim: string }
  56. | { handle: string; suffix: string }
  57. readonly valueRangeContainsNewline: boolean
  58. }
  59. interface Alias extends Node {
  60. type: Type.ALIAS
  61. /** contain the anchor without the * prefix */
  62. readonly rawValue: string
  63. }
  64. type Scalar = BlockValue | PlainValue | QuoteValue
  65. interface BlockValue extends Node {
  66. type: Type.BLOCK_FOLDED | Type.BLOCK_LITERAL
  67. chomping: 'CLIP' | 'KEEP' | 'STRIP'
  68. blockIndent: number | null
  69. header: Range
  70. readonly strValue: string | null
  71. }
  72. interface BlockFolded extends BlockValue {
  73. type: Type.BLOCK_FOLDED
  74. }
  75. interface BlockLiteral extends BlockValue {
  76. type: Type.BLOCK_LITERAL
  77. }
  78. interface PlainValue extends Node {
  79. type: Type.PLAIN
  80. readonly strValue: string | null
  81. }
  82. interface QuoteValue extends Node {
  83. type: Type.QUOTE_DOUBLE | Type.QUOTE_SINGLE
  84. readonly strValue:
  85. | null
  86. | string
  87. | { str: string; errors: YAMLSyntaxError[] }
  88. }
  89. interface QuoteDouble extends QuoteValue {
  90. type: Type.QUOTE_DOUBLE
  91. }
  92. interface QuoteSingle extends QuoteValue {
  93. type: Type.QUOTE_SINGLE
  94. }
  95. interface Comment extends Node {
  96. type: Type.COMMENT
  97. readonly anchor: null
  98. readonly comment: string
  99. readonly rawValue: null
  100. readonly tag: null
  101. }
  102. interface BlankLine extends Node {
  103. type: Type.BLANK_LINE
  104. }
  105. interface MapItem extends Node {
  106. type: Type.MAP_KEY | Type.MAP_VALUE
  107. node: ContentNode | null
  108. }
  109. interface MapKey extends MapItem {
  110. type: Type.MAP_KEY
  111. }
  112. interface MapValue extends MapItem {
  113. type: Type.MAP_VALUE
  114. }
  115. interface Map extends Node {
  116. type: Type.MAP
  117. /** implicit keys are not wrapped */
  118. items: Array<BlankLine | Comment | Alias | Scalar | MapItem>
  119. }
  120. interface SeqItem extends Node {
  121. type: Type.SEQ_ITEM
  122. node: ContentNode | null
  123. }
  124. interface Seq extends Node {
  125. type: Type.SEQ
  126. items: Array<BlankLine | Comment | SeqItem>
  127. }
  128. interface FlowChar {
  129. char: '{' | '}' | '[' | ']' | ',' | '?' | ':'
  130. offset: number
  131. origOffset?: number
  132. }
  133. interface FlowCollection extends Node {
  134. type: Type.FLOW_MAP | Type.FLOW_SEQ
  135. items: Array<
  136. FlowChar | BlankLine | Comment | Alias | Scalar | FlowCollection
  137. >
  138. }
  139. interface FlowMap extends FlowCollection {
  140. type: Type.FLOW_MAP
  141. }
  142. interface FlowSeq extends FlowCollection {
  143. type: Type.FLOW_SEQ
  144. }
  145. type ContentNode = Alias | Scalar | Map | Seq | FlowCollection
  146. interface Directive extends Node {
  147. type: Type.DIRECTIVE
  148. name: string
  149. readonly anchor: null
  150. readonly parameters: string[]
  151. readonly tag: null
  152. }
  153. interface Document extends Node {
  154. type: Type.DOCUMENT
  155. directives: Array<BlankLine | Comment | Directive>
  156. contents: Array<BlankLine | Comment | ContentNode>
  157. readonly anchor: null
  158. readonly comment: null
  159. readonly tag: null
  160. }
  161. }