X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/blobdiff_plain/e0808c472145fc81e52898bc9ac289e10c4f4f41..3ee33e04477ace9d13587f28253fb8c6d1c7ed6c:/src/pset-parse.lisp diff --git a/src/pset-parse.lisp b/src/pset-parse.lisp index 6b91696..a2199b6 100644 --- a/src/pset-parse.lisp +++ b/src/pset-parse.lisp @@ -73,7 +73,7 @@ (defun parse-expression (scanner) "Parse and evaluate a simple expression. The result is a pair (TYPE . VALUE). Currently, type types are `:id', - `:int', `:string', and `:char'. If an error prevented a sane value from + `:int', `:string', `:char', `:fragment', `:type'. If an error prevented a sane value from being produced, the type `:invalid' is returned. The syntax of expressions is rather limited at the moment, but more may be @@ -83,7 +83,7 @@ (defun parse-expression (scanner) term: factor | term `*' factor | term `/' factor factor: primary | `+' factor | `-' factor primary: int | id | string | `(' expression `)' | `{' fragment `}' - | `?' lisp-expression + | `<' declspec+ declarator[empty] `>' | `?' lisp-expression Only operators for dealing with integers are provided." (with-parser-context (token-scanner-context :scanner scanner) @@ -100,15 +100,27 @@ (defun parse-expression (scanner) (sexp (read stream t))) (scanner-step scanner) (multiple-value-bind (type value) - (decode-property sexp) + (restart-case (decode-property (eval sexp)) + (continue () (values :invalid nil))) (values (cons type value) t t)))) (#\{ (values (cons :fragment (parse-delimited-fragment scanner #\{ #\})) t t)) + (#\< + (parse (seq (#\< + (ds (parse-c-type scanner)) + (dc (parse-declarator + scanner ds + :kernel (lambda () + (values nil t nil)) + :abstractp t)) + #\>) + (values (cons :type (car dc)) + t t)))) (t - (values (list :int :id :char :string #\?) + (values (list :int :id :char :string #\? #\{ #\<) nil nil))))) (or (seq (#\+) add) (seq (#\-) sub) @@ -122,6 +134,7 @@ (defun parse-expression (scanner) ;;;-------------------------------------------------------------------------- ;;; Parsing property sets. +(export 'parse-property) (defun parse-property (scanner pset) "Parse a single property using the SCANNER; add it to the PSET." ;; property ::= id `=' expression