Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi all,

I'm working a bit with Parse::RecDescent and I'd like to share this (minimal) vim syntax file for Parse::RecDescent grammars. I have very little experience with vim "programming", so any comment and improvement would be great before trying to propose it either to the vim website or to TheDamian.

I saved this as ~/.vimrc/syntax/parse_recdescent.vim:

" Vim syntax file " Language: Parse::RecDescent (Perl module) " Maintainer: Flavio Poletti <flavio [you know what] polettix.it> " Last Change: 2007 October 30 " Location: none at the moment :) " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 syntax clear elseif exists("b:current_syntax") finish endif syn match prdDefinedAs /:/ syn region prdComment start=/#/ end=/$/ syn region prdDoubleString start=/"/ skip=/\\[\\"]/ end=/"/ syn region prdSingleString start=/'/ skip=/\\'/ end=/'/ syn match prdIdentifier /[a-zA-Z_][a-zA-Z0-9_]*/ syn region prdRegex start="m\?/"hs=e+1 skip="\\/" end="/[gmsxi]\?"he=s +-1 syn include @Perl syntax/perl.vim syn region prdCodeBlock start=/{/ end=/}/ contains=prdCodeBlock,@Perl " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighti +ng yet if version >= 508 || !exists("did_yacc_syn_inits") if version < 508 let did_yacchdl_syn_inits = 1 command -nargs=+ HiLink hi link <args> else command -nargs=+ HiLink hi def link <args> endif HiLink prdDefinedAs Operator HiLink prdComment Comment HiLink prdDoubleString String HiLink prdSingleString String HiLink prdIdentifier Keyword HiLink prdRegex String delcommand HiLink endif let b:current_syntax = "parse_recdescent"
Making the syntax file autoload on startup is somewhat beyond my vim-fu. I personally use .prd extension for these grammars, and I've added this line:
au BufRead,BufNewFile *.prd set filetype=parse_recdescent
in my ~.vimrc personalisation file.

Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Io ho capito... ma tu che hai detto?

In reply to RFC [OT?]: vim syntax file for Parse::RecDescent by polettix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found