Syntax Highlighting Pattern for Pascal ______________________________________ About this file --------------- This is the "blue-print" file for pascal.pats, an improved syntax highlighting pattern for Pascal. The use of this "blue-print" file is to complement the pattern file to indicate what to do and how to do. This file contains also important infos which are no longer available to users once the pattern is incorporated into NEdit. It also makes it easier for someone else to understand and maintain pattern not created by himself. Please read this file first before reporting bugs. After loading the pattern file into NEDit, choose Pascal as language for this file to see how syntaxes are highlighted. In this way, you could choose the Drawing Style that you like. General Overview ---------------- The pattern gets rid of C style patterns as provided in the official pattern in NEdit 5.0.2. Patterns are rigorously made according to references below: Standard Pascal: ISO/IEC 7185:1990(E) Extended Pascal: ISO/IEC 10206:1990(E) No pattern is made for Object-Oriented. Some Turbo Pascal syntaxes (based on TP 5.5) are included for convenience to some users. NOTE: the pattern is written to work with regex engine/syntax in 5.1 and later. Don't try to use with 5.0.2 or earlier versions. It won't work. There're so many patterns that the use of Drawing Style for some of them doesn't correspond to their meanings. Change the Drawing style if you want to change the colour or change it to Plain if you don't need such and such pattern to be highlighted. If the pattern is composed of purely keywords (KW), you could even delete the pattern. How to load the pattern ----------------------- Load this pattern by starting NEdit with: nedit -import pascal.pats Then, check that the patterns were loaded correctly, and choose Save Defaults from the Preferences menu. The new patterns will now be incorporated into NEdit's config file, so the next time you start NEdit, you will no longer need to use -import again. Pattern technical details ------------------------- The real pattern order inside "Syntax Highlighting Pattern" window is different from what is written here, otherwise it would have required to write more complicated patterns and thus reduced efficiency while rendering highlighting. Pascal is a case-insensitive language. Below, X stands for Extended, not X-window :-) In other words, things related to Extended Pascal like "Complex" as an extended data type. However, predefined field identifier like "date", "time", etc are not highlighted. TP stands for Turbo Pascal, obviously. It is not intended to include TP Predefined Constants, TP Predefined Procedures and TP Predefined Functions because there are too many keywords (more than 50). Including all these in the pattern would just slow down NEdit's response time. Create them yourself if you need them. _______________________________________________________________________________ Comment: These are valid comments delimitors and styles: (* Comment A *) { Comment B } (* Comment C } { Comment D *) A comment is defined from the starting delimitor up to the ending delimitor. Therefore, a comment can span several line. But nested comments are not allowed. TP Directives: It is in the form of {$X...} where X is a specific letter like I, N, R, etc defined by TP. However, the pattern doesn't check if the letter is valid. The default highlight style is "Comment". Change this if you want to highlight the directives differently. String: Each string is delimited by apostrophe (single quote) and it is not allowed span more than one line . 'string' and 'I can''t' (when an apostrophe is needed) are valid examples. 'This string is not allowed.' Parentheses: Obviously, ( and ) are highlighted. Array delimitors: [ and ] and the respective alternative aliases: (. and .) Numeric Values: integers: 83, 00004 reals: 1.0, 1e-12, 5.8E6, 0.000000001 At least one digit must exist on either side of the decimal point. Invalid reals: 20.e12 .305 X Numeric Values: To represent non-decimal numbers in the form of x#y where x is the radix which can take any value from 2 to 36 y is the value which can be composed of numbers and letters eg: 2#1001010 in binary 3#102210 in ternary 8#271 in octal 10#1234 in decimal 16#2a9f in hexadecimal 36#4T7H (don't know how to call this :p ) The pattern doesn't check the validity for all representations but it provides a minimal check on the radix, ie 2#1583 or 16#AZ58 are still highlighted even though the numeric part after the # symbol is wrong (because this part does not correspond to the radix). But 37#1234 isn't highlighted because 37 isn't an allowed radix. TP Numeric Values: Ordinal values for any ordinal type: - Decimal: #1298 - Hexadecimal: $4AF4 Reserved Words 1 & 2 (KW): Begin, Const, End, Program, Record, Type, Var Forward, Goto, Label, Of, Packed, With X Reserved words (KW): Bindable, Export, Implementation, Import, Interface, Module, Only, Otherwise, Protected, Qualified, Restricted, Value TP Reserved Words (KW): Absolute, Assembler, Exit, External, Far, Inline, Interrupt, Near, Private, Unit, Uses Data Types (KW): Array, Boolean, Char, File, Integer, Real, Set, Text X Data Types (KW): BindingType, Complex, String, TimeStamp TP Data Types (KW): Byte, Comp, Double, Extended, LongInt, ShortInt, Single, Word Predefined Constants (KW): False, Input, MaxInt, Nil, Output, True X Predefined Constants (KW): EpsReal, MaxChar, MaxReal, MinReal, StandardInput, StandardOutput Conditionals (KW): Case, Do, DownTo, Else, For, If, Repeat, Then, To, Until, While Procedure declaration (KW): Procedure Predefined Procedures (KW): Dispose, Get, New, Pack, Page, Put, Read, ReadLn, Reset, Rewrite, Unpack, Write, WriteLn X Predefined Procedures (KW): Bind, Extend, GetTimeStamp, Halt, ReadStr, SeekRead, SeekUpdate, SeekWrite, Unbind, Update, WriteStr Function declaration (KW): Function Predefined Functions (KW): Abs, Arctan, Chr, Cos, Eof, Eoln, Exp, Ln, Odd, Ord, Pred, Round, Sin, Sqr, Sqrt, Succ, Trunc X Predefined Functions (KW): Arg, Binding, Card, Cmplx, Date, Empty, Eq, Ge, Gt, Im, Index, LastPosition, Le, Length, Lt, Ne, Polar, Position, Re, SubStr, Time, Trim Assignment symbol: := This is not highlighted intentionally to make it clear that it must not be confused with =. Operators (KW): <, >, =, <>, <=, >=, ^, @, And, Div, In, Mod, Not, Or This includes relational operators, logical operators and mathematical operators other than +, -, *, /. X Operators (KW): ><, **, And_Then, Or_Else, Pow TP Operators (KW): Shl, Shr, Xor _______________________________________________________________________________ 1999-12-30 "Seak, Teng-Fong"