Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1646 connectés 

  FORUM HardWare.fr
  Programmation

  IDE, coloration syntaxique et principe de programmation..

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

IDE, coloration syntaxique et principe de programmation..

n°191786
farib
Posté le 07-08-2002 à 22:41:40  profilanswer
 

vala pour "m'amuser" :D je souhaite me faire un micro- ide en c++  (mais micro)
 
 
 
je me pose des questions au niveau des principes de programmation( pas les algos) de la coloration syntaxique
 
 
1- je me fais un tableau des lignes de ma feuille de code  ( un tableau de strings-lignes )
sur lequel je travaille ?
 
 [dans le cas de c++builder je fais un TRichEdit, je travaille directement dessus  ?]
 
2- j'appelle ma "fonction de coloration" a chaque nouveau caractere appuyé ?
 
vala, je demande pas des algos, c a moi de les faire, mais juste les grandes lignes du principe

mood
Publicité
Posté le 07-08-2002 à 22:41:40  profilanswer
 

n°191799
benou
Posté le 07-08-2002 à 23:06:31  profilanswer
 

ben ca dépend bcp du niveau de coloration que tu veux : si tu veux juste une coloration des mots clef, des chaines et des commentaires c'est facile. par contre si tu veux un truc méga puissant (genre emacs :D ) qui gère la syntaxe du langage, là c'est chaud !

n°191800
farib
Posté le 07-08-2002 à 23:16:02  profilanswer
 

j'ai pas dit une coloration qui gere la syntaxe du langage !
 
