aboutsummaryrefslogtreecommitdiff
path: root/module/c/lex.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-06-28 23:46:08 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-07-07 21:17:22 +0200
commit690034ca8abcd931e2fb6bb8129450deee701179 (patch)
treeb9b1fc396dcab97b6c08de71e89e8d985fdb93bd /module/c/lex.scm
parentJS user addition for parsing Microsoft Teams links. (diff)
downloadcalp-690034ca8abcd931e2fb6bb8129450deee701179.tar.gz
calp-690034ca8abcd931e2fb6bb8129450deee701179.tar.xz
Major work on c parser.
Diffstat (limited to 'module/c/lex.scm')
-rw-r--r--module/c/lex.scm25
1 files changed, 22 insertions, 3 deletions
diff --git a/module/c/lex.scm b/module/c/lex.scm
index 34e52d88..5f395322 100644
--- a/module/c/lex.scm
+++ b/module/c/lex.scm
@@ -43,8 +43,22 @@
(define-peg-pattern integer all
(and (or base-8 base-16 base-10) (? integer-suffix)))
+;; (define-peg-pattern float-suffix all
+;; (* (or "f" "F" "l" "L")))
+
+;; (define-peg-pattern exponent all
+;; (and (ignore (or "e" "E")) (? (or "+" "-")) base-10))
+
+;; (define-peg-pattern float all
+;; (or
+;; (and base-10 exponent (? float-suffix))
+;; (and base-10 (ignore ".") (? exponent) (? float-suffix))
+;; (and (? base-10) (ignore ".") base-10 (? exponent) (? float-suffix))))
+
(define-peg-pattern number body
- (or integer))
+ (or ; float
+ integer
+ ))
(define-peg-pattern group all
(and (ignore "(") expr (ignore ")")))
@@ -65,11 +79,16 @@
(define-peg-pattern char all
(and (ignore "'") (or escaped-char peg-any) (ignore "'")))
+;; (define-peg-pattern quot none (string "\""))
+
+;; (define-peg-pattern string all
+;; (and quot (* (or escaped-char (or peg-any))) quot))
(define-peg-pattern* operator all
`(or ,@(map symbol->string symbol-binary-operators)
,@(map (lambda (op) `(and ,(symbol->string op) ws))
- wordy-binary-operators)))
+ wordy-binary-operators)
+ "?" ":"))
;; whitespace
(define-peg-pattern ws none
@@ -99,7 +118,7 @@
)))
(define-peg-pattern postfix-operator all
- (or "++" "--"))
+ (or "++" "--" "*"))
(define-peg-pattern postfix all
;; literals can't be in-place incremented and decremented