commit ef1d84bdd68f596142acec9ee3e12d6613d586e3
parent 6acfa72dd92e59faaf158aa92514e48b61d7419d
Author: Szymon Mikulicz <szymon.mikulicz@posteo.net>
Date: Fri, 22 May 2026 22:47:33 +0200
More PEG work
Diffstat:
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/src/main.janet b/src/main.janet
@@ -104,14 +104,16 @@
[(path/join libdir "pkgconfig")
(path/join syslibdir "pkgconfig")] ":")
"CFLAGS" (string/join
- [(stropt "--include-directory-after" headerdir)
- (stropt "-Wl,-rpath" libdir)
- (stropt "-Wl,-rpath" syslibdir)
- (string "-L" libdir)
- (string "-L" syslibdir)
- "-Wno-unused-command-line-argument"] " ")
+ [(get env "CFLAGS" "")
+ (stropt "--include-directory-after" headerdir)
+ (stropt "-Wl,-rpath" libdir)
+ (stropt "-Wl,-rpath" syslibdir)
+ (string "-L" libdir)
+ (string "-L" syslibdir)
+ "-Wno-unused-command-line-argument"] " ")
"CXXFLAGS" (string/join
- [(stropt "--include-directory-after" headerdir)
+ [(get env "CXXFLAGS" "")
+ (stropt "--include-directory-after" headerdir)
(stropt "-Wl,-rpath" libdir)
(stropt "-Wl,-rpath" syslibdir)
(string "-L" libdir)
@@ -219,6 +221,7 @@
:make
"-C" builddir
"install"
+ ;(if-let [mf (env "MAKEFLAGS")] (string/split " " mf) [])
(stropt "PREFIX" prefix)
(stropt "prefix" prefix)
(stropt "CMAKE_INSTALL_PREFIX" prefix)
diff --git a/src/mnt.janet b/src/mnt.janet
@@ -5,15 +5,18 @@
(def mnt_peg
(peg/compile
- ~{
- :main (* (only-tags (constant 0 :col)) :map)
- :key (+ :check_indent (<- (to ":")))
- :val (* " " (+ :check_key_start (* (<- (to (+ " \n" "\n" -1))) (+ :check_key_end true))))
- :pair (* :key ":" (+ (* :val (? "\n")) "\n"))
+ ~{:main (* (only-tags (constant 0 :col)) :all :check_empty)
+ :key (* :check_indent (<- (to (+ " :" ":"))) :check_end)
+ :val (* " " :check_start (<- (to (+ " \n" "\n" -1 (* " " -1)))) :check_end)
:increase (only-tags (/ (backref :col) ,inc_indent :col))
:indent (lenprefix (backref :col) " ")
- :map (any (group (unref (* :indent :pair :increase :map) :col)))
- :check_indent (error (* " " (constant "Invalid indent")))
- :check_key_start (error (* (+ " " "\n") (constant "Key starting with space")))
- :check_key_end (error (* " " (constant "Key ends with space")))
+ :list (some (* :indent "-" :val (+ -1 (some "\n"))))
+ :comment (some (* "#" (to (+ "\n" -1)) (? "\n")))
+ :all (any (+ :comment :list :map))
+ :map (some (unref (group (* :indent :key ":" (group (+ -1 (* :val (+ (some "\n") -1)) (* (some "\n") :increase :all))))) :col))
+ :check_indent (+ (error (* " " (constant "Invalid indent"))) true)
+ :check_start (+ (error (* (+ " " "\n" -1) (constant "Stray space at start"))) true)
+ :check_end (+ (error (* " " (constant "Stray space at end"))) true)
+ :check_empty (+ (error (* 1 (constant "Stray characters at the end"))) true)
}))
+