sinon ce serait plus une coloration
 
 
(en + je fait un stage dans la coloration chez l'oreal, alors je sais de quoi je parle :lol: :lol:)

n°191803
benou
Posté le 07-08-2002 à 23:21:30  profilanswer
 

farib a écrit a écrit :

j'ai pas dit une coloration qui gere la syntaxe du langage !
 
sinon ce serait plus une coloration




:??:
 
quand je dis "qui gere la syntaxe du langage" je veux dire, qui est capacble de colorer différemment les noms de méthodes, les variables, etc ...

n°191805
farib
Posté le 07-08-2002 à 23:32:22  profilanswer
 

bah moi j'ai jamais utilisé emacs, et je connais que le gras des mots clefs, les commentaires, et les strings....
 
 

n°191808
schnapsman​n
Zaford Beeblefect
Posté le 07-08-2002 à 23:38:16  profilanswer
 

Code :
  1. ;;; Keyword regexp fontification functions.
  2. (defsubst font-lock-apply-highlight (highlight)
  3.   "Apply HIGHLIGHT following a match.
  4. HIGHLIGHT should be of the form MATCH-HIGHLIGHT, see `font-lock-keywords'."
  5.   (let* ((match (nth 0 highlight))
  6.  (start (match-beginning match)) (end (match-end match))
  7.  (override (nth 2 highlight)))
  8.     (cond ((not start)
  9.    ;; No match but we might not signal an error.
  10.    (or (nth 3 highlight)
  11.        (error "No match %d in highlight %S" match highlight)))
  12.   ((not override)
  13.    ;; Cannot override existing fontification.
  14.    (or (text-property-not-all start end 'face nil)
  15.        (put-text-property start end 'face (eval (nth 1 highlight)))))
  16.   ((eq override t)
  17.    ;; Override existing fontification.
  18.    (put-text-property start end 'face (eval (nth 1 highlight))))
  19.   ((eq override 'prepend)
  20.    ;; Prepend to existing fontification.
  21.    (font-lock-prepend-text-property start end 'face (eval (nth 1 highlight))))
  22.   ((eq override 'append)
  23.    ;; Append to existing fontification.
  24.    (font-lock-append-text-property start end 'face (eval (nth 1 highlight))))
  25.   ((eq override 'keep)
  26.    ;; Keep existing fontification.
  27.    (font-lock-fillin-text-property start end 'face (eval (nth 1 highlight)))))))
  28. (defsubst font-lock-fontify-anchored-keywords (keywords limit)
  29.   "Fontify according to KEYWORDS until LIMIT.
  30. KEYWORDS should be of the form MATCH-ANCHORED, see `font-lock-keywords',
  31. LIMIT can be modified by the value of its PRE-MATCH-FORM."
  32.   (let ((matcher (nth 0 keywords)) (lowdarks (nthcdr 3 keywords)) highlights
  33. (lead-start (match-beginning 0))
  34. ;; Evaluate PRE-MATCH-FORM.
  35. (pre-match-value (eval (nth 1 keywords))))
  36.     ;; Set LIMIT to value of PRE-MATCH-FORM or the end of line.
  37.     (if (not (and (numberp pre-match-value) (> pre-match-value (point))))
  38. (setq limit (line-end-position))
  39.       (setq limit pre-match-value)
  40.       (when (and font-lock-multiline (>= limit (line-beginning-position 2)))
  41. ;; this is a multiline anchored match
  42. ;; (setq font-lock-multiline t)
  43. (put-text-property (if (= limit (line-beginning-position 2))
  44.          (1- limit)
  45.        (min lead-start (point)))
  46.      limit
  47.      'font-lock-multiline t)))
  48.     (save-match-data
  49.       ;; Find an occurrence of `matcher' before `limit'.
  50.       (while (and (< (point) limit)
  51.    (if (stringp matcher)
  52.        (re-search-forward matcher limit t)
  53.      (funcall matcher limit)))
  54. ;; Apply each highlight to this instance of `matcher'.
  55. (setq highlights lowdarks)
  56. (while highlights
  57.   (font-lock-apply-highlight (car highlights))
  58.   (setq highlights (cdr highlights)))))
  59.     ;; Evaluate POST-MATCH-FORM.
  60.     (eval (nth 2 keywords))))
  61. (defun font-lock-fontify-keywords-region (start end &optional loudly)
  62.   "Fontify according to `font-lock-keywords' between START and END.
  63. START should be at the beginning of a line."
  64.   (unless (eq (car font-lock-keywords) t)
  65.     (setq font-lock-keywords (font-lock-compile-keywords font-lock-keywords)))
  66.   (let ((case-fold-search font-lock-keywords-case-fold-search)
  67. (keywords (cdr font-lock-keywords))
  68. (bufname (buffer-name)) (count 0)
  69. keyword matcher highlights)
  70.     ;;
  71.     ;; Fontify each item in `font-lock-keywords' from `start' to `end'.
  72.     (while keywords
  73.       (if loudly (message "Fontifying %s... (regexps..%s)" bufname
  74.     (make-string (incf count) ?.)))
  75.       ;;
  76.       ;; Find an occurrence of `matcher' from `start' to `end'.
  77.       (setq keyword (car keywords) matcher (car keyword))
  78.       (goto-char start)
  79.       (while (and (< (point) end)
  80.    (if (stringp matcher)
  81.        (re-search-forward matcher end t)
  82.      (funcall matcher end)))
  83. (when (and font-lock-multiline
  84.     (>= (point)
  85.         (save-excursion (goto-char (match-beginning 0))
  86.           (forward-line 1) (point))))
  87.   ;; this is a multiline regexp match
  88.   ;; (setq font-lock-multiline t)
  89.   (put-text-property (if (= (point)
  90.        (save-excursion
  91.          (goto-char (match-beginning 0))
  92.          (forward-line 1) (point)))
  93.     (1- (point))
  94.          (match-beginning 0))
  95.        (point)
  96.        'font-lock-multiline t))
  97. ;; Apply each highlight to this instance of `matcher', which may be
  98. ;; specific highlights or more keywords anchored to `matcher'.
  99. (setq highlights (cdr keyword))
  100. (while highlights
  101.   (if (numberp (car (car highlights)))
  102.       (font-lock-apply-highlight (car highlights))
  103.     (font-lock-fontify-anchored-keywords (car highlights) end))
  104.   (setq highlights (cdr highlights))))
  105.       (setq keywords (cdr keywords)))))
  106. ;;; End of Keyword regexp fontification functions.


 
ca ressemble à ça le code de font-lock.el de emacs, si le coeur t'en dis :lol:


---------------
From now on, you will speak only when spoken to, and the first and last words out of your filthy sewers will be "Sir!"
n°191811
farib
Posté le 07-08-2002 à 23:41:59  profilanswer
 

blague a part... z'avez pas des pties réponses pour mes deux questions ?

n°191813
benou
Posté le 07-08-2002 à 23:48:14  profilanswer
 

farib a écrit a écrit :

bah moi j'ai jamais utilisé emacs, et je connais que le gras des mots clefs, les commentaires, et les strings....




pauvre de toi ... ;)
 
allez, je te file un exemple : de ce que ca peut donner :  
http://perso.wanadoo.fr/vieuxbenou/divers/emacs_cc.jpg

n°191815
farib
Posté le 07-08-2002 à 23:51:41  profilanswer
 

farib a écrit a écrit :

blague a part... z'avez pas des pties réponses pour mes deux questions ?




eh, ca vous intéresse des fois :D  
 
(ps : je vois pas ce ke le vert et le caca d'oie apportent au niveau lisibilité...)

n°191816
benou
Posté le 07-08-2002 à 23:53:46  profilanswer
 

farib a écrit a écrit :

 
eh, ca vous intéresse des fois :D  
 
(ps : je vois pas ce ke le vert et le caca d'oie apportent au niveau lisibilité...)




pfff les couleurs ca se configure. elle est vraiment conne ta remarque ...  
 
L'intérêt me paraît pourtant évident : tu vois immédiatement les déclarations de variables, de méthodes, les types, etc ...

mood
Publicité
Posté le 07-08-2002 à 23:53:46  profilanswer
 

n°191827
farib
Posté le 08-08-2002 à 00:11:02  profilanswer
 

farib a écrit a écrit :

blague a part... z'avez pas des pties réponses pour mes deux questions ?




 
et ca :cry: :cry: :cry:

n°191910
redant
Posté le 08-08-2002 à 10:25:04  profilanswer
 

Pour faire un truc de ce genre qui tienne la route, personnelement j'utiliserais Lex&Yacc (sutout Lex en fait)
 
Lex permet de créer facilement un programme d'analyse syntaxique en donnant des mots clef et une syntaxe

n°191913
farib
Posté le 08-08-2002 à 10:30:41  profilanswer
 

oui, masi moi je veux fair eun truc simple, et en c++ :d
 
mots clef en gras, strings, commentaires....

n°191939
benou
Posté le 08-08-2002 à 11:20:44  profilanswer
 

bon ben c'est tout con à faire. C'est quoi ta question exactement ?


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

  IDE, coloration syntaxique et principe de programmation..

 

Sujets relatifs
[HTML] Cohabitation HTML-PHP et Design-ProgrammationProgrammation et base de données... Juste une question
programmation acrobat 4.0[help please] base programmation et javascript???
[PHP] Principe des sites de newsprogrammation OS9 (processeur motorola)
programmation SDL[php] methode de programmation d un site web
Je voudrais m'initier à la programmation, je commence par koi??depuis combien de temps faites vous de la programmation?
Plus de sujets relatifs à : IDE, coloration syntaxique et principe de programmation..


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR