"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/langDefs/ebnf2.lang" (12 May 2020, 6064 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "ebnf2.lang": 3.53_vs_3.54.

    1 --[[****************************************************************************
    2 *                                                                              *
    3 *                            EBNF2 Syntax Definition                           *
    4 *                                                                              *
    5 *                v1.0.1 (2018/01/18) | Highlight v3.41 | Lua 5.3               *
    6 *                                                                              *
    7 *                               by Tristano Ajmone                             *
    8 *                                                                              *
    9 ********************************************************************************
   10 Associated file extensions: none
   11 Syntax type: EBNF (Extended Backus–Naur form)
   12 --------------------------------------------------------------------------------
   13 I've created this EBNF syntax definition because I needed to syntax highlight
   14 the EBNF code of Polygen Manual, which wasn't being handled properly by the
   15 existing Highlight *BNF definitions ("ebnf", "abnf", and "bnf"). So I decided
   16 to create my own EBNF syntax by adapting the Polygen Grammars syntax I had
   17 just recently created. Some tweaks were required to make it parse properly
   18 the EBNF code found in the Polygen Manual (see changelog, at the end).
   19 
   20 Hopefully others might benefit from this new EBNF syntax too. Since there is
   21 no universal standard for EBNF notation (EBNF being a family of notations),
   22 this definition might be used as a starting point to tailor an ad hoc EBNF
   23 syntax matching your needs.
   24 --------------------------------------------------------------------------------
   25 Written by Tristano Ajmone:
   26     <tajmone@gmail.com>
   27     https://github.com/tajmone
   28 Released into the public domain according to the Unlicense terms:
   29     http://unlicense.org/
   30 --------------------------------------------------------------------------------
   31 --]]
   32 Description="EBNF2"
   33 
   34 Categories = {"protocol"}
   35 
   36 IgnoreCase=false
   37 EnableIndentation=false
   38 --------------------------------------------------------------------------------
   39 -- DISABLE/OVERRIDE UNUSED SYNTAX ELEMENTS
   40 --------------------------------------------------------------------------------
   41 NEVER_MATCH_RE=[=[ \A(?!x)x ]=] -- A Never-Matching RegEx!
   42 
   43 Digits=NEVER_MATCH_RE -- Numbers are just text in EBNF!
   44 
   45 Identifiers=NEVER_MATCH_RE -- Highlight's default Identifiers RegEx prevents
   46 -- capturing the Epsilon operator ('_'). Since in this syntax, all identifiers
   47 -- are defined as RegEx Keywords, and because we don't use any Keywords lists,
   48 -- we may as well disable Identifiers by defining them as a never-matching RegEx.
   49 -- NOTE: Defining Identifiers as a never-matching RegEx prevents using Kewyords
   50 --       lists (the parser will fail to capture them).
   51 
   52 -- =============================================================================
   53 --                                   COMMENTS
   54 -- =============================================================================
   55 -- OCaml style comments, no nesting: (* ...COMMENT BLOCK... *)
   56 Comments={
   57   { Block=true,
   58     Nested=false,
   59     Delimiter = {
   60       [=[ \(\* ]=], -- Comment start: '(*'
   61       [=[ \*\) ]=]  -- Comment end:   '*)'
   62     }
   63   },
   64 }
   65 -- =============================================================================
   66 --                                   STRINGS
   67 -- =============================================================================
   68 Strings={
   69   ------------------------------------------------------------------------------
   70   --                            STRING DELIMITERS
   71   ------------------------------------------------------------------------------
   72   -- Only double quotes as string delimiter: "...STRING..."
   73   Delimiter=[=[ " ]=],
   74 --[[----------------------------------------------------------------------------
   75                                 ESCAPE SEQUENCES
   76     ----------------------------------------------------------------------------
   77     Suppress Escape sequences via Never-Matching RegEx                      --]]
   78   Escape=NEVER_MATCH_RE
   79 }
   80 --[[============================================================================
   81                                     OPERATORS
   82     ============================================================================
   83     ::=   :=    :   ;   ^   .   ,   _   |   +   -   *   >   <   \
   84     >>  <<  (   )   [   ]   {   }
   85 
   86 --]]
   87 Operators=[=[ :|=|\^|\.|\*|\+|-|>|<|\(|\)|\[|]|\{|}|\||,|;|_|\\ ]=]
   88 -- =============================================================================
   89 --                                   KEYWORDS
   90 -- =============================================================================
   91 Keywords={
   92   ------------------------------------------------------------------------------
   93   --                           Non-Terminal Symbol
   94   ------------------------------------------------------------------------------
   95   -- Must beging with a capital letter; must not be preceded or followed by a "-"
   96   -- (to prevent capturing RegEx ranges like "A-Z" )
   97   { Id=1,
   98     Regex=[=[ (?<!-)([A-Z][A-Za-z0-9]*)\b(?!-) ]=],
   99     Group=1
  100   },
  101 }
  102 --[[============================================================================
  103                                       CHANGELOG
  104 ================================================================================
  105 v1.0.1 (2018/01/18) | Highlight v3.41)
  106   - Changed "PolyGen" to "Polygen" (the author has now officially adopted the
  107     latter syntax).
  108 v1.0.0 (2018/01/14) | Highlight v3.41)
  109   - First release. Created by modifying "polygen.lang" (v1.0.0):
  110     - Suppressed Escape Sequences (via Never-Matching RegEx)
  111     - Deleted custom OnStateChange() hook function to handle Escape Sequences.
  112     - Operators: added "*", and tweaked RegEx.
  113     - Keywords:
  114       - Removed Keywords Group 2 ("Label Identifier")
  115       - Removed Keywords Group 3 ( "Label Selector")
  116       - Keywords Group 1 ("Non-Terminal Symbol"): tweaked RegEx to ensure that
  117         keyword is not preceded or followed by "-", to avoid capturing RegEx
  118         ranges like "A-Z" in EBNF source.
  119 --]]