Browse code
Expand parse-tokens
Fernando Borretti authored on 30/01/2015 00:30:27
Showing 2 changed files
Showing 2 changed files
... | ... |
@@ -6,7 +6,8 @@ |
6 | 6 |
:homepage "https://github.com/eudoxia0/cl-yaml" |
7 | 7 |
:bug-tracker "https://github.com/eudoxia0/cl-yaml/issues" |
8 | 8 |
:source-control (:git "git@github.com:eudoxia0/cl-yaml.git") |
9 |
- :depends-on (:cl-libyaml) |
|
9 |
+ :depends-on (:cl-libyaml |
|
10 |
+ :alexandria) |
|
10 | 11 |
:components ((:module "src" |
11 | 12 |
:serial t |
12 | 13 |
:components |
... | ... |
@@ -1,6 +1,8 @@ |
1 | 1 |
(in-package :cl-user) |
2 | 2 |
(defpackage yaml.parser |
3 | 3 |
(:use :cl) |
4 |
+ (:import-from :alexandria |
|
5 |
+ :destructuring-case) |
|
4 | 6 |
(:import-from :libyaml.macros |
5 | 7 |
:with-parser |
6 | 8 |
:with-event) |
... | ... |
@@ -72,7 +74,34 @@ |
72 | 74 |
(signal-reader-error parser))))))) |
73 | 75 |
|
74 | 76 |
(defun parse-tokens (vector) |
75 |
- vector) |
|
77 |
+ (loop for token across vector do |
|
78 |
+ (print (first token)) |
|
79 |
+ (destructuring-case token |
|
80 |
+ ;; Documents |
|
81 |
+ ((:document-start-event) |
|
82 |
+ t) |
|
83 |
+ ((:document-end-event) |
|
84 |
+ t) |
|
85 |
+ ;; Alias event |
|
86 |
+ ((:alias-event &key anchor) |
|
87 |
+ (print anchor)) |
|
88 |
+ ;; Scalar |
|
89 |
+ ((:scalar-event &key anchor tag value) |
|
90 |
+ (print (list anchor tag value))) |
|
91 |
+ ;; Sequence start event |
|
92 |
+ ((:sequence-start-event &key anchor tag) |
|
93 |
+ (print (list anchor tag))) |
|
94 |
+ ;; Mapping start event |
|
95 |
+ ((:mapping-start-event &key anchor tag) |
|
96 |
+ (print (list anchor tag))) |
|
97 |
+ ;; End events |
|
98 |
+ ((:sequence-end-event) |
|
99 |
+ t) |
|
100 |
+ ((:mapping-end-event) |
|
101 |
+ t) |
|
102 |
+ ;; Do nothing |
|
103 |
+ ((t &rest rest) |
|
104 |
+ t)))) |
|
76 | 105 |
|
77 | 106 |
;;; The public interface |
78 | 107 |
|