Marco Maggi
2014-03-11 06:54:33 UTC
Ciao,
for an extended Scheme language I am customising a mode derived from
"scheme-mode"; I think I am on the good road with font locking of the
forms:
(define O 1)
(define {O <byte>} 1)
(define (O a b) 123)
(define ({O <byte>} a b) 123)
(define-method (O a b) 123)
(define-method ({O <byte>} a b) 123)
(case-define ciao
((a) 123))
(case-define {ciao <byte>}
((a) 123))
(define-constant ciao
123)
(define-constant {ciao <byte>}
123)
(define-inline-constant ciao
123)
(define-inline-constant {ciao <byte>}
123)
using, for example, the following components in the custom
*-font-lock-keywords:
;;This does DEFINE and DEFINE-METHOD for function bindings only.
(,(eval-when-compile
(concat "(\\s-*"
(regexp-opt '("define" "define-method") 'symbols)
"\\s-+(" ;any whitespace and open paren
"{?" ;optional open brace
"\\s-*" ;optional white space separator
"\\(" my-scheme-identifier-internal-rex "\\)"))
(1 font-lock-keyword-face)
(2 font-lock-function-name-face nil t))
;;This does DEFINE and DEFINE-CONSTANT for variable bindings only.
(,(eval-when-compile
(concat "(\\s-*"
(regexp-opt '("define" "define-constant"
"define-inline-constant")
'symbols)
"\\s-+" ;any whitespace
"{?" ;optional open brace
"\\s-*" ;optional white space separator
"\\(" my-scheme-identifier-internal-rex "\\)"))
(1 font-lock-keyword-face)
(2 font-lock-variable-name-face nil t))
but I dunno how to go to colorise the following syntaxes:
(define-values (a b c)
(values 1 2 3))
(define-values ({a <byte>} {b <byte>} {c <byte>})
(values 1 2 3))
where:
* DEFINE-VALUES should be "font-lock-keyword-face".
* "a", "b" and "c" should be "font-lock-variable-name-face"; there can
be any number of these identifiers.
* The type tags "<byte>" should be "font-lock-type-face".
To colorise the type tags I have the following font-lock-keywords
component:
(,(eval-when-compile
(concat "\\<\\("
"\\(?:" my-scheme-identifier-internal-rex "\\.\\)?"
"<" my-scheme-identifier-internal-rex ">"
"\\)\\>"))
1 font-lock-type-face)
which does both tags like "<fixnum>" and like "prefix.<fixnum>"; there
should be no need to do anything more.
How do I handle repeated patterns?
TIA
for an extended Scheme language I am customising a mode derived from
"scheme-mode"; I think I am on the good road with font locking of the
forms:
(define O 1)
(define {O <byte>} 1)
(define (O a b) 123)
(define ({O <byte>} a b) 123)
(define-method (O a b) 123)
(define-method ({O <byte>} a b) 123)
(case-define ciao
((a) 123))
(case-define {ciao <byte>}
((a) 123))
(define-constant ciao
123)
(define-constant {ciao <byte>}
123)
(define-inline-constant ciao
123)
(define-inline-constant {ciao <byte>}
123)
using, for example, the following components in the custom
*-font-lock-keywords:
;;This does DEFINE and DEFINE-METHOD for function bindings only.
(,(eval-when-compile
(concat "(\\s-*"
(regexp-opt '("define" "define-method") 'symbols)
"\\s-+(" ;any whitespace and open paren
"{?" ;optional open brace
"\\s-*" ;optional white space separator
"\\(" my-scheme-identifier-internal-rex "\\)"))
(1 font-lock-keyword-face)
(2 font-lock-function-name-face nil t))
;;This does DEFINE and DEFINE-CONSTANT for variable bindings only.
(,(eval-when-compile
(concat "(\\s-*"
(regexp-opt '("define" "define-constant"
"define-inline-constant")
'symbols)
"\\s-+" ;any whitespace
"{?" ;optional open brace
"\\s-*" ;optional white space separator
"\\(" my-scheme-identifier-internal-rex "\\)"))
(1 font-lock-keyword-face)
(2 font-lock-variable-name-face nil t))
but I dunno how to go to colorise the following syntaxes:
(define-values (a b c)
(values 1 2 3))
(define-values ({a <byte>} {b <byte>} {c <byte>})
(values 1 2 3))
where:
* DEFINE-VALUES should be "font-lock-keyword-face".
* "a", "b" and "c" should be "font-lock-variable-name-face"; there can
be any number of these identifiers.
* The type tags "<byte>" should be "font-lock-type-face".
To colorise the type tags I have the following font-lock-keywords
component:
(,(eval-when-compile
(concat "\\<\\("
"\\(?:" my-scheme-identifier-internal-rex "\\.\\)?"
"<" my-scheme-identifier-internal-rex ">"
"\\)\\>"))
1 font-lock-type-face)
which does both tags like "<fixnum>" and like "prefix.<fixnum>"; there
should be no need to do anything more.
How do I handle repeated patterns?
TIA
--
"Now feel the funk blast!"
Rage Against the Machine - "Calm like a bomb"
"Now feel the funk blast!"
Rage Against the Machine - "Calm like a bomb"