MySample

MySample is my version of the sample application that came with the Crystal Edit edit control. (It is the (stand-alone) editor that I use most. It is one of the main tools to maintain my web site, of which this page belongs.) Most of my efforts went into reimplementing the colour coding making use of the Plug-in Pattern. This also allows the implementation of real syntax colouring, not simple lexical colouring as most other editors do.

Other improvements are:

Script language

The grammar for the build-in script (in the notation used by IParse) language is:

primary_expr
    : ident
    | int
    | double
    | char
    | string
    | "(" expr ")"
    .

postfix_expr
    : postfix_expr "[" expr LIST "]"
    | postfix_expr "(" assignment_expr LIST OPT ")"
    | postfix_expr "." ident "(" assignment_expr LIST OPT ")"
    | postfix_expr "." ident
    | postfix_expr "++"
    | postfix_expr "--"
    | primary_expr
    .

unary_expr
    : "++" unary_expr
    | "--" unary_expr
    | "+" unary_expr
    | "-" unary_expr
    | "!" unary_expr
    | postfix_expr
    .

l_expr1
    : l_expr1 "*" unary_expr
    | l_expr1 "/" unary_expr
    | l_expr1 "%" unary_expr
    | unary_expr
    .
l_expr2
    : l_expr2 "+" l_expr1
    | l_expr2 "-" l_expr1
    | l_expr1
    .
l_expr3
    : l_expr3 "<<" l_expr2
    | l_expr3 ">>" l_expr2
    | l_expr2
    .
l_expr4
    : l_expr4 "<=" l_expr3
    | l_expr4 ">=" l_expr3
    | l_expr4 "<"  l_expr3
    | l_expr4 ">"  l_expr3
    | l_expr4 "==" l_expr3
    | l_expr4 "!=" l_expr3
    | l_expr3
    .
l_expr5 : l_expr5 "&&" l_expr4 | l_expr4 .
l_expr6 : l_expr6 "||" l_expr5 | l_expr5 .

expr
    : l_expr6 "?" l_expr6 ":" expr
    | l_expr6
    .

assignment_expr
    : unary_expr assignment_operator assignment_expr
    | expr
    .

assignment_operator
    : "="
    | "*="
    | "/="
    | "%="
    | "+="
    | "-="
    | "<<="
    | ">>="
    .

declaration
    : type_specifier ident "[" expr LIST "]" ";"
    | type_specifier ident ("=" expr) OPT ";"
    .

type_specifier
    : "bool"
    | "int"
    | "double"
    | "string"
    | "textbuffer"
    | "image"
    | "color"
    | "point"
    .


statement
    : declaration
    | "{" statement SEQ OPT "}"
    | assignment_expr OPT ";"
    | "if" "(" expr ")" statement  ("else" statement) OPT
    | "while" "(" expr ")" statement
    | "for" ident "from" expr "to" expr statement
    .

root : statement SEQ OPT .

Sources

The following ZIP files contains all the sources sorted by release date. I am not making any promisses with respect to program crashes.

Known bugs


My life as a hacker | Software Engineering | home