feat: add missing KF6 framework recipes

This commit is contained in:
2026-05-07 07:53:26 +01:00
parent d8d498f831
commit a69f479b52
2374 changed files with 2610246 additions and 0 deletions
@@ -0,0 +1,2 @@
DisableFormat: true
SortIncludes: false
@@ -0,0 +1,8 @@
# exclude everything except directory foo/bar in subdir foobar
/foobar/*
!/foobar/foo
/foobar/foo/*
!/foobar/foo/bar
/**/a?[a-z12!][]][!][:upper:]][^[=a=]]\?[\\incomplete?*
!/**/a?[a-z][]][!][:upper:]][^[=a=]]\?[\\incomplete?*
@@ -0,0 +1,74 @@
# List of all options: https://docs.kde.org/trunk5/en/kdesrc-build/kdesrc-build/conf-options-table.html
global
branch-group kf6-qt6
# strange capitalisation of value
include-dependencies TrUe
# path with tilde
kdedir ~/kde/usr
# try using the existing option as value for other option
qtdir ${source-dir} # Comment on the same line with value
# Use line breaks
cmake-options -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DQT_MAJOR_VERSION=6 \
-DBUILD_WITH_QT6=ON
num-cores ${non-existing-var}
num-cores-low-mem 4
non-existing-option 12345
# use int value for binary option
install-session-driver 5
# impossible enum value (allowed are: invent, flat, metadata)
directory-layout project-ids-as-folder-names
# option with valid value with spaces
cmake-generator Kate - Ninja
end global
# Comment with \
# line break
include ~/kde6/src/kdesrc-build/kf6-common-options-build-include
options kcalc
# use of module-set only option in the options block:
use-modules one two \
three
# use of unrecognized option:
new-option true
end options
module-set
# use of global-only option in module-set:
stop-on-failure true
# use allowed option:
use-modules one two three
end module-set
# module block without the actual name
module
repository kde-projects
end module
# double opening module block (forget ending the module block):
module kcalc
module kcalc
# body without options
end module kcalc
# non-recognized block
kcalc
repository kde-projects
end kcalc
# kate: syntax kdesrc-buildrc;
@@ -0,0 +1,19 @@
# LGPLv2+ example file
# This is a comment
FROM ubuntu:14.04
MAINTAINER James Turnbull <james@example.com> # comment
ENV REFRESHED_AT 2014-06-01
RUN apt-get -yqq update
RUN apt-get install -yqq software-properties-common python-software-properties
RUN add-apt-repository ppa:chris-lea/redis-server
RUN apt-get -yqq update
RUN apt-get -yqq install redis-server redis-tools
RUN apt-get -yqq update # comment
VOLUME [ "/var/lib/redis", "/var/log/redis/" ]
EXPOSE 6379
CMD []
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,143 @@
# kate: hl earthfile;
VERSION --shell-out-anywhere 0.6
# BEGIN Global parameters
ARG DEVTOOLSET_VERSION = 11
ARG DEVTOOLSET = devtoolset-${DEVTOOLSET_VERSION}
# END Global parameters
ARG param_1 = "String w/ variable interpolation ${DEVTOOLSET}"
ARG param_2 = 'String w/o variable interpolation ${DEVTOOLSET}'
# Run shell command
ARG param_3 = $(echo "String w/ variable interpolation ${DEVTOOLSET}")
sample-target:
FROM alpine
ARG stage
COPY --if-exists files/${stage}/ /files/
SAVE ARTIFACT --keep-ts /files /share
repos-conf-apt:
ARG image
ARG ppa
FROM ${image}
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
IF [ "${ppa}" != '' ]
ARG _more_cmds = add-apt-repository -y -n ppa:${ppa}/ppa
ELSE
ARG _more_cmds = :
END
RUN --mount type=secret,id=+secrets/repo_gpg_key,target=/run/secrets/private-archive-keyring.gpg \
--mount type=cache,target=/var/cache/apt/archives \
--mount type=cache,target=/var/lib/apt/lists \
set -x; \
debconf-set-selections /tmp/debconf-preset.txt \
&& rm -rf /etc/apt/apt.conf.d/docker-clean \
&& apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository --remove multiverse \
&& gpg -v --dearmor - </run/secrets/private-archive-keyring.gpg > /usr/share/keyrings/private-archive-keyring.gpg \
&& ${_more_cmds}
SAVE ARTIFACT /etc/apt/sources.list /sources.list
SAVE ARTIFACT /usr/share/keyrings/private-archive-keyring.gpg /private-archive-keyring.gpg
IF [ "${ppa}" != '' ]
SAVE ARTIFACT /etc/apt/sources.list.d/${ppa}*.list /sources.list.d
SAVE ARTIFACT /etc/apt/trusted.gpg.d/${ppa}*.gpg /trusted.gpg.d
END
APT_INSTALL:
FUNCTION
ARG image
ARG packages = ''
ARG packages_on_hold = ''
ARG upgrade = 0
ARG clean = 0
ARG pm_aux_options = ''
ARG more_rm_files = ''
ARG more_cmds = :
IF [ ! -f /root/debconf-preset.txt ]
COPY (+repos-conf-apt/debconf-preset.txt --image=${image}) /root/debconf-preset.txt
ARG _debconf_cmd_cond = debconf-set-selections /root/debconf-preset.txt
ELSE
ARG _debconf_cmd_cond = :
END
IF [ ! -f /usr/share/keyrings/private-archive-keyring.gpg ]
COPY (+repos-conf-apt/private-archive-keyring.gpg --image=${image}) \
/usr/share/keyrings/private-archive-keyring.gpg
# NOTE Also copy the `sources.list` file with `multiverse` disabled!
COPY (+repos-conf-apt/sources.list --image=${image}) /etc/apt
END
# ...
MAKE_PYTHON_CI_IMAGE:
FUNCTION
ARG image
ARG python = python3
ARG python_pkg = ${python}
ARG python_bin = ${python}
ARG python_ver = 3.11
DO +APT_INSTALL --packages="${python_pkg} git"
ARG _chroot_base = $(dirname $(cat /etc/debian_chroot))
DO ./share+IMAGE_INIT \
--image_description="CI image for Python projects" \
--debian_chroot=${_chroot_base}/python/${python_ver}/ci \
--storage_name=none
COPY --dir (+prep-python-ci/local --image=${image}) /usr
ENV SETUPTOOLS_USE_DISTUTILS='stdlib'
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
all:
LOCALLY
# Primary images
BUILD +ci
BUILD +clang-ci
BUILD +python-ci
IF [ "${BUILD_TESTING}" -gt 0 ]
# Also include all tests
BUILD +tests
END
tests:
LOCALLY
BUILD +ci-tests
BUILD +clang-ci-tests
BUILD +python-ci-tests
ci-tests:
FROM +ci
COPY .env /
DO share+RUN_TESTS --VERBOSE=${VERBOSE}
clang-ci-tests:
FROM +clang-ci
COPY .env /
ENV EXPECT_CLANG_VERSION=${CLANG_VERSION}
DO share+RUN_TESTS --VERBOSE=${VERBOSE} --script=ci-tests.sh
python-ci-tests:
FROM +python-ci
COPY .env /
DO share+RUN_TESTS --VERBOSE=${VERBOSE}
@@ -0,0 +1,248 @@
project
: requirements <include>/home/ghost/Work/boost <threading>multi
;
project a : : debug ;
exe hello : hello.cpp ;
exe hello
: hello.cpp
: <include>boost <threading>multi
;
exe app : app.cpp ../util/foo//bar ;
exe important : main.cpp helpers/<link>static ;
exe b : [ glob *.cpp ] ;
lib tools :
[ glob *.cpp ] ;
lib tools : [ glob *.cpp : file_to_exclude.cpp bad*.cpp ] ;
lib network : network.cpp
: <conditional>@my-rule
;
DEPENDS foo.o : foo.c ;
using msvc : : "Z:/Programs/Microsoft Visual Studio/vc98/bin/cl" ;
using msvc : : echo Compiling && foo/bar/baz/cl ;
using gcc : 5 : : <cxxflags>"-std=c++14 -O2" ;
using clang : 3.9 : : <cxxflags>-std=c++14 <cxxflags>-O2 ;
exe test3 : test3.cpp : -<threading>multi ;
XYZ += <cxxflags>-Wzero-as-null-pointer-constant&&-Wno-zero-as-null-pointer-constant ;
exe hello : hello.cpp : <os>NT,<toolset>gcc:<link>static ;
install dist : hello helpers :
<variant>release:<location>dist/release
<variant>debug:<location>dist/debug ;
install dist2 : hello helpers : <location>$(DIST) ;
exe app : app.cpp : [ check-target-builds has_foo "System has foo" : <library>foo : <define>FOO_MISSING=1 ] ;
import path : * ;
using python
: 2.7 # version
: # Interpreter/path to dir
: /usr/include/python2.7 # includes
: /usr/lib/x86_64-linux-gnu # libs
: # conditions
;
xx ;
xx ;; ;
xx ;a ;
xx a; ;
xx ;a; ;
## comment title
# BUG
# TODO
# aTODOa
#| multi
line
comment
TODO
bla bla
|#
if cond {
statements ;
}
else {
statements ;
}
for var in list {
statements ;
}
while cond {
statements ;
}
switch value
{
case pattern1 : statements ;
case pattern2 : statements ;
other ;
}
if xxinxx {
}
ifxxx s ;
rule a? ( x )
{
echo $(x) ;
}
a? 23 ;
local rule test ( a )
{
}
rule example
(
parameter1 :
parameter2 ? :
parameter3 + :
parameter4 *
)
{
if <variant>debug in $(properties)
{
OPTIONS on $(targets) = --debug ;
}
}
rule my-rule ( properties * )
{
local result ;
if <toolset>gcc <optimization>speed in $(properties)
{
result += <define>USE_INLINE_ASSEMBLER ;
return $(result) ;
}
local m = [ CALLER_MODULE ] ;
local result ;
for v in $(values)
{
if [ modules.call-in $(m) : $(f) $(v) ]
{
result += $(v) ;
}
}
return result ;
return <name>$(name) ;
return [ virtual-target.register $(t) ] ;
return [ sequence.transform virtual-target.register : $(targets) ] ;
}
rule run ( project name ? : property-set : sources * )
{
if [ $(s).type ] = PY
{
python = $(s) ;
}
local new-sources ;
for local s in $(sources)
{
if [ type.is-derived [ $(s).type ] CPP ]
{
local name = [ $(s).name ] ; # get the target's basename
if $(name) = [ $(python).name ]
{
name = $(name)_ext ; # rename the target
}
new-sources += [ generators.construct $(project) $(name) :
PYTHON_EXTENSION : $(property-set) : $(s) $(libs) ] ;
}
}
result = [ construct-result $(python) $(new-sources) : $(project) $(name)
: $(property-set) ] ;
}
rule link
{
DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ;
}
actions link bind DEF_FILE
{
$(.LD) .... /DEF:$(DEF_FILE) ....
}
actions create-file-from-another
{
create-file-from-another $(OPTIONS) $(<) $(>)
}
mypackage =
[ pkg-config.import mypackage : usage-requirements <conditional>@define_ns
] ;
me = [ modules.binding $(__name__) ] ;
local ZLIB_INCLUDE = [ modules.peek : ZLIB_INCLUDE ] ;
local t = [ new file-target $(name) : CPP : $(project) : $(a) ] ;
$(var) field1 : field2 : ... : fieldN ;
$(var)o aaaa ;
on target $(var) field1 : field2 : ... : fieldN ;
[ $(var) field1 : field2 : ... : fieldN ]
[ on target $(var) field1 : field2 : ... : fieldN ]
local key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths" ;
local values = [ W32_GETREGNAMES "$(key)\\$(subkey)" : values ] ;
variable = $(b) $(c) ;
variable += elements ;
variable on targets = elements ;
variable on targets += "elements" ;
variable default = elements ;
variable ?= elements ;
defs += <define>NAME='\"$(VALUE)\"' ;
x = $($(Z)) ;
x = $(Z)x ;
x = x$(Z) ;
x = x$(Z)x ;
x = "C:\\Program Files\\Borland" ; ECHO $(x:T) ;
module my_module # my module
{
rule salute ( x ) { ECHO $(x), world ; }
rule greet ( ) { salute hello ; }
greet ; # ok
}
class verbatim-scanner : common-scanner
{
rule pattern ( )
{
return "//###include[ ]*\"([^\"]*)\"" ;
}
greet ; # error
}
# test crazy (and valid) name
a<b> a<b> [ a<b> a<b> a] ] ;
rule a<b>() () { }
actions a<b> { }
local a<x> ;
local a<x> = a<b> ;
@@ -0,0 +1,356 @@
This is wrong but should not crash ] ) } !
# comment
config BR2_PACKAGE_GAMMARAY
bool "gammaray"
depends on BR2_PACKAGE_QT5
help
GammaRay Qt introspection probe.
second line of help, with correct indentation
GammaRay Qt introspection probe.
second line of help, with correct indentation
third line underindented and thus wrong
default 'true'
config W1_MASTER_GPIO_CUSTOM
tristate "Custom GPIO-based W1 driver"
depends on GENERIC_GPIO
select W1_GPIOconfig AG71XX
tristate "Atheros AR7XXX/AR9XXX built-in ethernet mac support"
depends on ATH79
imply HAS_TXX9_SERIAL
def_bool LD_VERSION >= 225000000 || LD_IS_LLD
select PHYLIB
---help---
If you wish to compile a kernel for AR7XXX/91XXX and enable
ethernet support, then you should always answer Y to this.
comment "module support disabled"
depends on !MODULES
menu myMenu
depends on NET
config NETDEVICES
bool "Atheros AR71xx built-in ethernet driver debugging"
def_bool ds
default n
help
Atheros AR71xx built-in ethernet driver debugging messages.
endmenu
if TARGET_OX820
config SYS_CPU
default "arm1136"
endif
if AG71XX
config AG71XX_DEBUG
bool "Atheros AR71xx built-in ethernet driver debugging"
default n
help
Atheros AR71xx built-in ethernet driver debugging messages.
endif
# comment
menu "System setup"
choice
prompt "Alpha system type"
default ALPHA_GENERIC
string "bad"
---help---
This is the system type of your hardware.
config HZ_32
bool "32 Hz"
config HZ_64
bool "64 Hz"
config ALPHA_GENERIC
bool "Generic"
depends on TTY
select HAVE_EISA
select GENERIC_BUG_RELATIVE_POINTERS if X86_64
bool "64-bit kernel" if "$(SUBARCH)" = "x86"
bool "Support the legacy \"mmu-masters\" devicetree bindings"
depends on ARM_SMMU=y && OF
help
A generic kernel will run on all supported Alpha hardware.
endchoice
config VGA_HOSE
bool
def_bool y
depends on VGA_CONSOLE && (ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI)
default y
default n
default 3
bool "Use WTINT" if ALPHA_SRM || ALPHA_GENERIC
default y if ALPHA_QEMU
default n if ALPHA_EV5 || ALPHA_EV56 || (ALPHA_EV4 && !ALPHA_LCA)
default n if !ALPHA_SRM && !ALPHA_GENERIC
default y if SMP
default "y" if PPC_POWERNV
range 2 32
depends on SMP
default "32" if ALPHA_GENERIC || ALPHA_MARVEL
default '4' if !ALPHA_GENERIC && !ALPHA_MARVEL
help
Support VGA on an arbitrary hose; needed for several platforms
which always have multiple hoses, and whose consoles support it.
endmenu
menu "ARC Architecture Configuration"
menu "ARC Platform/SoC/Board"
#New platform adds here
source "arch/arc/plat-eznps/Kconfig"
source 'arch/arc/plat-hsdk/Kconfig'
endmenu
menu "ARC CPU Configuration"
choice
prompt "ARC Core"
default ARC_CPU_HS if ISA_ARCV2
help
bla bla
if ISA_ARCOMPACT
config ARC_CPU_750D
bool "ARC750D"
select ARC_CANT_LLSC
help
Support for ARC750 core
endif #ISA_ARCOMPACT
endchoice
if SMP
config NR_CPUS
int "Maximum number of CPUs (2-4096)"
range 2 4096
default "4"
endif #SMP
config ARC_MMU_V4
bool "MMU v4"
depends on ISA_ARCV2
endmenu # "ARC CPU Configuration"
menuconfig ARC_PLAT_EZNPS
bool "\"EZchip\" ARC dev platform"
depends on ISA_ARCOMPACT
select CPU_BIG_ENDIAN
select CLKSRC_NPS if !PHYS_ADDR_T_64BIT
help
Support for EZchip development platforms,
based on ARC700 cores.
We handle few flavors:
- Hardware Emulator AKA HE which is FPGA based chassis
- Simulator based on MetaWare nSIM
- NPS400 chip based on ASIC
# SPDX-License-Identifier: GPL-2.0-only
config ARM64
def_bool y
select HAVE_DYNAMIC_FTRACE_WITH_REGS \
if $(cc-option,-fpatchable-function-entry=2)
select HAVE_EFFICIENT_UNALIGNED_ACCESS
help
ARM 64-bit (AArch64) Linux support.
config PHYS_OFFSET
hex "Physical address of main memory" if MMU
depends on !ARM_PATCH_PHYS_VIRT
default DRAM_BASE if !MMU
default 0x00000000 if ARCH_EBSA110 || \
ARCH_FOOTBRIDGE || \
ARCH_INTEGRATOR || \
ARCH_REALVIEW
default 0x10000000 if ARCH_OMAP1 || ARCH_RPC
default 0x20000000 if ARCH_S5PV210
default 0xc0000000 if ARCH_SA1100
help
Please provide the physical address corresponding to the
location of main memory in your system.
comment "S3C2416 Boards"
config KERNEL_RAM_BASE_ADDRESS
hex "Virtual address of memory base"
default 0xe0000000 if SOC_TMS320C6455
default 0xe0000000 if SOC_TMS320C6457
config CC_IS_GCC
def_bool $(success,echo "$(CC_VERSION_TEXT)" | grep -q gcc)
endif # error
# next line caused hang, see https://phabricator.kde.org/D18509
menu
# the next lines should all be fine
plain:=plain_value
with_whitespace := plain value whitespace
value_with_expansion := $(ARCH)
plain_expansion_mix := Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration
# function definition
cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null,$(1))
# function call
$(cc-option-bit,-m64)
# function call and storing the result
m32-flag := $(cc-option-bit,-m32)
# call to known function
name := $(filename)
# call to known function with arguments
$(warning-if,y,hello world 1)
# ... with nested expansions
$(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)
# expansion in different contexts
config FOO_$(BAR$(BAZ))
int "$(filename)"
default $(lineno) if $(lineno) >= 5
menu "A MENU"
visible if 01 > 00
config A_BOOL
def_bool y && m || !!(!(!!n)) || "$(foo)"
endmenu
# Advanced real world example taken from init/Kconfig in Linux 5.10:
# Invoke the system shell /bin/sh with a command to pipe a C program with an
# asm goto statement to the C compiler that is set by the environment. If the
# exit code is 0 then set the default value of CC_HAS_ASM_GOTO_OUTPUT to y,
# otherwise to n.
config CC_HAS_ASM_GOTO_OUTPUT
depends on CC_HAS_ASM_GOTO
def_bool $(success,echo 'int foo(int x) { asm goto ("": "=r"(x) ::: bar); return x; bar: return 0; }' | $(CC) -x c - -c -o /dev/null)
# Real world example with irregular indentation
config W1_MASTER_DS2490
tristate "DS2490 USB <-> W1 transport layer for 1-wire"
depends on USB
help
Say Y here if you want to have a driver for DS2490 based USB <-> W1 bridges,
for example DS9490*.
This support is also available as a module. If so, the module
will be called ds2490.
# synthetic example
to_upper=$(shell,echo $(1) | tr [:lower:] [:upper:])
config ARGS_$(to_upper,$(CC))
string "Arguments for the current compiler \"$(CC)\""
help
This is a bad idea.
See <file:Documentation/completely/made-up.rst>
# binary operator in expression of an if statement
if CPU_SUPPORTS_CPUFREQ && MIPS_EXTERNAL_TIMER
source "drivers/cpufreq/Kconfig"
endif
# alert on characters (here a colon) that are ignored (taken from axTLS 2.1.5)
config CONFIG_LUA_CORE
string "Location of Lua CORE"
default "/usr/local"
help:
If the Lua exists on another directory then this needs to be changed
comment "Comment texts know expansions, too: $(CC), and the depends property:"
depends on A_BOOL
# "boolean" is now a free variable name ...
boolean=foo
# ... but it looks like a bad idea. This may be disputed.
menuconfig MODULES
bool "Enable loadable module support"
modules
# the three modern options
config OPTIONS
option allnoconfig_y
option modules
option defconfig_list
# old option "env" and obsolete custom options
config OPTIONS
option env=ARCH
option custom-without-argument
option custom-with-argument=ABC
# old syntax
menu OLD_STYLE_PROMPT
visible if CPU_SUPPORTS_CPUFREQ
# busybox 1.31.1
source libbb/Config.in
# uClibc-ng-1.0.37
config DESIRED_TARGET_ARCH
string
option env="ARCH"
config OLD_HELP
hex
---help---
old help property
default 0x1CEC0FEE
endmenu
# a few errors
allnoconfig_y
bool
def_bool
def_tristate
default
defconfig_list
depends
endchoice
endif
help
hex
imply
int
mainmenu
modules
on
option
optional
prompt
range
select
string
tristate
visible
config OK
bool "still OK"
help
still OK
now=fail
andNow=OK
@@ -0,0 +1,114 @@
# comment
include Makefile.in
-include Makefile.doesntexist
.PHONY: all
all: target
foo = bar $(var) \
$(baz) quux
ifeq ($(CC),gcc)
bla=$(call func,param1,param2)
else ifeq "x" "y"
$(error this seems wrong)
else
libs=$(normal_libs)
endif
target1:
error
target2: bla.cpp $@
$(CC) bla.c -o bla.o
$(CC) bla.o $< \
-o bla.exe
@echo "hello" \
bla bla
echo "hello" \
bla bla
target3: ; @echo hello \
world ; echo "hello \
world"
@echo "hello"
target4: ; echo hello \
world ; echo "hello \
world"
echo "hello"
target5 \
target6 \
target7 &::
@echo "hello"
# this should not break the rule
# ifndef is a command
ifndef
# String Substitution
VAR := $(ANOTHER_VAR:%=%+1)
# Variable Assignment
RELAXED ::= mello
rempl := x
foo := a b c
bar := foo
hello := $($(bar):a=$(rempl))
my??var=value
var??=value
var?=value
var? = value
var :::= value
var ::= value
var += value
var != value
var = value\#nocomment
var = value#comment
var = value;value2
override var = a
define var :::=
bar
endef
override define var :::=
bar
endef
undefine var
override undefine var
export foo bar
export foo = bar
unexport foo bar
prog: private EXTRA_CFLAGS = -L/usr/local/lib
prog: CFLAGS = -g
prog: a.o b.o
# Conditionals
bar =
foo = $(bar)
ifdef bar
frobozz = yes
else ifdef foo
frobozz = no
endif
error_type := 0
check:
ifeq ($(error_type),0)
else ifeq ($(error_type),1)
else ifeq ($(error_type),2)
else ifeq ($(error_type),3)
endif
$(info "'")
$(info '"')
$(info $(??))
$(eval $(call Variable_rule,target/compile_flags,$${CXX} $$(CXXFLAGS)))
$(eval ${call Variable_rule,target/link_flags,$$(CXX) $$(LDFLAGS) $${LDLIBS}})
@@ -0,0 +1,53 @@
[Adblock Plus 2.0]
! Checksum: OBK3kgyECgXJtrF4BTO3Fg
! Version: 201709021630
! Title: Test Adblock List
! Last modified: 02 Sep 2017 16:30 UTC
! Expires: 2 days (update frequency)
! Homepage: https://www.kde.org/
! Licence: MIT
!
! Some more text
!
! basic rules
http://example.com/ads/banner123.gif
http://example.com/ads/banner*.gif
http://example.com/ads/*
http://example.com/*
! exception rules
@@advice
@@||example.com^$document
! begin/end matches
swf|
||example.com/banner.gif
! separator characters
http://example.com^
^example.com^
^%D1%82%D0%B5%D1%81%D1%82^
! filter options
*/ads/*$script,match-case
*$donottrack,image,~image
*$domain=example.com|example.net
*/BannerAd.gif$match-case
! regular expressions
/banner\d+/
/\.bla\/[0-9]{2,9}\/$/$script,stylesheet,third-party,xmlhttprequest
! element selectors
##.textad.
###sponsorad
example.com##.sponsor
~foo.example.com##.sponsor
! attribute selectors
##table[width="80%"]
##div[title^="adv"][title$="ert"]
! element selector exceptions
exmaple.com#@#.adwords
@@ -0,0 +1,67 @@
# Apache configuration highlighting unit test
# comment with alters TODO FIXME ###
<IfModule mod_dav_fs.c>
DAVLockDB /var/lock/apache/DAVLock
</IfModule>
<VirtualHost *:443>
Include something_else.inc
SSLEngine on
# exclude insecure protocols
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
# exclude insecure ciphers
SSLCipherSuite "HIGH !EXP !eNULL !aNULL !LOW !RC4 !3DES !MD5 !EXP !PSK !SRP !DSS !DES !aECDH"
SSLCertificateFile /etc/letsencrypt/live/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/chain.pem
CustomLog /var/log/apache2/ssl_request_log ssl_combined
</VirtualHost>
<Proxy "http://localhost:10000/">
SSLRequireSSL
</Proxy>
<Directory "/some/quoted/path">
Options -Indexes -FollowSymLinks
DirectoryIndex index.php
AllowOverride None
Order allow,deny
Allow from all
Options FollowSymLinks
AllowOverride FileInfo Options All
<LimitExcept GET>
Require valid-user
</LimitExcept>
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
ForceType text/plain
</Files>
</Directory>
Alias /foo/ "/srv/www/htdocs/foo/"
AuthType Basic
AuthName "KDE"
AuthUserFile /srv/www/htpasswd.db
Require user konqui
<VirtualHost _default_:80>
ServerName www.kde.org
ServerAlias kde.org
RewriteEngine On
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,QSA,R=permanent]
</VirtualHost>
AuthBasicProvider ldap
AuthLDAPBindDN uid=ldapproxy,ou=people,dc=kde,dc=org
AuthLDAPBindPassword top_secret
AuthLDAPURL ldap://localhost:389/ou=people,dc=kde,dc=org?uid?sub?(objectClass=posixAccount)
AuthLDAPGroupAttributeIsDN on
AuthLDAPGroupAttribute member
Require ldap-group cn=sysadmin,ou=Group,dc=kde,dc=org
@@ -0,0 +1 @@
Apache Configuration
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,143 @@
#i am macro
library "a"
function myfunc ( foo as Integer , bar as Float = 3.5 ) as Void
end function
sub mysub ( foo as Integer , bar as Float = 3.5 ) as Void
end sub
' my comment
Function MyCamelCaseFunction()
lvalue = rvalue
a=5
a=5!
a=5#
a=5%
a=5&
a$=5
a!=5
a#=5
a%=5
a&=5
a=a$
a=a!
a=a#
a=a%
a=a&
foo()
a.foo()
a=a.foo()
eval=5
eval()
a.eval()
a=eval
a=eval()
a=a.eval()
sleep=5
sleep()
a.sleep()
a=sleep
a=sleep()
a=a.sleep()
if a=b c=d
if a foo()
if a then foo()
if a
end if
if a then
end if
if a
else if
else
end if
if a
elseif
endif
for each a in b
end for
for a=1 to 10 step 2
endFor
for each a in b
next
while a
end while
while a
endWhile
a [ "a" , 1, foo() ] = 1
a.foo()[1]=1
a = {
a : 1
b : "2"
c : function() : end function
}
b.foo("string",1,{a:b},1.5,[1,2,3])
a = b.foo("string",1,{a:b},1.5,[1,2,3])
unnamed_function = function ( a as Integer ) as Float
a = +-b
a = &h42abcdef
c = var@attr
end function
unnamed_sub = sub ( a as Integer ) as Void
end sub
endFunction
sub exceptions()
try=1
try()
try.foo
try foo
catch=1
catch()
catch.foo
catch foo
try
catch foo
end try
try ' comment
endtry
throw {a: "abc"}
end sub
sub inline_lambda()
a(a, "string")(a, "string")
a = sub()
end sub(a, "string", [a, foo("string")])
b = function()
end function(a, "string")
c = sub()
end sub
end sub
@@ -0,0 +1,86 @@
/* highlighting test case for Gradle (which actually uses Groovy syntax) */
// single line comment with ### TODO FIXME
/* multiline comment with ### TODO FIXME */
/** Javadoc comment with ### TODO FIXME
* @param foo bla bla ATTENTION
* @return abc cde
* @see javadoc.xml
*/
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.mnode.ical4j:ical4j:2.2.0'
}
android {
compileSdkVersion androidCompileSdkVersion.toInteger()
buildToolsVersion androidBuildToolsVersion
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
}
lintOptions {
abortOnError false
}
}
def a = 'ab\'c'
def a = '''\
abc $x.toString() ${x.toString()}
\nxy
'''
def a = '''
abc $x.toString() ${x.toString()}
\nxy
'''
def a = "ab\'c"
def a = """\
abc $x.toString() ${x.toString()}
\nxy
"""
def a = """
abc $x.toString() ${x.toString()}
\nxy
"""
def a = $/$ $$ $/ $= $x.toString() ${x.toString()}
abc
\nxy/$
def a = /ab\/c
\nxyd/
1_2e3_4
@@ -0,0 +1,125 @@
# comment
rule b
rule c
#d
rule c
description=a
rule d
description = ds
description = ds
rule=ds
description = ds
rule b
rule c
rule c
# ds
ds=ds
description=a
rule d
rule =description = ds
rule b
command = clang -MMD -MF $out.d -o $out -c $in
description = building $out
unknown = xyz
rule dump
command = sleep 1; ls -l /proc/self/fd; exit 1
pool = link_pool
# blah blah
pool = console
pool = $console
rule xy-z_
rule --xy-z_
rule _xy-z_
# error
rule with error
rule a:a
rule a|a
rule a$
rule 0-@#d
# browse_py.h is used to inline browse.py.
rule inline
command = "$root/src/inline.sh" $varname < $in > $out
description = INLINE $out
default foo bar
default baz
include ninja1.ninja
subninja ninja2.ninja
pool link_pool
depth = 4
xxx = d
pool link_pool d
depth = 4
build a.o: b a.c
build a.o|c: b a.c || a | b
build a.o | c : b a.c | a || b
build $a.o | $c : b $a.c | $a || $b
build 0: sleep README
build 1: sleep README
build all: phony 0 1
deps = xxx
CMD = cc
build all: phony 0 1
build $builddir/browse_py.h: inline $root/src/browse.py | $root/src/inline.sh
varname = kBrowsePy
build $builddir/subprocess-posix.o: cxx $root/src/subprocess-posix.cc
build $builddir/libninja.a: ar $builddir/browse.o $builddir/build.o $
$builddir/build_log.o $builddir/clean.o $builddir/debug_flags.o $
$builddir/depfile_parser.o $builddir/deps_log.o
build $root/doc/manual.pdf: dblatex $builddir/manual.xml | $
$root/doc/dblatex.xsl
build out: cat in |@ validate1 validate2 |@ validate1 | dep
build out: cat in || dep |@ validate
builddir=/
builddir =/
builddir= /
ldflags = -L$builddir
xx x
x = $a
x = $-a_
x = ${a}
x = ${-a}
x = $a@
x = $@
x = $$
x = $:
x = $ a
x = $
b
x = $
$
a
x = $
$a
x = $a a
x = ${a} a
x = $$ a
x = $: a
x = $! a
x = ${a b ds
x = a
@@ -0,0 +1,73 @@
; Test file, released under MIT License
(ns ^{:doc "Syntax highlighting test file"
:author "Markus Brenneis"}
highlighting)
(defn something-else [f xs]
#_(map #(apply f (% [%])) (cons 1 xs))
(map #(apply f (% xs)) (cons 1 xs))
#_[1 '(2)]
xs)
(def foo [\a \b \n \ucafe \o123 \n
\newline \tab \space \formfeed \backspace])
(def fizz {#{\a \b}
#{\n \newline}})
(def fizz' #{{\a \b}
{\n \newline}})
(defn bar [xs]
(as-> xs <>
(cons :a <>)
(map #(%1 %2) <>) ; TODO improve
(into <> [:konjure.logic.specs/numShips])))
(def x-2-y
#_"do \" sth"
(domonad set-m
[x #{1.1, (+ -2 +4)}
y #{1.1, (- -2.0 4.0)}]
(*' x y)))
(def bases
(and (= -1 -1N)
(= 1/4 -2.5e-1)
(= -1/2 -0.5M)
(= -0x1Ab -0X1ab)
(= +2r101010 25R1h)
(= 39r13 42R10))) ; FIXME this one is not correct
(def ^{:private true}
(= (last #{#{}}) #{{#{}}}))
(def s "#repl\n")
(def r #"repl")
(defn- stuff!
[a]
"This is no \"documentation\"!"
(= (class #'+) (class #'foo))
(let [+ -] [(+ a 1) (@#'+ a 1)]))
(defn- throwIllegalArgumentException!
"Throws an \"IllegalArgumentException\" or
a js/Error."
[message]
#?(:clj (throw (IllegalArgumentException. message))
:cljs (throw (js/Error. message))))
(defmacro let-fn "a nonsense macro" [one-binding & body]
`(+ 1 ~(inc' 1))
(let [[identifier & fn-body] one-binding]
`(let [~identifier (fn ~identifier ~@fn-body)]
~@body `a#)))
(def state (atom [(= false true) nil]))
(defn something-cool [] (first @state))
(defn- something-different [] (first (into @state [12])))
(defn- instance-getfield [this k] (@(.state this) k))
@@ -0,0 +1,14 @@
Source: libdemo
Section: unknown
Priority: extra
Maintainer: Foo Bar <foo.bar@example.org>
Build-Depends: debhelper (>=9)
Standards-Version: 3.9.8
Homepage: https://libdemo.example.org
Package: libdemo
Architecture: any
Multi-Arch: foreign
Depends: ${misc:Depends}, ${shlibs:Depends}
Description: Demonstration library
This library serves only the purpose of demonstration
@@ -0,0 +1,203 @@
<#
.SYNOPSIS
Lorem ipsum dolor sit amet.
.DESCRIPTION
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
.PARAMETER InputPath
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
.parameter InputPath
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
bla .PARAMETER InputPath
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
.EXAMPLE
PS> .\foo.ps1
#>
@" multi
line
string
$x
"'
\n
"@
"@
@' multi
line
string
$x
"'
\n
'@
'@
$foo = "Test `u{2013} String`nwith `"escapes`" """
$foo = "Test `u{2013} String`nwith `"escapes`" `
dssad"
$foo = 'bla bla''bla bla $x `n'
$Global:HOME = "abc"
[bool]::Parse('false')
echo [bool]::Parse('false')
echo $env:EDITOR ${env:EDITOR} $foo ${foo} $foo-bar ${foo-bar} ${a b
c}
echo "hashtable: $(@{ key = 'value' })"
echo 122.42kb 332.d 23d 625 3232e+2 0x233 0b1101
echo 0xaj 0b1112 123a
docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
--network todo-app `
-e MYSQL_HOST=mysql `
-e MYSQL_USER=root `
-e MYSQL_PASSWORD=secret `
-e MYSQL_DB=todos `
node:12-alpine `
cmd "npm install && npm run start"
function Get-NewPix
{
$start = Get-Date -Month 1 -Day 1 -Year 2010
$allpix = Get-ChildItem -Path $env:UserProfile\*.jpg -Recurse
$allpix | Where-Object {$_.LastWriteTime -gt $Start}
}
function Get-SmallFiles {
Param($Size)
Get-ChildItem $HOME | Where-Object {
$_.Length -lt $Size -and !$_.PSIsContainer
}
}
function Get-EscapedPath
{
param(
[Parameter(
Position=0,
Mandatory=$true
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)
]
[string]$path
)
process {
if ($path.Contains(' '))
{
return '"' + $path + '"'
}
return $path
}
}
<#
Copied from Craft for testing syntax highlighting
#>
# this file sets some environment variables that are needed
# for finding programs and libraries etc.
# by Hannah von Reth <vonreth@kde.org>
# you should copy kdesettings.ini to ..\etc\kdesettings.ini
# and adapt it to your needs (see that file for more info)
# this file should contain all path settings - and provide thus an environment
# to build and run kde programs
# based on kdeenv.bat
cls
$env:CraftRoot=[System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
$CRAFT_ARGUMENTS = $args
&{
[version]$minPythonVersion = 3.6
function findPython([string] $name)
{
$py = (Get-Command $name -ErrorAction SilentlyContinue)
if ($py -and ($py | Get-Member Version) -and $py.Version -ge $minPythonVersion) {
$env:CRAFT_PYTHON=$py.Source
}
}
findPython("python3")
findPython("python")
function readINI([string] $fileName)
{
$ini = @{}
switch -regex -file $fileName {
"^\[(.+)\]$" {
$section = $matches[1].Trim()
$ini[$section] = @{}
}
"^\s*([^#].+?)\s*=\s*(.*)" {
$name,$value = $matches[1..2]
$ini[$section][$name] = $value.Trim()
}
}
$ini
}
if(test-path -path $env:CraftRoot\..\etc\kdesettings.ini)
{
$settings = readINI $env:CraftRoot\..\etc\kdesettings.ini
}
else
{
Write-Error("$env:CraftRoot\..\etc\kdesettings.ini Does not exist")
break
}
if( $CRAFT_ARGUMENTS[0] -eq "--get")
{
Write-Host($settings[$CRAFT_ARGUMENTS[1]][$CRAFT_ARGUMENTS[2]])
break
}
function prependPATH([string] $path)
{
$env:PATH="$path{0}$env:PATH" -f [IO.Path]::PathSeparator
}
if( -Not $env:CRAFT_PYTHON)
{
prependPATH $settings["Paths"]["Python"]
$env:CRAFT_PYTHON=[IO.PATH]::COMBINE($settings["Paths"]["Python"], "python")
}
(& $env:CRAFT_PYTHON ([IO.PATH]::COMBINE("$env:CraftRoot", "bin", "CraftSetupHelper.py")) "--setup") |
foreach {
if ($_ -match "=") {
$v = $_.split("=")
set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
#Write-Host("$v[0]=$v[1]")
}
}
cd "$env:KDEROOT"
}
function Global:craft() {
return & $env:CRAFT_PYTHON ([IO.PATH]::COMBINE("$env:CraftRoot", "bin", "craft.py")) $args
}
if($args.Length -ne 0)
{
invoke-expression -command "$args"
}
@@ -0,0 +1,38 @@
// this is a single-line comment
// NOTE ### FIXME TODO
/* this is a
multi-line comment
*/
/* this is another
* multiline comment
* NOTE ### FIXME TODO
*/
/** this is another
* multiline comment
* NOTE ### FIXME TODO
*/
// simple assignment
var i = 5;
var j = // assignment missing, still should be nice highlighting
var k // assignment missing, still should be nice highlighting
// test a string
var s = "Hello World!";
// arr is an array
var arr = new[] { 0, 1, 2, 3, 4 };
// expr is compiled as IEnumerable<Customer>
// or perhaps IQueryable<Customer>
var expr =
from c in customers
where c.City == "London"
select c;
// compiled anonymous type
var anon = new { Country = "Germany", Inhabitants = 80000000 };
@@ -0,0 +1,33 @@
# cube.obj
#
g cube
v 0.0 0.0 0.0
v 0.0 0.0 1.0
v 0.0 1.0 0.0
v 0.0 1.0 1.0
v 1.0 0.0 0.0
v 1.0 0.0 1.0
v 1.0 1.0 0.0
v 1.0 1.0 1.0
vn 0.0 0.0 1.0
vn 0.0 0.0 -1.0
vn 0.0 1.0 0.0
vn 0.0 -1.0 0.0
vn 1.0 0.0 0.0
vn -1.0 0.0 0.0
f 1//2 7//2 5//2
f 1//2 3//2 7//2
f 1//6 4//6 3//6
f 1//6 2//6 4//6
f 3//3 8//3 7//3
f 3//3 4//3 8//3
f 5//5 7//5 8//5
f 5//5 8//5 6//5
f 1//4 5//4 6//4
f 1//4 6//4 2//4
f 2//1 6//1 8//1
f 2//1 8//1 4//1
@@ -0,0 +1,26 @@
error before header
ply
format ascii 1.0
comment TODO this is a comment
element vertex 8
property float x
property float y
property float z
element face 6
property list uint int vertex_indices
end_header
-1 -1 -1
1 -1 -1
1 1 -1
-1 1 -1
-1 -1 1
1 -1 1
1 1 1
-1 1 1
4 0 1 2 3
4 5 4 7 6
4 6 2 1 5
4 3 7 4 0
4 7 3 2 6
4 5 1 0 4
@@ -0,0 +1,30 @@
solid cube_corner
facet normal 0.0 -1.0 0.0
outer loop
vertex 0.0 0.0 0.0
vertex 1.0 0.0 0.0
vertex 0.0 0.0 1.0
endloop
endfacet
facet normal 0.0 0.0 -1.0
outer loop
vertex 0.0 0.0 0.0
vertex 0.0 1.0 0.0
vertex 1.0 0.0 0.0
endloop
endfacet
facet normal -1.0 0.0 0.0
outer loop
vertex 0.0 0.0 0.0
vertex 0.0 0.0 1.0
vertex 0.0 1.0 0.0
endloop
endfacet
facet normal 0.577 0.577 0.577
outer loop
vertex 1.0 0.0 0.0
vertex 0.0 1.0 0.0
vertex 0.0 0.0 1.0
endloop
endfacet
endsolid
@@ -0,0 +1,2 @@
normal X:string other: normal X:string other: normal
normal X{string other} normal X:string other: normal
@@ -0,0 +1,47 @@
# Highlight words
word1
_word2
/word3
word4+
<word5>
&
;;;
w w-word8-
normal word1
normal _word2
normal /word3
normal word4+
normal <word5>
normal &
normal ;;;
normal w w-word8-
....word1....
...._word2....
..../word3....
....word4+....
....<word5>....
....&....
....;;;....
....w w-word8-....
normal_word2 <-- _word2
normal/word3 <-- /word3
word4+normal <-- word4+
normal<word5>normal <-- <word5>
normal&normal <-- &
normal;;;normal <-- ;;;
w w-word8-normal <-- w w-word8-
aaa_word2_aaa <-- _word2
aaa/word3/aaa <-- /word3
aaa+word4+aaa <-- word4+
aaa-w w-word8-aaa <-- w w-word8-
# Normal text
aaaword1aaa
aaa_word2aaa
aaa/word3aaa
aaaword4+aaa
aaaw w-word8-aaa
@@ -0,0 +1,113 @@
#
# Copyright (c) 2016-2018 Varnish Cache project
# Copyright (c) 2012-2016 Varnish Software AS
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# detectdevice.vcl - regex based device detection for Varnish
# https://github.com/varnishcache/varnish-devicedetect/
#
# Original author: Lasse Karstensen <lkarsten@varnish-software.com>
sub devicedetect {
unset req.http.X-UA-Device;
set req.http.X-UA-Device = "pc";
# Handle that a cookie may override the detection alltogether.
if (req.http.Cookie ~ "(?i)X-UA-Device-force") {
/* ;?? means zero or one ;, non-greedy to match the first. */
set req.http.X-UA-Device = regsub(req.http.Cookie, "(?i).*X-UA-Device-force=([^;]+);??.*", "\1");
/* Clean up our mess in the cookie header */
set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *X-UA-Device-force=[^;]+;? *", "\1");
/* If the cookie header is now empty, or just whitespace, unset it. */
if (req.http.Cookie ~ "^ *$") { unset req.http.Cookie; }
} else {
if (req.http.User-Agent ~ "\(compatible; Googlebot-Mobile/2.1; \+http://www.google.com/bot.html\)" ||
(req.http.User-Agent ~ "(Android|iPhone)" && req.http.User-Agent ~ "\(compatible.?; Googlebot/2.1.?; \+http://www.google.com/bot.html") ||
(req.http.User-Agent ~ "(iPhone|Windows Phone)" && req.http.User-Agent ~ "\(compatible; bingbot/2.0; \+http://www.bing.com/bingbot.htm")) {
set req.http.X-UA-Device = "mobile-bot"; }
elsif (req.http.User-Agent ~ "(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot" ||
req.http.User-Agent ~ "(?i)(baidu|jike|symantec)spider" ||
req.http.User-Agent ~ "(?i)pingdom" ||
req.http.User-Agent ~ "(?i)facebookexternalhit" ||
req.http.User-Agent ~ "(?i)scanner" ||
req.http.User-Agent ~ "(?i)slurp" ||
req.http.User-Agent ~ "(?i)(web)crawler") {
set req.http.X-UA-Device = "bot"; }
elsif (req.http.User-Agent ~ "(?i)ipad") { set req.http.X-UA-Device = "tablet-ipad"; }
elsif (req.http.User-Agent ~ "(?i)ip(hone|od)") { set req.http.X-UA-Device = "mobile-iphone"; }
/* how do we differ between an android phone and an android tablet?
http://stackoverflow.com/questions/5341637/how-do-detect-android-tablets-in-general-useragent */
elsif (req.http.User-Agent ~ "(?i)android.*(mobile|mini)") { set req.http.X-UA-Device = "mobile-android"; }
// android 3/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.
elsif (req.http.User-Agent ~ "(?i)android 3") { set req.http.X-UA-Device = "tablet-android"; }
/* Opera Mobile */
elsif (req.http.User-Agent ~ "Opera Mobi") { set req.http.X-UA-Device = "mobile-smartphone"; }
// May very well give false positives towards android tablets. Suggestions welcome.
elsif (req.http.User-Agent ~ "(?i)android") { set req.http.X-UA-Device = "tablet-android"; }
elsif (req.http.User-Agent ~ "PlayBook; U; RIM Tablet") { set req.http.X-UA-Device = "tablet-rim"; }
elsif (req.http.User-Agent ~ "hp-tablet.*TouchPad") { set req.http.X-UA-Device = "tablet-hp"; }
elsif (req.http.User-Agent ~ "Kindle/3") { set req.http.X-UA-Device = "tablet-kindle"; }
elsif (req.http.User-Agent ~ "Touch.+Tablet PC" ||
req.http.User-Agent ~ "Windows NT [0-9.]+; ARM;" ) {
set req.http.X-UA-Device = "tablet-microsoft";
}
elsif (req.http.User-Agent ~ "Mobile.+Firefox") { set req.http.X-UA-Device = "mobile-firefoxos"; }
elsif (req.http.User-Agent ~ "^HTC" ||
req.http.User-Agent ~ "Fennec" ||
req.http.User-Agent ~ "IEMobile" ||
req.http.User-Agent ~ "BlackBerry" ||
req.http.User-Agent ~ "BB10.*Mobile" ||
req.http.User-Agent ~ "GT-.*Build/GINGERBREAD" ||
req.http.User-Agent ~ "SymbianOS.*AppleWebKit") {
set req.http.X-UA-Device = "mobile-smartphone";
}
elsif (req.http.User-Agent ~ "(?i)symbian" ||
req.http.User-Agent ~ "(?i)^sonyericsson" ||
req.http.User-Agent ~ "(?i)^nokia" ||
req.http.User-Agent ~ "(?i)^samsung" ||
req.http.User-Agent ~ "(?i)^lg" ||
req.http.User-Agent ~ "(?i)bada" ||
req.http.User-Agent ~ "(?i)blazer" ||
req.http.User-Agent ~ "(?i)cellphone" ||
req.http.User-Agent ~ "(?i)iemobile" ||
req.http.User-Agent ~ "(?i)midp-2.0" ||
req.http.User-Agent ~ "(?i)u990" ||
req.http.User-Agent ~ "(?i)netfront" ||
req.http.User-Agent ~ "(?i)opera mini" ||
req.http.User-Agent ~ "(?i)palm" ||
req.http.User-Agent ~ "(?i)nintendo wii" ||
req.http.User-Agent ~ "(?i)playstation portable" ||
req.http.User-Agent ~ "(?i)portalmmm" ||
req.http.User-Agent ~ "(?i)proxinet" ||
req.http.User-Agent ~ "(?i)windows\ ?ce" ||
req.http.User-Agent ~ "(?i)winwap" ||
req.http.User-Agent ~ "(?i)eudoraweb" ||
req.http.User-Agent ~ "(?i)htc" ||
req.http.User-Agent ~ "(?i)240x320" ||
req.http.User-Agent ~ "(?i)avantgo") {
set req.http.X-UA-Device = "mobile-generic";
}
}
}
@@ -0,0 +1,68 @@
---
title: "test"
author: "me"
date: "07.10.2014"
output: html_document
---
This is a simple test document. It shows syntax highlighting switches between YAML (above), R blocks
```{r, echo=FALSE}
for (i in 1:10) {
if(i>=10) print(i)
}
# two blank lines below
sessionInfo()
```
LaTeX equations,
$$
h_{i}(t \mid q,C) = h_{0}(t) e^{\beta_{1}quality_{i} + \beta_{2}C_{iq}}
$$
and Markdown. A [link](http://example.com) in Markdown.
Inline `r y <- 5 + x - sin(3)` R code.
Inline `y <- 5 + x - sin(3)` code.
Heading
=======
Sub-heading
-----------
A list of editors:
* kate
* vim
* emacs
*italic*, **bold**, `monospace`
code block
more code
normal text
normal text
normal text
1. item
* This is a list item
with multiple lines.
```{r pressure, echo=FALSE}
plot(pressure)
```
> This is a
blockquote `r cos(33) `
This is a new paragraph, which
is part of this $$ \text{item} $$.
indented code block
Other paragraph.
* subitem
* subitem
$$ A = B + C $$
@@ -0,0 +1,4 @@
keyword
{keyword}
`keyword`
'keyword'
@@ -0,0 +1,9 @@
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
UUID=A7EF-407D /boot/efi vfat umask=0077 0 2
/dev/mapper/luks-6d67ccaf-3e9a-44fb-8e51-f38175256a87 / ext4 defaults,noatime 0 1
@@ -0,0 +1,58 @@
pick 318aceb Add test for Makefile highlighting
p 4c7182a Add first batch of test files resurrected from Kate 4.6
r 6f7d8a7 Sync xml files with KTextEditor
reword 8f0dbdc Add another batch of resurrected tests from Kate 4.6
e 828de45 Add some more resurrected tests from Kate 4.6
edit 6aa6264 Add simple coverage information for syntax definition tests
s 63df253 Add more syntax highlighting tests from Kate 4.6
squash 3e7771f Add three more tests recovered from Kate 4.6
f 5c7fd91 Add Kate 4.6 ASP syntax test
f -c 5c7fd91 Add Kate 4.6 ASP syntax test
fixup 7a777ff Implement case-sensitive overrides for keyword rules
fixup -C 7a777ff Implement case-sensitive overrides for keyword rules
exec 2b16665 Implement dynamic DetectChar rules
x 0b703a3 Add a few more tests from the Kate 4.6 test suite
d dd808dc Quote captured strings we replace in regular expressions
drop dd808dc Quote captured strings we replace in regular expressions
b afafafaffa
break afafafaffa
l label
label afafafaffa
t label
reset afafafaffa
m label # bla bla bla
merge -c afafafaffa label
u ref
update-ref ref
# Rebase a27a854..0b703a3 onto a27a854 (13 command(s))
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# create a merge commit using the original merge commit's
# message (or the oneline, if no original merge commit was
# specified); use -c <commit> to reword the commit message
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
# to this position in the new commits. The <ref> is
# updated at the end of the rebase
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
@@ -0,0 +1,16 @@
# Example gitolite.conf
include "mygroups.conf"
@admin = user1 user2
@admin = user3@domain.com
repo @all
option deny-rules = 1
option hooks.emailprefix = '[%GL_REPO] '
repo myrepo
- protected$ = @all # Nobody can push
RW+CD = @admin
RW = @group1
R = user3@domain.com
@@ -0,0 +1,131 @@
## R Script Sample File
## Source: http://www.rexamples.com
## Basics
a <- 42.24
a <- 42i
a <- 42L
a <- 42
A <- a * 2 # R is case sensitive
print(a)
cat(A, "\n") # "84" is concatenated with "\n"
if(A>a) # true, 84 > 42
{
cat(A, ">", a, "\n")
}
## Functions
Square <- function(x) {
return(x^2)
}
print(Square(4))
print(Square(x=4)) # same thing
DoSomething(color="red",number=55)
## Countdown
countdown <- function(from)
{
print(from)
while(from!=0)
{
Sys.sleep(1)
from <- from - 1
print(from)
}
}
countdown(5)
## Reading user input
readinteger <- function()
{
n <- readline(prompt="Enter an integer: ")
n <- as.integer(n)
if (is.na(n)){
n <- readinteger()
}
return(n)
}
print(readinteger())
readinteger <- function()
{
n <- readline(prompt="Enter an integer: ")
if(!grepl("^[0-9]+$",n))
{
return(readinteger())
}
return(as.integer(n))
}
print(readinteger())
## Guess a random number game
readinteger <- function()
{
n <- readline(prompt="Enter an integer: ")
if(!grepl("^[0-9]+$",n))
{
return(readinteger())
}
return(as.integer(n))
}
# real program start here
num <- round(runif(1) * 100, digits = 0)
guess <- -1
cat("Guess a number between 0 and 100.\n")
while(guess != num)
{
guess <- readinteger()
if (guess == num)
{
cat("Congratulations,", num, "is right.\n")
}
else if (guess < num)
{
cat("It's bigger!\n")
}
else if(guess > num)
{
cat("It's smaller!\n")
}
}
## Lists
sum(0:9)
append(LETTERS[1:13],letters[14:26])
c(1,6,4,9)*2
something <- c(1,4,letters[2]) # indices start at one, you get (1,4,"b")
length(something)
## margrittr's pipe
diamonds %>%
filter(price > 1000) %>%
group_by(cut) %>%
tally() %>%
rename(tally = n) %>%
arrange(-tally) %>%
mutate(pct = tally / sum(tally)) -> df
## R native pipes (R > 4.1)
Sys.setenv("_R_USE_PIPEBIND_"= TRUE)
mtcars |> x => lm(mpg ~ cyl, data = x)
## ggplot2
plot = ggplot(diamonds, aes(x = price, y = carat)) +
geom_point(alpha = 0.3, colour = 'steelblue') +
labs(
title = "ggplot diamonds",
x = "Price, $",
y = "Carat"
) +
facet_wrap(~ cut) +
theme_minimal()
plot + coord_flip()
@@ -0,0 +1,43 @@
-- Test file for kate's syntax highlighting
Title "Test file";
-- BEGIN region (a region marker region) :)
% multiline comment
goes on here %
-- END
FUNCTION FCT (Clk, Key) RETURNS (pulse);
SUBDESIGN CDCLOCK2
(
in : INPUT; -- go in
out[3..0] : OUTPUT; -- come out
)
VARIABLE
start : soft;
usec[3..0] : node;
BEGIN
in = FCT(clock, some_key); -- senseless code
-- comment
blubb = (blobb[] == H"3ff");
IF in THEN asdf
-- folde me
END IF;
TABLE
-- missing code
END TABLE
END;
-- hex, octal, binary
H"0" => B"1000000";
O"01234567";
@@ -0,0 +1,604 @@
^j:: ; hotkey label
::ftw::Free the whales ; hotstring label abbreviation
::btw:: ; hotstring label action
MsgBox, You typed btw.
Run, notepad.exe ; Run Notepad when you press CTRL+N.
MsgBox, Wow!
MsgBox, There are
Run, notepad.exe
WinActivate, Untitled - Notepad
WinWaitActive, Untitled - Notepad
Send, 7 lines{!}{Enter}
SendInput, inside the CTRL{+}J hotkey.
return
Numpad0 & Numpad1::
MsgBox, You pressed Numpad1 while holding down Numpad0.
Run, notepad.exe
return
; Untitled - Notepad
#IfWinActive Untitled - Notepad
!q::
MsgBox, You pressed ALT+Q in Notepad.
return
; Any window that isn't Untitled - Notepad
#IfWinActive
!q::
MsgBox, You pressed ALT+Q in any window.
return
; Retrieve the ID/HWND of the active window
id := WinExist("A")
MsgBox % id
; Press Win+↑ to maximize the active window
#Up::WinMaximize, A
#i::
Run, https://www.google.com/
return
^p::
Run, notepad.exe
return
~j::
Send, ack
return
:*:acheiv::achiev
::achievment::achievement
::acquaintence::acquaintance
:*:adquir::acquir
::aquisition::acquisition
:*:agravat::aggravat
:*:allign::align
::ameria::America
:*:ftw::Free the whales ; Hotstring modifiers
this_is_a_label: ; label
#IfWinActive Untitled - Notepad
#Space::
MsgBox, You pressed WIN+SPACE in Notepad.
return
Send, {Ctrl down}c{Ctrl up}
SendInput, [b]{Ctrl down}v{Ctrl up}[/b]
return ; This ends the hotkey. The code below this point will not get triggered.
Send, This text has been typed{!}
Send, {a} ; WRONG
Send, {a}{b}{c} ; WRONG
Send, {abc} ; WRONG
Send, abc ; CORRECT
Send, ^s ; Both of these send CTRL+S
Send, {Ctrl down}s{Ctrl up} ; Both of these send CTRL+S
Send, {Ctrl down}c{Ctrl up}
Send, {b down}{b up}
Send, {Tab down}{Tab up}
Send, {Up down} ; Press down the up-arrow key.
Sleep, 1000 ; Keep it down for one second.
Send, {Up up} ; Release the up-arrow key.
Send,
(
Line 1
Line 2
Apples are a fruit.
)
Send %A_Hour%
SubStr(37 * 12, 1, 2)
SubStr(A_Hour - 12, 2)
SubStr(A_AhkPath, InStr(A_AhkPath, "AutoHotkey"))
SubStr("I'm scripting, awesome!", 16)
SetTitleMatchMode RegEx
WinActivate ahk_exe i)\\notepad\.exe$ ; Match the name part of the full path.
WinActivate ahk_exe im)(*BSR_ANYCRLF)abc\Rxyz
WinActivate ahk_exe im)(*BSR_ANY[^]]CRLF)abc\Rxyz
if (MyVar = 5)
{
MsgBox, MyVar equals %MyVar%!!
ExitApp
}
MyVar = Text
MyVar = %MyVar2%
MyVar = %MyVar2% some text %MyVar3%.
MyVar := SubStr("I'm scripting, awesome!", 16)
MyVar := "Text"
MyVar := MyVar2
MyVar := 6 + 8 / 3 * 2 - Sqrt(9)
MyVar := "The value of 5 + " MyVar2 " is: " 5 + MyVar2
if (Var1 != Var2)
Var1 := Var2 + 100
; Some examples showing when to use percents and when not:
Var = Text ; Assign some text to a variable (legacy).
Number := 6 ; Assign a number to a variable (expression).
Var2 = %Var% ; Assign a variable to another (legacy).
Var3 := Var ; Assign a variable to another (expression).
Var4 .= Var ; Append a variable to the end of another (expression).
Var5 += Var ; Add the value of a variable to another (expression).
Var5 -= Var ; Subtract the value of a variable from another (expression).
Var6 := SubStr(Var, 2, 2) ; Variable inside a function. This is always an expression.
Var7 = %Var% Text ; Assigns a variable to another with some extra text (legacy).
Var8 := Var " Text" ; Assigns a variable to another with some extra text (expression).
MsgBox, %Var% ; Variable inside a command.
StringSplit, Var, Var, x ; Variable inside a command that uses InputVar and OutputVar.
if (Number = 6) ; Whenever an IF has parentheses, it'll be an expression. So no percent signs.
if (Var != Number) ; Whenever an IF has parentheses, it'll be an expression. So no percent signs.
if Number = 6 ; Without parentheses, the IF is legacy. However, only variables on the 'right side' need percent signs.
if Var1 < %Var2% ; Without parentheses, the IF is legacy. However, only variables on the 'right side' need percent signs.
MyObject := ["one", "two", "three", 17]
Banana := {"Color": "Yellow", "Taste": "Delicious", "Price": 3}
MyObject := Array("one", "two", "three", 17)
Banana := Object("Color", "Yellow", "Taste", "Delicious", "Price", 3)
Banana["Pickled"] := True ; This banana has been pickled. Eww.
Banana.Consistency := "Mushy"
Value := Banana["Color"]
Value := Banana.Color
MyObject["NewerKey"] := 3.1415
MyObject.NewKey := "Shiny"
MyObject.Push(Value1, Value2, Value3...)
Banana.Consistency := ""
RemovedValue := MyObject.Delete(AnyKey)
NumberOfRemovedKeys := MyObject.Delete(FirstKey, LastKey)
arr := [{}] ; Creates an array containing an object.
arr[1] := {} ; Creates a second object, implicitly freeing the first object.
arr.RemoveAt(1) ; Removes and frees the second object.
x := {}, y := {} ; Create two objects.
x.child := y, y.parent := x ; Create a circular reference.
y.parent := ""
x := "", y := ""
table.base.__Get(table, x)[y] := content ; A
table.base.__Set(table, x, y, content) ; B
RemovedValue := MyObject.RemoveAt(Index)
NumberOfRemovedKeys := MyObject.RemoveAt(Index, Length)
val := obj.Property := 42
m1 := new GMem(0, 20)
m2 := {base: GMem}.__New(0, 30)
x ? CallIfTrue() : CallIfFalse()
ProductIsAvailable := (Color = "Red")
? false ; We don't have any red products, so don't bother calling the function.
: ProductIsAvailableInColor(Product, Color)
MyObject.Pop()
%Var%()
Sleep MillisecondsToWait
Sleep %MillisecondsToWait%
Sleep % MillisecondsToWait
MsgBox % 1+1 ; Shows "2"
MsgBox 1+1 ; Shows "1+1"
MsgBox % "This is text."
MsgBox This is text.
MsgBox % A_AhkVersion
MsgBox %A_AhkVersion%
MsgBox % %A_AhkVersion%
MsgBox % "Hello %A_UserName%." ; Shows "%A_UserName%"
MsgBox Hello %A_UserName%. ; Shows your username.
MsgBox % "Hello " . A_UserName . "." ; Shows your username.
MyVar := "This is text."
MyVar = This is text.
if (Var1 = Var2)
if Var1 = %Var2%
if (Var1 >= Low and Var1 <= High)
if Var1 between %Low% and %High%
Format("{:L}{:U}{:T}", input, input, input)
*#up::MouseMove, 0, -10, 0, R ; Win+UpArrow hotkey => Move cursor upward
*#Down::MouseMove, 0, 10, 0, R ; Win+DownArrow => Move cursor downward
*#Left::MouseMove, -10, 0, 0, R ; Win+LeftArrow => Move cursor to the left
*#Right::MouseMove, 10, 0, 0, R ; Win+RightArrow => Move cursor to the right
*<#RCtrl:: ; LeftWin + RightControl => Left-click (hold down Control/Shift to Control-Click or Shift-Click).
SendEvent {Blind}{LButton down}
KeyWait RCtrl ; Prevents keyboard auto-repeat from repeating the mouse click.
SendEvent {Blind}{LButton up}
return
*<#AppsKey:: ; LeftWin + AppsKey => Right-click
SendEvent {Blind}{RButton down}
KeyWait AppsKey ; Prevents keyboard auto-repeat from repeating the mouse click.
SendEvent {Blind}{RButton up}
return
#Persistent ; Keep this script running until the user explicitly exits it.
SetTimer, WatchPOV, 5
return
WatchPOV:
POV := GetKeyState("JoyPOV") ; Get position of the POV control.
KeyToHoldDownPrev := KeyToHoldDown ; Prev now holds the key that was down before (if any).
; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
; To support them all, use a range:
if (POV < 0) ; No angle to report
KeyToHoldDown := ""
else if (POV > 31500) ; 315 to 360 degrees: Forward
KeyToHoldDown := "Up"
else if POV between 0 and 4500 ; 0 to 45 degrees: Forward
KeyToHoldDown := "Up"
else if POV between 4501 and 13500 ; 45 to 135 degrees: Right
KeyToHoldDown := "Right"
else if POV between 13501 and 22500 ; 135 to 225 degrees: Down
KeyToHoldDown := "Down"
else ; 225 to 315 degrees: Left
KeyToHoldDown := "Left"
if (KeyToHoldDown = KeyToHoldDownPrev) ; The correct key is already down (or no key is needed).
return ; Do nothing.
; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1 ; Avoid delays between keystrokes.
if KeyToHoldDownPrev ; There is a previous key to release.
Send, {%KeyToHoldDownPrev% up} ; Release it.
if KeyToHoldDown ; There is a key to press down.
Send, {%KeyToHoldDown% down} ; Press it down.
return
<^>!m::MsgBox You pressed AltGr+m.
<^<!m::MsgBox You pressed LeftControl+LeftAlt+m.
AppsKey::ToolTip Press < or > to cycle through windows.
AppsKey Up::ToolTip
~AppsKey & <::Send !+{Esc}
~AppsKey & >::Send !{Esc}
; Press AppsKey and Alt in any order, then slash (/).
#if GetKeyState("AppsKey", "P")
Alt & /::MsgBox Hotkey activated.
; If the keys are swapped, Alt must be pressed first (use one at a time):
#if GetKeyState("Alt", "P")
AppsKey & /::MsgBox Hotkey activated.
; [ & ] & \::
#if GetKeyState("[") && GetKeyState("]")
\::MsgBox
; Ctrl+Shift+O to open containing folder in Explorer.
; Ctrl+Shift+E to open folder with current file selected.
; Supports SciTE and Notepad++.
^+o::
^+e::
editor_open_folder() {
WinGetTitle, path, A
if RegExMatch(path, "\*?\K(.*)\\[^\\]+(?= [-*] )", path)
if (FileExist(path) && A_ThisHotkey = "^+e")
Run explorer.exe /select`,"%path%"
else
Run explorer.exe "%path1%"
}
#h:: ; Win+H hotkey
; Get the text currently selected. The clipboard is used instead of
; "ControlGet Selected" because it works in a greater variety of editors
; (namely word processors). Save the current clipboard contents to be
; restored later. Although this handles only plain text, it seems better
; than nothing:
AutoTrim Off ; Retain any leading and trailing whitespace on the clipboard.
ClipboardOld := ClipboardAll
Clipboard := "" ; Must start off blank for detection to work.
Send ^c
ClipWait 1
if ErrorLevel ; ClipWait timed out.
return
; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring:
; The same is done for any other characters that might otherwise
; be a problem in raw mode:
StringReplace, Hotstring, Clipboard, ``, ````, All ; Do this replacement first to avoid interfering with the others below.
StringReplace, Hotstring, Hotstring, `r`n, ``r, All ; Using `r works better than `n in MS Word, etc.
StringReplace, Hotstring, Hotstring, `n, ``r, All
StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All
StringReplace, Hotstring, Hotstring, `;, ```;, All
Clipboard := ClipboardOld ; Restore previous contents of clipboard.
; This will move the InputBox's caret to a more friendly position:
SetTimer, MoveCaret, 10
if ErrorLevel ; The user pressed Cancel.
return
if InStr(Hotstring, ":R`:::")
{
MsgBox You didn't provide an abbreviation. The hotstring has not been added.
return
}
; Otherwise, add the hotstring and reload the script:
FileAppend, `n%Hotstring%, %A_ScriptFullPath% ; Put a `n at the beginning in case file lacks a blank line at its end.
Reload
Sleep 200
MsgBox, 4,, The hotstring just added appears to be improperly formatted.
IfMsgBox, Yes, Edit
return
MoveCaret:
IfWinNotActive, New Hotstring
return
; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.
Send {Home}{Right 3}
SetTimer, MoveCaret, Off
return
; This example also demonstrates one way to implement case conformity in a script.
:C:BTW:: ; Typed in all-caps.
:C:Btw:: ; Typed with only the first letter upper-case.
: :btw:: ; Typed in any other combination.
case_conform_btw() {
hs := A_ThisHotkey ; For convenience and in case we're interrupted.
if (hs == ":C:BTW")
Send BY THE WAY
else if (hs == ":C:Btw")
Send By the way
else
Send by the way
}
#IfWinActive ahk_class Notepad
::btw::This replacement text will appear only in Notepad.
#IfWinActive
::btw::This replacement text appears in windows other than Notepad.
#Hotstring EndChars -()[]{}:;'"/\,.?!`n `t
Hotstring("EndChars", "-()[]{}:;")
::btw::
MsgBox You typed "``btw``".
return
:*:]d:: ; This hotstring replaces "]d" with the current date and time via the commands below.
MyFunction(FirstParameter, Second, ByRef Third, Fourth:="")
{
return "a value"
}
Loop 3
MsgBox % MyArray%A_Index%
SysGet, WA, MonitorWorkArea
MsgBox, Left: %WALeft% -- Top: %WATop% -- Right: %WARight% -- Bottom: %WABottom%.
n := 123 00123 -1. 0x7B 0x007B -0x1 3.14159
FileAppend, ; Comment.
; Comment.
( LTrim Join ; Comment.
; This is not a comment; it is literal. Include the word Comments in the line above to make it a comment.
), C:\File.txt ; Comment.
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
Add(X, Y, Z:=0) {
return X + Y + Z
}
Join(sep, params*) {
for index,param in params
str .= param . sep
return SubStr(str, 1, -StrLen(sep))
}
MsgBox % Join("`n", "one", "two", "three")
LogToFile(TextToLog)
{
global LogFileName ; This global variable was previously given a value somewhere outside this function.
FileAppend, %TextToLog%`n, %LogFileName%
}
SetDefaults()
{
global
MyGlobal := 33
local x, y:=0, z
}
LogToFile(TextToLog)
{
static LoggedLines := 0
LoggedLines += 1
global LogFileName
FileAppend, %LoggedLines%: %TextToLog%`n, %LogFileName%
}
GetFromStaticArray(WhichItemNumber)
{
static
static FirstCallToUs := true
if FirstCallToUs
{
FirstCallToUs := false
Loop 10
StaticArray%A_Index% := "Value #" . A_Index
}
return StaticArray%WhichItemNumber%
}
if (ColorName != "" AND not FindColor(ColorName))
MsgBox %ColorName% could not be found.
class baseObject {
static foo := "bar"
}
baseObject := {foo: "bar"}
thing := {}
thing.foo := "bar"
thing.test := Func("thing_test")
thing.test()
thing_test(this) {
MsgBox % this.foo
}
class Color
{
__New(aRGB)
{
this.RGB := aRGB
}
__Delete()
{
MsgBox % "Delete Color."
}
static Shift := {R:16, G:8, B:0}
__Get(aName)
{
; NOTE: Using this.Shift here would cause an infinite loop!
shift := Color.Shift[aName] ; Get the number of bits to shift.
if (shift != "") ; Is it a known property?
return (this.RGB >> shift) & 0xff
; NOTE: Using 'return' here would break this.RGB.
}
__Set(aName, aValue)
{
if ((shift := Color.Shift[aName]) != "")
{
aValue &= 255 ; Truncate it to the proper range.
; Calculate and store the new RGB value.
this.RGB := (aValue << shift) | (this.RGB & ~(0xff << shift))
; 'Return' must be used to indicate a new key-value pair should not be created.
; This also defines what will be stored in the 'x' in 'x := clr[name] := val':
return aValue
}
; NOTE: Using 'return' here would break this.stored_RGB and this.RGB.
}
; Meta-functions can be mixed with properties:
RGB {
get {
; Return it in hex format:
return format("0x{:06x}", this.stored_RGB)
}
set {
return this.stored_RGB := value
}
}
class __Get extends Properties
{
R() {
return (this.RGB >> 16) & 255
}
G() {
return (this.RGB >> 8) & 255
}
B() {
return this.RGB & 255
}
}
Property[] ; Brackets are optional
{
get {
return ...
}
set {
return ... := value
}
}
}
class Properties extends FunctionObject
{
Call(aTarget, aName, aParams*)
{
; If this Properties object contains a definition for this half-property, call it.
if ObjHasKey(this, aName)
return this[aName].Call(aTarget, aParams*)
}
}
MyGet(this, Key, Key2)
MySet(this, Key, Key2, Value)
MyCall(this, Name, Params)
ClassName := { __Get: Func("MyGet"), __Set: Func("MySet"), __Call: Func("MyCall") }
red := new Color(0xff0000), red.R -= 5
cyan := new Color(0), cyan.G := 255, cyan.B := 255
MsgBox % "red: " red.R "," red.G "," red.B " = " red.RGB
MsgBox % "cyan: " cyan.R "," cyan.G "," cyan.B " = " cyan.RGB
; This example requires the FunctionObject class in order to work.
blue := new Color(0x0000ff)
MsgBox % blue.R "," blue.G "," blue.B
x := {base: {addr: Func("x_Addr"), __Set: Func("x_Setter")}}
; Assign value, implicitly calling x_Setter to create sub-objects.
x[1,2,3] := "..."
; Retrieve value and call example method.
MsgBox % x[1,2,3] "`n" x.addr() "`n" x[1].addr() "`n" x[1,2].addr()
x_Setter(x, p1, p2, p3) {
x[p1] := new x.base
}
x_Addr(x) {
return &x
}
InputBox, OutputVar, Question 1, What is your first name?
if (OutputVar = "Bill")
MsgBox, That's an awesome name`, %OutputVar%.
InputBox, OutputVar2, Question 2, Do you like AutoHotkey?
if (OutputVar2 = "yes")
MsgBox, Thank you for answering %OutputVar2%`, %OutputVar%! We will become great friends.
else
MsgBox, %OutputVar%`, That makes me sad.
MsgBox, 4,, Would you like to continue?
IfMsgBox, No
return ; If No, stop the code from going further.
MsgBox, You pressed YES. ; Otherwise, the user picked yes.
if (car = "old")
{
MsgBox, The car is really old.
if (wheels = "flat")
{
MsgBox, This car is not safe to drive.
return
}
else
{
MsgBox, Be careful! This old car will be dangerous to drive.
}
}
else
{
MsgBox, My`, what a shiny new vehicle you have there.
}
if (Color = "Red" or Color = "Green" or Color = "Blue" ; Comment.
or Color = "Black" or Color = "Gray" or Color = "White") ; Comment.
and ProductIsAvailableInColor(Product, Color) ; Comment.
if (codepage != "")
codepage := " /CP" . codepage
cmd="%A_AhkPath%"%codepage% "`%1" `%*
key=AutoHotkeyScript\Shell\Open\Command
if A_IsAdmin ; Set for all users.
RegWrite, REG_SZ, HKCR, %key%,, %cmd%
else ; Set for current user only.
RegWrite, REG_SZ, HKCU, Software\Classes\%key%,, %cmd%
^j:: ; hotkey label
MsgBox, You typed btw.
@@ -0,0 +1,88 @@
createTextField("greet", 0, 0, 0, 100, 100);
greet.text = "Hello, world";
class com.example.Greeter extends MovieClip
{
public function Greeter()
{
var txtHello:TextField = this.createTextField("txtHello", 0, 0, 0, 100, 100);
txtHello.text = "Hello, world";
}
}
var txtHello:TextField = new TextField();
txtHello.text = "Hello World";
this.addChild(txtHello);
package com.example
{
import flash.text.TextField;
import flash.display.Sprite;
public class Greeter extends Sprite
{
public function Greeter()
{
var txtHello:TextField = new TextField();
txtHello.text = "Hello World";
addChild(txtHello);
}
}
}
var myObject:Object = new Object();
var myObject = {};
var myString:String = "Hello Wikipedia!"; // This would automatically set the variable as a string.
var myNumber:Number = 5; // This would do the same for a number.
var myObject:Object = {Param1:"Hi!", Param2:76}; //This creates an object with two variables.
// Param1 is a string with the data of "Hi!",
// and Param2 is a number with the data of 76.
var myArray:Array = [5,"Hello!",{a:5, b:7}]; //This is the syntax for automatically creating an Array.
//It creates an Array with 3 variables.
//The first (0) is a number with the value of 5,
//the second (1) is a string with the value of "Hello!",
//and the third (2) is an object with {a:5, b:7}.
var item1:String="ABC";
var item2:Boolean=true;
var item3:Number=12;
var item4:Array=["a","b","c"];
var item5:Object={name:"Actionscript",version:"3.0"};
var item6:XML = <node><child/></node>; //Note that the primitive XML is not quoted
var item1:XML=new XML("<node><child/></node>");
var item2:XML=item1;
item2.firstChild.attributes.value=13;
//item1 now equals item2 since item2 simply points to what item1 points to.
//Both are now:
//<node><child value="13"/></node>
private function getNeighbours(_arg1:int, _arg2:int):Array{
var _local3:Array = -(((null - !NULL!) % ~(undefined)));
var _local4:*;
var _local5:*;
var _local6:*;
_local3 = new Array();
_local4 = 0;
for (;//unresolved jump
, _arg2 < 8;_local4++) {
_local5 = (_arg1 + int(!NULL!));
_local6 = (_arg2 + int(!NULL!));
if (true){
_arg1 = (((//unresolved nextvalue or nextname << !NULL!) + !NULL!)
<< undefined);
_arg1 = (!(!NULL!) ^ !NULL!);
(!NULL! instanceof !NULL!);
var _local1 = (((!NULL! as !NULL!) + !NULL!) == this);
if (!(!NULL! == !NULL!)){
-((true << !NULL!)).push(Cell(cells[_local5][_local6]));
}
}
if (!true){
(_local6 < 0);
(_local6 < 0);
(_local5 < 0);
}
}
return (_local3);
}
@@ -0,0 +1,78 @@
.MEMORYMAP
SLOTSIZE $8000 ; The slot is $8000 bytes in size. More details on slots later.
DEFAULTSLOT 0 ; There's only 1 slot in SNES, there are more in other consoles.
SLOT 0 $8000 ; Defines Slot 0's starting address.
.ENDME
.SNESHEADER
ID "SNES"
NAME "Test Demo Mode 7 "
; "123456789012345678901"
LOROM
SLOWROM
CARTRIDGETYPE $00
ROMSIZE $09 ;size rom 09-0d
VERSION 00
.ENDSNES
.MACRO Clear_RAM
ldx #$0
ldy #0
-:
sty 0,x
inx
inx
cpx #$2000
bne -
.ENDM
.include "header.asm"
.bank 0 slot 0
.org 0
Main:
sei
clc
xce
rep #$10 ;16 bit xy
sep #$20 ; 8 bit a
.dw $1C02,$1C02,$1C02,$1C02
lda sincos.l + $80,X
sincos2:
.include "DATA/dsincos.asm"
lda #\1&$FF
sta $211B
cmp #$04
bne +++
lda #$04
bra lab
+++:
TMP EQU $6
XY:
BCC MOD7
CPX #3 ; bla bla
BCS MARCH
DEY
MARCH EOR #$7F ; bla bla
JSR MOD7
CPY #200
ADC MTAB-1,X
STA TMP
TYA
SBC TMP
LSR
TYA
STA TMP
MOD7 ADC #7
RTS
CLC
MTAB DB 1,4,23,34,3,12
@@ -0,0 +1,108 @@
;********************************************************************
;* LED flasher: LED will flash with a X on/off ratio at PD6
;*
;* NOTE: delay depends in the value of X, 1 is fast, 255 is slow
;*
;* No copyright ©1998 RES® * FREEWARE *
;*
;* NOTE: Connect a low current LED with a 1k resistor in serie from
;* Vdd to pin 11 of the MCU. (Or a normal LED with a 330ohm)
;*
;* RES® can be reached by email: digitalaudio@mail.com
;* or visit the website: http://home.wanadoo.nl/electro1/avr
;*
;* Version :1.0
;* Date :12/26/98
;* Author :Rob's ElectroSoft®
;* Target MCU :AT90S1200-12PI@4MHz
;********************************************************************
.include "1200def.inc"
rjmp RESET ;reset handle
;* Long delay
;* Register variables
.def T1 = r1
.def T2 = r2
.def temp = r19
;* Code
longDelay:
clr T1 ;T1 used as delay 2nd count
clr T2 ;T2 used as delay 3d count
delay_1:
dec T2
brne delay_1
dec T1
brne delay_1
dec temp ;temp must be preset as
brne delay_1 ; delay master count
ret
;* Resets the data direction register D
;* Defines
.equ led = 6 ;LED at PD6
;* Code
RESET:
sbi DDRD, led ;connect LED to PORTD pin 6
;* Main program
;* This part will let the LED go on and off by X
;* Register variables
.equ X = 10 ;enter delaytime X
flash:
sbi PORTD, led ;LED on
ldi temp, X ;X sec delay
rcall longDelay
cbi PORTD, led ;LED off
ldi temp, X ;X sec delay
rcall longDelay
rjmp flash ;another run
/* other
tests */
.org LARGEBOOTSTART
; the following sets up RAMPZ:Z to point to a FLASH data object, typically
; for use with ELPM.
ldi ZL, low (cmdtable * 2)
ldi ZH, high (cmdtable * 2)
.if ((cmdtable * 2) > 65535)
ldi r16, 1
sts RAMPZ, r16
.endif
; more code follows here
cmdtable: .db "foo", 0x0
.db "Hello\n" // is equivalent to:
.db 'H', 'e', 'l', 'l', 'o', '\\', 'n'
.db '\0', '\177', '\xff'
.db "\nx\rx\ax\bx\fx\tx\vx\\x\0000\xfff\0\1"
0b10_111_2 0xaf3_4 0_12 32_32 $32_3
.macro m
ldi @0, @1
.endm m r16,\ 0
#define TEST \
.IF val \
.DW __TIME__ \
.ELSE \
.DW 1 \
.ENDIF
#defi TEST
@@ -0,0 +1,56 @@
* initialization
n equ 20
start equ $40
wddr equ $0
cddr equ $0
input equ $ffe0
output equ $ffe1
;
org p:start
move #wddr,r0 ;r0 ¬ samples
move #cddr,r4 ;r1 ¬ coefficients
move #n-1,m0 ;set modulo arithmetic
move m0,m4 ;for the 2 circular buffers
;
opt cc
; filter loop :8+(n-1) cycles
movep y:input,x: (r0) ;input sample in memory
clr a x:(r0)+,x0 y: (r4)+,y0
rep #n-1
mac x0,y0,a x:(r0)+,x0 y:(r4)+,y0
macr x0,x0,a (r0)-
movep a,y:output ;output filtered sample
fftr2a macro points,data,coef
fftr2a: ident 1,1
move #points/2,n0 ;initialize butterflies per group
move #1,n2 ;initialize groups per pass
move #points/4,n6 ;initialize C pointer offset
move #-1,m0 ;initialize A and B address modifiers
move m0,m1 ;for linear addressing
move m0,m4
move m0,m5
move #0,m6 ;initialize C address modifier for
;reverse carry (bit-reversed) addressing
do #@cvi (@log(points)/@log(2)+0.5),_end_pass
move #data,r0 ;initialize A input pointer
move r0,r4 ;initialize A output pointer
_end_bfy
move a,x:(r5)+n5 y:(r1)+n1,y1
end_cell
rnd a
movep #0,x:$fffe
dc @sin(@cvf(count)*freq)
move #twiddle,r2
MOVE L:<$1,A
SUB X,A L:<$3,B
bad_label
good_label:
@@ -0,0 +1,516 @@
jmp near dword [0]
jmp far dword [0]
mov bx,ax ; general register to general register
mov [char],al ; general register to memory
mov dl,32 ; immediate value to general register
mov cr3,ebx ; general register to control register
xchg ax,bx ; swap two general registers
xchg al,[char] ; swap register with memory
push ax ; store general register
push es ; store segment register
pushw [bx] ; store memory
push 1000h ; store immediate value
imul ax,[si],10 ; memory by immediate value to register
bt ax,15 ; test bit in register
bts word [bx],15 ; test and set bit in memory
bswap edx ; swap bytes in register
jmp 100h ; direct near jump
jmp 0FFFFh:0 ; direct far jump
jmp ax ; indirect near jump
jmp pword [ebx] ; indirect far jump
movs byte [di],[si] ; transfer byte
movs word [es:di],[ss:si] ; transfer word
movsd ; transfer double word
cmpxchg8b [bx] ; compare and exchange 8 bytes
movq2dq xmm0,mm1 ; move from MMX register to SSE register
movdq2q mm0,xmm1 ; move from SSE register to MMX register
enter 2048,0 ; enter and allocate 2048 bytes on stack
mov [rip+3],sil ; manual RIP-relative addressing
blendvps xmm3,xmm7,xmm0 ; blend according to mask
vgatherqps xmm0,[xmm2],xmm3 ; gather two floats
vgatherqps xmm0,[ymm2+64],xmm3 ; gather four floats
vfmsub231ps ymm1,ymm2,ymm3 ; multiply and subtract
vfnmadd132sd xmm0,xmm5,[ebx] ; multiply, negate and add
vpermil2ps ymm0,ymm3,ymm7,ymm2,0 ; permute from two sources
vscatterdps [eax+xmm1]{k1},xmm0 ; scatter four floats
vscatterdpd [ymm3*8]{k3},zmm0 ; scatter eight doubles
dd sum
x = 1
x = x+2
sum = x
if count>0
mov cx,count
rep movsb
end if
if count & ~ count mod 4
mov cx,count/4
rep movsd
else if count>4
mov cx,count/4
rep movsd
mov cx,count mod 4
rep movsb
else
mov cx,count
rep movsb
end if
repeat 8
mov byte [bx],%
inc bx
end repeat
s = x/2
repeat 100
if x/s = s
break
end if
s = (s+x/s)/2
end repeat
repeat $-$$
load a byte from $$+%-1
store byte a xor c at $$+%-1
end repeat
GDTR dp ?
virtual at GDTR
GDT_limit dw ?
GDT_address dd ?
end virtual
virtual at 0
file 'a.txt':10h,1
load char from 0
end virtual
virtual at 0 as 'asc'
times 256 db %-1
end virtual
virtual at 0
hex_digits::
db '0123456789ABCDEF'
end virtual
load a byte from hex_digits:10
bits = 16
display 'Current offset is 0x'
repeat bits/4
d = '0' + $ shr (bits-%*4) and 0Fh
if d > '9'
d = d + 'A'-'9'-1
end if
display d
end repeat
display 13,10
if ~ defined alpha
alpha:
end if
if ~ defined alpha | defined @f
alpha:
@@:
end if
include 'macros.inc'
d equ dword
NULL equ d 0
d equ edx
d equ d,eax
b equ byte
w equ word
d equ dword
p equ pword
f equ fword
q equ qword
t equ tword
x equ dqword
y equ qqword
incl fix include
macro tst {test al,0xFF}
macro stos0
{
xor al,al
stosb
}
macro align value { rb (value-1)-($+value-1) mod value }
macro mov op1,op2
{
if op1 in <ds,es,fs,gs,ss> & op2 in <cs,ds,es,fs,gs,ss>
push op2
pop op1
else
mov op1,op2
end if
}
macro stoschar [char]
{
mov al,char
stosb
}
macro movstr
{
local move
move:
lodsb
stosb
test al,al
jnz move
}
macro strtbl name,[string]
{
common
label name dword
forward
local label
dd label
forward
label db string,0
}
push 3
push 2
push 1
call foo
macro invoke proc,[arg]
{ common stdcall [proc],arg }
macro jif op1,cond,op2,label
{
cmp op1,op2
j#cond label
}
macro label name
{
label name
if ~ used name
display `name # " is defined but not used.",13,10
end if
}
macro message arg
{
if arg eqtype ""
local str
jmp @f
str db arg,0Dh,0Ah,24h
@@:
mov dx,str
else
mov dx,arg
end if
mov ah,9
int 21h
}
macro ext instr
{
macro instr op1,op2,op3
\{
if op3 eq
instr op1,op2
else
instr op1,op2
instr op2,op3
end if
\}
}
ext add
ext sub
macro tmacro [params]
{
common macro params {
}
MACRO fix tmacro
ENDM fix }
MACRO stoschar char
mov al,char
stosb
ENDM
postpone
{
code_size = $
}
struc point x,y
{
.x dw x
.y dw y
}
struc db [data]
{
common
. db data
.size = $ - .
}
rept 5 { in al,dx }
rept 3 counter
{
byte#counter db counter
}
match +,+ { include 'first.inc' }
match +,- { include 'second.inc' }
match a b, 1+2+3 { db a }
V fix {
macro empty
V
V fix }
V
list equ
macro append item
{
match any, list \{ list equ list,item \}
match , list \{ list equ item \}
}
define a b+4
define b 3
rept 1 result:a*b+2 { define c result }
rept 8 n:0 { pxor xmm#n,xmm#n }
irps reg, al bx ecx
{ xor reg,reg }
if 0
a = 1
b equ 2
end if
dd b
extrn exit
extrn '__imp__MessageBoxA@16' as MessageBox:dword
extrn 'printf' as _printf
printf = PLT _printf
tester? = 0
space:
space.x = 1
space.y = 2
space.color:
space.color.r = 0
space.color.g = 0
space.color.b = 0
space:
namespace space
x = 1
y = 2
color:
.r = 0
.g = 0
.b = 0
end namespace
first:
.child = 1
..other = 0
second:
.child = 2
..another = ..other
label character:byte
label char:1
byte? = 1 ; 8 bits
word? = 2 ; 16 bits
dword? = 4 ; 32 bits
fword? = 6 ; 48 bits
pword? = 6 ; 48 bits
qword? = 8 ; 64 bits
tbyte? = 10 ; 80 bits
tword? = 10 ; 80 bits
dqword? = 16 ; 128 bits
xword? = 16 ; 128 bits
qqword? = 32 ; 256 bits
yword? = 32 ; 256 bits
dqqword? = 64 ; 512 bits
zword? = 64 ; 512 bits
element A
linpoly = A + A + 3
vterm = linpoly scale 1 * linpoly element 1 ; vterm = 2 * A
db 4 dup 90h ; generate 4 bytes
db 2 dup ('abc',10) ; generate 8 bytes
macro measured name,string
local top
name db string
top: name.length = top - name
end macro
measured hello, 'Hello!' ; hello.length = 6
A equ 1
A equ 2
drop A
drop A
data1 dw 1
buffer1 rb 10h ; zeroed and present in the output
org 400h
data dw 2
buffer2 rb 20h ; not in the output
section 1000h
data3 dw 3
buffer3 rb 30h ; not in the output
virtual at 0
hex_digits::
db '0123456789ABCDEF'
end virtual
load a:byte from hex_digits:10 ; a = 'A'
db "Text"
key = 7Bh
repeat $-$$
load a : byte from $$+%-1
store a xor key : byte at $$+%-1
end repeat
load char : byte from const:0
if $>10000h
err 'segment too large'
end if
calminstruction please? cmd&
match =do? =not? cmd, cmd
jyes done
assemble cmd
done:
end calminstruction
please do not display 'Bye!'
macro jmpi target
if target-($+2) < 80h & target-($+2) >= -80h
db 0EBh
db target-($+1)
else
db 0E9h
dw target-($+2)
end if
end macro
macro EX? first,second
match (=SP?), first
match =HL?, second
db 0E3h
else match =IX?, second
db 0DDh,0E3h
else match =IY?, second
db 0FDh,0E3h
else
err "incorrect second argument"
end match
else match =AF?, first
match =AF'?, second
db 08h
else
err "incorrect second argument"
end match
else match =DE?, first
match =HL?, second
db 0EBh
else
err "incorrect second argument"
end match
else
err "incorrect first argument"
end match
end macro
EX (SP),HL
macro INC? argument
match [:r:], argument
db 100b + r shl 3
else match (=HL?), argument
db 34h
else match (=IX?+d), argument
db 0DDh,34h,d
else match (=IY?+d), argument
db 0FDh,34h,d
else
err "incorrect argument"
end match
end macro
INC (IX+2)
element IY?
element L? : register + 101b
macro CALL? arguments&
local cc,nn
match condition =, target, arguments
cc = condition - CC
nn = target
db 0C4h + cc shl 3
else
nn = arguments
db 0CDh
end match
dw nn
end macro
@@ -0,0 +1,87 @@
map_collision_rom:
dc.b 0,0,7,7
hud_tile:
dc.w $6268,$6269,$6268,$6269
MAP_DATA1 macro
dc.w $4200+\2+(\1*$400),$4200+\2+2+(\1*$400)
move.w \2,Sprite+0+(8*\1)
endm
move.w MarioArmy+0+6*\2,d0
move.w #$050B+2*\2,d1
cmp.w #15,MarioAnim
if_mi
addi.w #$0800,d2
endi
if_eq
andi.w #$01,d5
cmp.w #$1,d5
if_ne
move.w #$200,d0
endi
endi
Draw_Sprite 0,Selecty,#$0501,SelectTile,Selectx
move.w #$0030,d6
cmp.w #0,SelectChoix
;Mario3 Menu
Draw_Sprite 4,#$80+28,#$0505,d4,#$80+8*9
move.w #1,d1
lea EnemyArmyDgt,a0
lea EnemyArmy,a1
move.w #9,d0
move.w d4,d2
subi.w #$80,d2
lsr.w #4,d2
move.w d3,d7
subi.w #$C0,d7
asr.w #4,d7
asl.w #4,d7
move.l a1,a2
move.w #0,(a2)+
move.w #$0,(a0) ;remove de l'écran
move.l a1,a2
move.w Selectx,(a2)+
move.w #$1,(a3) ;est a l'écran
add.w #$6,a3
org $000000
dc.l $0,Main
dc.l INT,INT,INT,INT,INT,INT,INT
dc.b ' 00000000-00' ; Product code, version nu
mber. 12 bytes long
dc.w $FDDB ; Checksum. 2 bytes long
dc.b 'J ' ; I/O support. 16 bytes
dc.l $00000000,$00020000
do
move.l (a2)+,VDP_DATA
while_dbra d0
if_ne macro
bne L1\@!
endm
_A = 12
VDP_Port_VRAMW #$A000+(2*\2)+($40*\3)
lea \1,a2
move.w #3,d7
VDP_DATA equ $C00000
VDP_CTRL equ $C00004
@@ -0,0 +1 @@
Motorola 68k (VASM/Devpac)
@@ -0,0 +1,34 @@
# A demonstration of some simple MIPS instructions
# used to test QtSPIM
# Declare main as a global function
.globl main
# All program code is placed after the
# .text assembler directive
.text
# The label 'main' represents the starting point
main:
li $t2, 25 # Load immediate value (25)
lw $t3, value # Load the word stored in value (see bottom)
add $t4, $t2, $t3 # Add
sub $t5, $t2, $t3 # Subtract
sw $t5, Z #Store the answer in Z (declared at the bottom)
# Exit the program by means of a syscall.
# There are many syscalls - pick the desired one
# by placing its code in $v0. The code for exit is "10"
li $v0, 10 # Sets $v0 to "10" to select exit syscall
syscall # Exit
# All memory structures are placed after the
# .data assembler directive
.data
# The .word assembler directive reserves space
# in memory for a single 4-byte word (or multiple 4-byte words)
# and assigns that memory location an initial value
# (or a comma separated list of initial values)
value: .word 12
Z: .word 0
@@ -0,0 +1,523 @@
; Example file for nasm.xml kate syntax file
; compile with `nasm example.asm -f elf -o example.o`
; and link with 'gcc example.o -o example`
; Public domain
; kate: hl Intel x86 (NASM);
section .data
hello dd 'Hello World', 0x0A, 0h
printf_param dd '%s', 0q
section .text
extern printf
global main
main:
push ebp
mov ebp, esp
push hello
push printf_param
call printf
mov eax, 0b
leave
ret
NULL EQU 0 ; Constants
STD_OUTPUT_HANDLE EQU -11
extern GetStdHandle ; Import external symbols
global Start ; Export symbols. The entry point
section .data ; Initialized data segment
Message db "Console Message 64", 0Dh, 0Ah
MessageLength EQU $-Message ; Address of this line ($) - address of Message
section .bss ; Uninitialized data segment
alignb 8
Written resq 1
section .text ; Code segment
Start:
sub RSP, 8 ; Align the stack to a multiple of 16 bytes
mov ECX, STD_OUTPUT_HANDLE
call GetStdHandle
mov qword [REL StandardHandle], RAX
sub RSP, 32 + 8 + 8 ; Shadow space + 5th parameter + align stack
; to a multiple of 16 bytes
mov RCX, qword [REL StandardHandle] ; 1st parameter
lea RDX, [REL Message] ; 2nd parameter
mov R8, MessageLength ; 3rd parameter
mov qword [RSP + 4 * 8], NULL ; 5th parameter
; Message Box, 64 bit. V1.02
.DisplayMessageBox:
xor ECX, ECX ; 1st parameter
lea RDX, [REL MessageBoxText] ; 2nd parameter
lea R8, [REL MessageBoxCaption] ; 3rd parameter
mov R9D, MB_YESNO | MB_DEFBUTTON2 ; 4th parameter. 2 constants ORed together
call MessageBoxA
cmp RAX, IDNO ; Check the return value for "No"
je .DisplayMessageBox
extern _GetStdHandle@4 ; Import external symbols
Start:
call _WriteFile@20
section .data ; Initialized data segment
Static1Colour dd 0F0F0F0h,
Edit2 resq 1
%define Screen.Width RBP - 160 ; 4 bytes
%define ClientArea RBP - 152 ; RECT structure. 16 bytes
mov dword [wc.cbSize], 80 ; [RBP - 136]
mov dword [wc.style], CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW ; [RBP - 132]
mov qword [wc.lpfnWndProc], RAX ; [RBP - 128]
mov qword [wc.hIcon], RAX ; [RBP - 104]
mov dword [RSP + 4 * 8], EAX ; X position, now centred
cmp qword [uMsg], WM_CLOSE ; [RBP + 24]
je WMCLOSE
call DestroyWindow ; Send a WM_DESTROY message
jmp Return.WM_Processed
mov EDX, 0604060h
call SetBkColor
mov EDX, 0005000h
db 0x55 ; just the byte 0x55
db 0x55,0x56,0x57 ; three bytes in succession
db 'a',0x55 ; character constants are OK
db 'hello',13,10,'$' ; so are string constants
dw 0x1234 ; 0x34 0x12
dw 'a' ; 0x61 0x00 (it's just a number)
dw 'ab' ; 0x61 0x62 (character constant)
dw 'abc' ; 0x61 0x62 0x63 0x00 (string)
dd 0x12345678 ; 0x78 0x56 0x34 0x12
dd 1.234567e20 ; floating-point constant
dq 0x123456789abcdef0 ; eight byte constant
dq 1.234567e20 ; double-precision float
dt 1.234567e20 ; extended-precision float
db 33
db (44) ; Integer expression
; db (44,55) ; Invalid - error
db %(44,55)
db %('XX','YY')
db ('AA') ; Integer expression - outputs single byte
db %('BB') ; List, containing a string
db ?
db 6 dup (33)
db 6 dup (33, 34)
db 6 dup (33, 34), 35
db 7 dup (99)
db 7 dup dword (?, word ?, ?)
dw byte (?,44)
dw 3 dup (0xcc, 4 dup byte ('PQR'), ?), 0xabcd
dd 16 dup (0xaaaa, ?, 0xbbbbbb)
dd 64 dup (?)
db `\u263a` ; UTF-8 smiley face
db `\xe2\x98\xba` ; UTF-8 smiley face
db 0E2h, 098h, 0BAh ; UTF-8 smiley face
buffer: resb 64 ; reserve 64 bytes
wordvar: resw 1 ; reserve a word
buffer: db 64 dup (?) ; reserve 64 bytes
wordvar: dw ? ; reserve a word
incbin "file.dat" ; include the whole file
incbin "file.dat",1024 ; skip the first 1024 bytes
incbin "file.dat",1024,512 ; skip the first 1024, and
; actually include at most 512
message db 'hello, world'
msglen equ $-message
buffer: db 'hello, world'
times 64-$+buffer db ' '
bndstx [rbx*1+rax+0x3], bnd0 ; GAS - '*1' indecates an index reg
VDIVPS zmm4, zmm5, dword [rbx]{1to16} ; single-precision float
VDIVPS zmm4, zmm5, zword [rbx] ; packed 512 bit memory
mov ax,200 ; decimal
mov ax,0200 ; still decimal
mov ax,0200d ; explicitly decimal
mov ax,0d200 ; also decimal
mov ax,0c8h ; hex
mov ax,$0c8 ; hex again: the 0 is required
mov ax,0xc8 ; hex yet again
mov ax,0hc8 ; still hex
mov ax,310q ; octal
mov ax,310o ; octal again
mov ax,0o310 ; octal yet again
mov ax,0q310 ; octal yet again
mov ax,11001000b ; binary
mov ax,1100_1000b ; same binary constant
mov ax,1100_1000y ; same binary constant once more
mov ax,0b1100_1000 ; same binary constant yet again
mov ax,0y1100_1000 ; same binary constant yet again
%define u(x) __?utf16?__(x)
%define w(x) __?utf32?__(x)
dw u('C:\WINDOWS'), 0 ; Pathname in UTF-16
dd w(`A + B = \u206a`), 0 ; String in UTF-32
db -0.2 ; "Quarter precision"
dw -0.5 ; IEEE 754r/SSE5 half precision
dd 1.2 ; an easy one
dd 1.222_222_222 ; underscores are permitted
dd 0x1p+2 ; 1.0x2^2 = 4.0
dq 0x1p+32 ; 1.0x2^32 = 4 294 967 296.0
dq 1.e10 ; 10 000 000 000.0
dq 1.e+10 ; synonymous with 1.e10
dq 1.e-10 ; 0.000 000 000 1
dt 3.141592653589793238462 ; pi
do 1.e+4000 ; IEEE 754r quad precision
mov rax,__?float64?__(3.141592653589793238462)
mov rax,0x400921fb54442d18
%define Inf __?Infinity?__
%define NaN __?QNaN?__
dq +1.5, -Inf, NaN ; Double-precision constants
dt 12_345_678_901_245_678p
dt -12_345_678_901_245_678p
dt +0p33
dt 33p
dq b * (a // b) + (a %% b)
call (seg procedure):procedure
call weird_seg:(procedure wrt weird_seg)
push dword 33
push strict dword 33
times (label-$) db 0
label: db 'Where am I?'
times (label-$+1) db 0
label: db 'NOW where am I?'
label1 ; some code
.loop
; some more code
jne .loop
ret
label1: ; a non-local label
.local: ; this is really label1.local
..@foo: ; this is a special symbol
label2: ; another non-local label
.local: ; this is really label2.local
jmp ..@foo ; this will jump three lines up
%define THIS_VERY_LONG_MACRO_NAME_IS_DEFINED_TO \
THIS_VALUE
%define ctrl 0x1F &
%define param(a,b) ((a)+(a)*(b))
mov byte [param(2,ebx)], ctrl 'D'
mov byte [(2)+(2)*(ebx)], 0x1F & 'D'
%define a(x) 1+b(x)
%define b(x) 2*x
mov ax,a(8)
%define foo (a,b) ; no arguments, (a,b) is the expansion
%define bar(a,b) ; two arguments, empty expansion
%define ereg(foo,) e %+ foo
mov eax,ereg(dx,cx)
%define xyzzy(=expr,&val) expr, str
%define plugh(x) xyzzy(x,x)
db plugh(3+5), `\0` ; Expands to: db 8, "3+5", `\0`
mov ax,Foo%[__?BITS?__] ; The Foo value
%xdefine Bar Quux ; Expands due to %xdefine
%define Bar %[Quux] ; Expands due to %[...]
%define BDASTART 400h ; Start of BIOS data area
struc tBIOSDA ; its structure
.COM1addr RESW 1
.COM2addr RESW 1
; ..and so on
endstruc
mov ax,BDASTART + tBIOSDA.COM1addr
mov bx,BDASTART + tBIOSDA.COM2addr
; Macro to access BIOS variables by their names (from tBDA):
%idefine Foo mov %?,%??
%idefine keyword $%?
%idefine pause $%? ; Hide the PAUSE instruction
%define foo bar
%undef foo
mov eax, foo
%assign i i+1
%defstr test TEST
%define test 'TEST'
%defstr PATH %!PATH ; The operating system PATH variable
%deftok test 'TEST'
%define test TEST
%define greedy(a,b,c+) a + 66 %, b * 3 %, c
db greedy(1,2) ; db 1 + 66, 2 * 3
db greedy(1,2,3) ; db 1 + 66, 2 * 3, 3
db greedy(1,2,3,4) ; db 1 + 66, 2 * 3, 3, 4
db greedy(1,2,3,4,5) ; db 1 + 66, 2 * 3, 3, 4, 5
%macro silly 2
%2: db %1
%endmacro
silly 'a', letter_a ; letter_a: db 'a'
silly 'ab', string_ab ; string_ab: db 'ab'
silly {13,10}, crlf ; crlf: db 13,10
%pragma preproc sane_empty_expansion
%macro mpar 1-*
db %{3:5}
db %{-1:-3}
%endmacro
mpar 1,2,3,4,5,6
%macro die 0-1 "Painful program death has occurred."
writefile 2,%1
mov ax,0x4c01
int 0x21
%endmacro
%macro multipush 1-*
%rep %0
push %1
%rotate 1
%endrep
j%-1 %%skip
ret
%%skip:
%endmacro
%macro foo 1.nolist
%endmacro
%macro pushparam 1
%ifidni %1,ip
call %%label
%%label:
%else
push %1
%endif
%endmacro
%assign i 0
%rep 64
inc word [table+2*i]
%assign i i+1
%endrep
fibonacci:
%assign i 0
%assign j 1
%rep 100
%if j > 65535
%exitrep
%endif
dw j
%assign k j+i
%assign i j
%assign j k
%endrep
fib_number equ ($-fibonacci)/2
%include "macros.mac"
%ifndef MACROS_MAC
%define MACROS_MAC
; now define some macros
%endif
%pathsearch MyFoo "foo.bin"
%imacro incbin 1-2+ 0
%pathsearch dep %1
%depend dep
incbin dep,%2
%endmacro
%use altreg
%use 'altreg'
%push foobar
%macro repeat 0
%push repeat
%$begin:
%endmacro
%macro until 1
j%-1 %$begin
%pop
%endmacro
%define %$localmac 3
%macro else 0
%ifctx if
%repl else
jmp %$ifend
%$ifnot:
%else
%error "expected `if' before `else'"
%endif
%endmacro
%macro endif 0
%ifctx if
%$ifnot:
%pop
%elifctx else
%$ifend:
%pop
%else
%error "expected `if' or `else' before `endif'"
%endif
%endmacro
some_function:
%push mycontext ; save the current context
%stacksize small ; tell NASM to use bp
%assign %$localsize 0 ; see text for explanation
%local old_ax:word, old_dx:word
enter %$localsize,0 ; see text for explanation
mov [old_ax],ax ; swap ax & bx
mov cx,[old_dx]
leave ; restore old bp
ret ;
%pop ; restore original context
%ifdef F1
; do some setup
%elifdef F2
; do some different setup
%else
%error "Neither F1 nor F2 was defined."
%endif
%ifdef F1
; do some setup
%elifdef F2
; do some different setup
%else
%warning "Neither F1 nor F2 was defined, assuming F1."
%define F1
%endif%if foo > 64
%assign foo_over foo-64
%error foo is foo_over bytes too large
%endif
db __?NASM_VER?__
struc mytype
mt_long: resd 1
.str: resb 32
endstruc
%use altreg
%macro writefile 2+
[section .data]
%%str: db %2
%%endstr:
__?SECT?__
mov dx,%%str
mov cx,%%endstr-%%str
mov bx,%1
mov ah,0x40
int 0x21
%endmacro
DEFAULT BND
call foo ; BND will be prefixed
nobnd call foo ; BND will NOT be prefixed
global _main
_main:
global hashlookup:function, hashtable:data
common intvar 4
static foo
foo:
; codes
%pragma macho lprefix L_
; The most common conventions
%pragma output gprefix _
%pragma output lprefix L_
; ELF uses a different convention
%pragma elf gprefix ; empty
%pragma elf lprefix .L
section .pdata rdata align=4
dd main wrt ..imagebase
dd main_end wrt ..imagebase
dd xmain wrt ..imagebase
section .xdata rdata align=8
xmain: db 9,0,0,0
dd handler wrt ..imagebase
section .drectve info
db '/defaultlib:user32.lib /defaultlib:msvcrt.lib '
@@ -0,0 +1,60 @@
; Blank line
loop sleep ; Label and operation
incf 6,1 ; Operation with 2 parameters
goto loop ; Operation with 1 parameter
#define X Y
#defin ; incomplete
#undefine X
number equ 5
label_#v((number + 1) * 5)_suffix equ 0x10
db .34,O'35',O'93',0xAf,0xady,a'a',a'ap,A'\'
any macro parm
movlw parm
endm
any 33
; Shift reg left
slf macro reg
clrc
rlf reg,f
endm
; Scale W by “factor”. Result in “reg”, W unchanged.
scale macro reg, factor
if (factor == 1)
movwf reg ; 1 X is easy
else
scale reg, (factor / 2) ; W * (factor / 2)
slf reg,f ; double reg
if ((factor & 1) == 1) ; if lo-bit set ..
addwf reg,f ; .. add W to reg
endif
endif
endm
scale tmp,D'10'
movwf tmp
clrc
rlf tmp,f
addwf tmp,f
spin macro n
movlw n
addlw 0xff
btfss STATUS,Z
goto $-2
endm
LOOP: BTFSS flag,0x00
GOTO LOOP
BTFSS flag,0x00
GOTO $ - 1
@@ -0,0 +1,35 @@
-- comment with FIXME alerts
-- example code taken from https://en.wikipedia.org/wiki/ASN.1
FooProtocol DEFINITIONS ::= BEGIN
/** Multiline comment
* with ### alerts
*/
FooQuestion ::= SEQUENCE {
trackingNumber INTEGER(0..199),
question IA5String
}
FooAnswer ::= SEQUENCE {
questionNumber INTEGER(10..20),
answer BOOLEAN
}
FooHistory ::= SEQUENCE {
questions SEQUENCE(SIZE(0..10)) OF FooQuestion,
answers SEQUENCE(SIZE(1..10)) OF FooAnswer,
anArray SEQUENCE(SIZE(100)) OF INTEGER(0..1000)
}
END
-- exmaples from ERA FCB barcode.asn
ASN-Module DEFINITIONS AUTOMATIC TAGS ::= BEGIN
IssuingData ::= SEQUENCE {
-- [...]
-- currency of the price: ISO4217 currency codes
currency IA5String (SIZE(3)) DEFAULT "EUR"
-- [...]
}
END
@@ -0,0 +1,58 @@
<% 'kate: hl ASP;
if ( instr(request.servervariables("PATH_INFO"),"login.asp") <= 0 and instr(request.servervariables("PATH_INFO"),"inset") <= 0 and instr(request.servervariables("PATH_INFO"),"Data") <= 0 and instr(request.servervariables("PATH_INFO"),"dropDown") <= 0 ) then
Session("originalRequestedPage") = Request.ServerVariables("PATH_INFO") & "?" & Request.ServerVariables("QUERY_STRING")
end if
function countRecords( rsToCount )
numRecs = 0
do until rsToCount.eof
numRecs = numRecs + 1
rsToCount.movenext
loop
rsToCount.close ' just to make sure nobody
' tries to operate on the recordset,
' which has already reached eof
countRecords = numRecs
end function
function unique( rs, sortColumn ) ' return unique instances of text in sortColumn within rs
dim sorted()
redim sorted(1)
dim i
i = 0
do until rs.eof
if (not find( rs(sortColumn), sorted )) then
redim preserve sorted(i+1)
sorted(i) = rs(sortColumn)
i = i + 1
end if
rs.MoveNext
loop
redim preserve sorted(i-1) ' the function will add an extra blank entry to the array
rs.Close ' close the recordset - we'll be using it again - and reset i - well be using it again, too
unique = sorted
end function
sub testSub( variable ) ' do nothing impressive...
dim newVar
newVar = variable
if ( variable = true )
response.end
else %>
<p>We are writing text.</p>
<p class="stuff"><%=newVar%></p>
<p>We have written text and outputted a variable.</p>
<% end if
end sub %>
@@ -0,0 +1,52 @@
#!/usr
# AWK hl test
# BEGIN and END are also matched as patterns
BEGIN {
p = 0;
}
/some pattern/ {
p++;
}
# / inside brackets is not considered end of expression
# a loose division operator (/) is not mismatched as a pattern.
$1 =~ /[^abc/]def/ || b == 3 / 5 {
gsub ( FILENAME );
}
# TODO and FIXME also work in comments in Awk.
# Also backslash in patterns works.
/\/usr\/bin\/awk/ { print "This is me"; }
END {
print p;
}
function myfunc()
{
print 42
}
/abc/,/a[b]c/{
# parameter with a regex
if (match($0, /a/)) {}
"x\ax\nx\ex\zx\023x\2x\xffx\xFf\xax\12x"
a =~ /[[:alpha:]]/
a =~ /[xx[:alpha:]xx]/
a =~ /[a-z[:alpha:]xx-]/
a =~ /[]a]/
a =~ /[-a]/
a =~ /[^]a]/
a =~ /[^-a]/
a =~ /[a]a\/\n/
# incomplete regex
a =~ /[xx[:alph
a = 23.2
}
@@ -0,0 +1,31 @@
% test file for kate's bibtex syntax highlighting
@Article{artikel,
author = {Me},
title = {Something},
journal = {JHEP},
year = {2003},
}
@Book
{
boek,
author = "Someone",
title = "Something",
journal = "Nucl. Phys. B",
year = "2003",
}
This is ignored by BibTeX, no special highlighting
%This is not a comment, it is just ignored (thanks to the people in #latex) :)
@string{test="lange string die ik niet vaak opnieuw wil intikken"}
@PhdThesis{thesis,
author = {Me},
title = {Dunno},
school = {ITFA},
year = {2005, hopefully},
}
@@ -0,0 +1,37 @@
"""module docstring"""
namespace My.NameSpace #optional namespace declaration
import Assembly.Reference #import statements
#followed by the Members of this module (classes, methods, etc.)
class MyClass:
pass
def domyfunction(it):
print(it)
#start "main" section that is executed when script is run
x as int
x = 3
domyfunction(x)
#optional assembly attribute declarations used when compiling
[assembly: AssemblyTitle('foo')]
[assembly: AssemblyDescription('bar')]
import MyLibrary
print (Version)
doit()
[Module]
class MainClass:
public static Version as string
static def constructor():
Version = "0.1"
def doit():
#you can refer to "globals" from within your library, too:
print("This library's version is: "+MainClass.Version)
@@ -0,0 +1,31 @@
Thread 1 "lab_dialog" received signal SIGSEGV, Segmentation fault.
0x000055555555a279 in Ui_Window::setupUi (this=0x0, Window=0x7fffffffc350) at ./ui_window.h:56
56 centralwidget = new QWidget(Window);
[Current thread is 1 (Thread 0x7ffff7edd840 (LWP 7267))]
Thread 3 (Thread 0x7fffe035e700 (LWP 2289)):
#0 0x00007ffff565697b in poll () from /usr/lib/libc.so.6
#1 0x00007ffff3a29613 in ?? () from /usr/lib/libglib-2.0.so.0
#2 0x00007ffff3a2972e in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3 0x00007ffff69ae241 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#4 0x00007ffff695032b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQt5Core.so.5
#5 0x00007ffff675f72e in QThread::exec() () from /usr/lib/libQt5Core.so.5
#6 0x00007fffeed1d416 in ?? () from /usr/lib/libQt5DBus.so.5
#7 0x00007ffff6764acd in ?? () from /usr/lib/libQt5Core.so.5
#8 0x00007ffff621308c in start_thread () from /usr/lib/libpthread.so.0
#9 0x00007ffff5660e7f in clone () from /usr/lib/libc.so.6
Thread 2 (Thread 0x7fffebd8a700 (LWP 2287)):
#0 0x00007ffff565697b in poll () from /usr/lib/libc.so.6
#1 0x00007ffff011a180 in ?? () from /usr/lib/libxcb.so.1
#2 0x00007ffff011be4b in xcb_wait_for_event () from /usr/lib/libxcb.so.1
#3 0x00007fffef21382a in ?? () from /usr/lib/libQt5XcbQpa.so.5
#4 0x00007ffff6764acd in ?? () from /usr/lib/libQt5Core.so.5
#5 0x00007ffff621308c in start_thread () from /usr/lib/libpthread.so.0
#6 0x00007ffff5660e7f in clone () from /usr/lib/libc.so.6
Thread 1 (Thread 0x7ffff7f80cc0 (LWP 2283)):
#0 0x000055555555a279 in Ui_Window::setupUi (this=0x0, Window=0x7fffffffc350) at ./ui_window.h:56
#1 0x0000555555558ea2 in Window::Window (this=0x7fffffffc350, parent=0x0) at ../window.cpp:22
#2 0x0000555555558b85 in main (argc=1, argv=0x7fffffffc498) at ../main.cpp:20
@@ -0,0 +1,54 @@
name: Foo
version: 1.0
if(os(darwin))
optimization: False
elif(os(freebsd))
packages: freebsd/*.cabal
else
optimization: True
import: https://some.remote.source/subdir/cabal.config
import: relativepath/extra-project.project
-- bla bla
import: /absolutepath/some-project.project
tested-with: GHC == 9.0.1
, GHC == 8.10.4 -- bla bla
, GHC == 8.8.4
tested-with:
GHC == 9.0.1
GHC == 8.10.4
tested-with: GHC == { 9.0.1, 8.10.4, 8.8.4 }
library attoparsec
build-depends:
, base ^>= 4.11.1.0
, bytestring ^>= 0.10.2.0
cabal-version: 3.0
name: haddock-library
version: 1.6.0
license: BSD-3-Clause
test-suite foo
type: exitcode-stdio-1.0
-- bla bla
library
build-depends:
, base ^>= 4.11.1.0
, containers ^>= 0.4.2.1 || ^>= 0.5.0.0
library
default-language: Haskell2010
build-depends: base >= 4 && < 5
exposed-modules: Foo
extensions: ForeignFunctionInterface
ghc-options: -Wall
if os(windows)
build-depends: Win32 >= 2.1 && < 2.6
@@ -0,0 +1,112 @@
*> These are equivalent.
INVOKE my-class "foo" RETURNING var
MOVE my-class::"foo" TO var *> Inline method invocation
ADD 1 TO x
ADD 1, a, b TO x ROUNDED, y, z ROUNDED
ADD a, b TO c
ON SIZE ERROR
DISPLAY "Error"
END-ADD
ADD a TO b
NOT SIZE ERROR
DISPLAY "No error"
ON SIZE ERROR
DISPLAY "Error"
RD sales-report
PAGE LIMITS 60 LINES
FIRST DETAIL 3
CONTROLS seller-name.
01 TYPE PAGE HEADING.
03 COL 1 VALUE "Sales Report".
03 COL 74 VALUE "Page".
03 COL 79 PIC Z9 SOURCE PAGE-COUNTER.
01 sales-on-day TYPE DETAIL, LINE + 1.
03 COL 3 VALUE "Sales on".
03 COL 12 PIC 99/99/9999 SOURCE sales-date.
03 COL 21 VALUE "were".
03 COL 26 PIC $$$$9.99 SOURCE sales-amount.
01 invalid-sales TYPE DETAIL, LINE + 1.
03 COL 3 VALUE "INVALID RECORD:".
03 COL 19 PIC X(34) SOURCE sales-record.
01 TYPE CONTROL HEADING seller-name, LINE + 2.
03 COL 1 VALUE "Seller:".
03 COL 9 PIC X(30) SOURCE seller-name.
PIC 99.
PIC 9(7)V99.
PIC 9(10). *> sads
PIC 9(5)V9(2).
PIC 9(5)
PIC +++++
PIC 99/99/9(4)
PIC *(4)9.99
PIC X(3)BX(3)BX(3)
OPEN INPUT sales, OUTPUT report-out
INITIATE sales-report
PERFORM UNTIL 1 <> 1
READ sales
AT END
EXIT PERFORM
END-READ
VALIDATE sales-record
IF valid-record
GENERATE sales-on-day
ELSE
GENERATE invalid-sales
END-IF
END-PERFORM
TERMINATE sales-report
CLOSE sales, report-out
EVALUATE TRUE ALSO desired-speed ALSO current-speed
WHEN lid-closed ALSO min-speed THRU max-speed ALSO LESS THAN desired-speed
PERFORM speed-up-machine
WHEN lid-closed ALSO min-speed THRU max-speed ALSO GREATER THAN desired-speed
PERFORM slow-down-machine
WHEN lid-open ALSO ANY ALSO NOT ZERO
PERFORM emergency-stop
WHEN OTHER
CONTINUE
END-EVALUATE
//COBUCLG JOB (001),'COBOL BASE TEST', 00010000
// CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1) 00020000
//BASETEST EXEC COBUCLG 00030000
//COB.SYSIN DD * 00040000
00000* VALIDATION OF BASE COBOL INSTALL 00050000
01000 IDENTIFICATION DIVISION. 00060000
01100 PROGRAM-ID. 'HELLO'. 00070000
02000 ENVIRONMENT DIVISION. 00080000
02100 CONFIGURATION SECTION. 00090000
02110 SOURCE-COMPUTER. GNULINUX. 00100000
02120 OBJECT-COMPUTER. HERCULES. 00110000
02200 SPECIAL-NAMES. 00120000
02210 CONSOLE IS CONSL. 00130000
03000 DATA DIVISION. 00140000
04000 PROCEDURE DIVISION. 00150000
04100 00-MAIN. 00160000
04110 DISPLAY 'HELLO, WORLD' UPON CONSL. 00170000
04900 STOP RUN. 00180000
//LKED.SYSLIB DD DSNAME=SYS1.COBLIB,DISP=SHR 00190000
// DD DSNAME=SYS1.LINKLIB,DISP=SHR 00200000
//GO.SYSPRINT DD SYSOUT=A 00210000
// 00220000
*> COBOL with embedded SQL.
*> Normally for extensions pco, scb and sqb, but currently integrated into COBOL
EXEC SQL
select count(*) from abc
END-EXEC
ADD 1 TO x
@@ -0,0 +1,102 @@
<!--- ColdFusion Sample File --->
<!--- Source: https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-arrays-and-structures/structure-examples.html --->
<head>
<title>Add New Employees</title>
</head>
<body>
<h1>Add New Employees</h1>
<!--- Action page code for the form at the bottom of this page. --->
<!--- Establish parameters for first time through --->
<cfparam name="Form.firstname" default="">
<cfparam name="Form.lastname" default="">
<cfparam name="Form.email" default="">
<cfparam name="Form.phone" default="">
<cfparam name="Form.department" default="">
<!--- If at least the firstname form field is passed, create
a structure named employee and add values. --->
<cfif #Form.firstname# eq "">
<p>Please fill out the form.</p>
<cfelse>
<cfoutput>
<cfscript>
employee=StructNew();
employee.firstname = Form.firstname;
employee.lastname = Form.lastname;
employee.email = Form.email;
employee.phone = Form.phone;
employee.department = Form.department;
</cfscript>
<!--- Display results of creating the structure. --->
First name is #StructFind(employee, "firstname")#<br>
Last name is #StructFind(employee, "lastname")#<br>
EMail is #StructFind(employee, "email")#<br>
Phone is #StructFind(employee, "phone")#<br>
Department is #StructFind(employee, "department")#<br>
</cfoutput>
<!--- Call the custom tag that adds employees. --->
<cf_addemployee empinfo="#employee#">
</cfif>
<!--- The form for adding the new employee information --->
<hr>
<form action="newemployee.cfm" method="Post">
First Name:&nbsp;
<input name="firstname" type="text" hspace="30" maxlength="30"><br>
Last Name:&nbsp;
<input name="lastname" type="text" hspace="30" maxlength="30"><br>
EMail:&nbsp;
<input name="email" type="text" hspace="30" maxlength="30"><br>
Phone:&nbsp;
<input name="phone" type="text" hspace="20" maxlength="20"><br>
Department:&nbsp;
<input name="department" type="text" hspace="30" maxlength="30"><br>
<input type="Submit" value="OK">
</form>
<br>
</body>
</html>
<cfoutput>
Error. No employee data was passed.<br>
</cfoutput>
<cfexit method="ExitTag">
<cfelse>
<!--- Add the employee --->
<cfquery name="AddEmployee" datasource="cfdocexamples">
INSERT INTO Employees
(FirstName, LastName, Email, Phone, Department)
VALUES (
'#attributes.empinfo.firstname#' ,
'#attributes.empinfo.lastname#' ,
'#attributes.empinfo.email#' ,
'#attributes.empinfo.phone#' ,
'#attributes.empinfo.department#' )
</cfquery>
</cfif>
<cfoutput>
<hr>Employee Add Complete
</cfoutput>
<!--- temperature.cfc --->
<cfcomponent>
<cffunction name="FtoC" access="public" returntype="numeric">
<cfargument name="fahrenheit" required="yes" type="numeric" />
<cfset answer= (fahrenheit - 32)*100/180 />
<cfreturn answer />
</cffunction>
</cfcomponent>
<!--- test.cfm --->
<cfset fDegrees = 212 />
<cfinvoke component="temperature" method="FtoC" returnvariable="result">
<cfinvokeargument name="fahrenheit" value="#fDegrees#" />
</cfinvoke>
<cfoutput>#fDegrees#&deg;F = #result#&deg;C</cfoutput> <br />
<cfset person = CreateObject("component", "Person") />
@@ -0,0 +1,47 @@
PROGRAM testtest;
INTERFACE
extern inout int inputs_int[];
extern out int nur_out[];
extern in int nur_in[];
CODE
function jetzt_mach_schon(in int grenze, out int fak){
int temp, counter;
counter=grenze;
temp=1;
while(counter>1)
temp*=(counter--);
fak=temp;
}
function mach_mal(inout int i){
if(i==3) i=6;
else if(i==4) i=24;
else if(i>=5) jetzt_mach_schon(i,i);
// 1 und 2: gleich.
}
function mach_nochmal(in int k1, out int k2, in int vektor){
int4 hossa;
hossa=k1;
int4 hasso;
hasso=-vektor;
k2=(hasso|hossa>k1)?k1:-k1; //parse error before `|'
// k2=(hasso||hossa>k1)?k1:-k1; //only works on expressions of equal dimension
}
CONTROL
forall (int i in inputs_int:1D) do {
mach_mal(i);
}
forall (int j in inputs_int:1D;
int i in nur_out:1D;
int vektor in nur_in:1D) do {
mach_nochmal(j,i, vektor);
}
@@ -0,0 +1,48 @@
version 12.2
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
! bla bla
hostname R-site2
logging queue-limit 100
no logging console
enable secret 5 $1$UzZM$BTdJlwFCg63tUdyLmq6cr0
username admin password 0 Yas!8^VB5q$yZ53C35#nC
ip subnet-zero
no ip domain lookup
ip domain name solea2.local
ip dhcp excluded-address 10.1.22.200 10.1.22.254
ip dhcp pool Administrateur
network 10.1.10.0 255.255.255.0
dns-server 8.8.8.8
default-router 10.1.10.254
crypto map VPNSOLEA 20 ipsec-isakmp
set peer 192.168.141.4
set transform-set SETVPN
match address 110
interface FastEthernet0/0.22
encapsulation dot1Q 22
ip address 10.1.22.254 255.255.255.0
ip nat inside
access-list 110 permit ip 10.1.0.0 0.0.255.255 10.0.0.0 0.0.255.255
route-map nonat permit 20
match ip address 150
line con 0
password 57vmLD3
line aux 0
line vty 0 4
login local
transport input ssh
line vty 5 15
login local
transport input ssh
@@ -0,0 +1,133 @@
# This CMakeLists.txt doesn't do anything useful,
# but it shoudl demonstrate the cmake syntax highlighting
#
# Alex Turbov <i.zaufi@gmail.com>
#
#[[.rst:
Demo
----
This is an **RST** documentation.
::
# Sample code block
blah-blah
But we are about to test CMake here ;-)
#]]
cmake_policy(VERSION 3.11)
project(
Demo VERSION 1.0
DESCRIPTION "For unit testing purposes"
# NOTE that particular languages is a separate style
# to highlight "special" (well known values)
LANGUAGES C CXX
)
set(SOME_TRUE_OPTION TRUE) # `true` value
# `false` value and "internal" variable
set(_ANOTHER_FALSE_OPTION OFF CACHE INTERNAL "Internal option")
#BEGIN Message block
message(FATAL_ERROR "Ordinal message do ${VARIABLE_EXPANSION}")
message(AUTHOR_WARNING "... standard variables have a dedicated style")
message(SEND_ERROR "e.g. ${PROJECT_DESCRIPTION} or ${CMAKE_COMMAND}")
message(
STATUS [=[
Raw messages do not do ${VARIABLES_EXPANSION} or \n
escape symbols highlighting...
]=]
)
#END Message block
# ATTENTION Every command highlight only its own named keywords...
# Also, note aliased (most of the time imported) targets higlighted as well
add_library(Foo::foo IMPORTED GLOBAL)
set(KW_HL IMPORTED GLOBAL) # `IMPORTED` and `GLOBAL` are not highlighted here!
# Properties are separate ("special value") style
set_target_properties(Foo::foo PROPERTIES LOCATION "${FOO_LIBRARY}")
# Generator expressions
target_compile_definitions(
# NOTE Ok w/ CMake >= 3.11
Foo::foo
$<$<PLATFORM_ID:Windows>:WINDOWS_FOO>
$<$<PLATFORM_ID:Linux>:
LINUX_FOO
$<$<BOOL:${_has_foo}>:SOME_FOO_PATH=${PROJECT_BINARY_DIR}/foo>
>
)
#[=======================================================================[.rst:
.. cmake:command:: my_fun
*RST* documentation ``can`` refer to :cmake:command:`any_commands` or
:cmake:variable:`variables`...
.. code-block:: cmake
:caption: **Synopsys**
my_fun([ANYTHING...])
#]=======================================================================]
function(my_fun)
# TODO Add implementation
endfunction()
my_fun(
# Custom functions do not highlight "standard" named args ...
PUBLIC LOCATION PARENT_SCOPE
# only some well-known values ...
smth-NOTFOUND ON
# and standard variables
PROJECT_VERSION
# or substitutions
$ENV{HOME} OR ${_internal_var_is_grey}
)
# I dont'recall exactly, but there was some bug with `if`...
if((A AND "${B}") OR C OR (var MATCHES "regex"))
# Anyway... it is Ok nowadays ;-)
elseif(POLICY CMP066)
add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cc)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
Qt5::Core
$<$<BOOL:${HAS_FOO}>:Foo::foo>
)
endif()
# In each function call below, all 3 named parameter lines should apply the same highlighting.
add_custom_command(
COMMAND true
COMMAND (true)
COMMAND true
)
add_custom_target(TargetName
WORKING_DIRECTORY somedir
COMMAND (true)
BYPRODUCTS somefile
)
execute_process(
COMMAND true
COMMAND (true)
COMMAND true
)
add_test(
NAME sometest
COMMAND (true)
WORKING_DIRECTORY somedir
)
# nested parentheses
if( true AND ( false OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") ) )
endif()
@@ -0,0 +1,584 @@
#pragma once
#include <cassert>
#include <assert.h>
#include "assert.h"
#include "assert.hpp" // abc
#include "path/assert.hpp"
#include "assert.h"a
#include "assert.h" a
#include <cassert>a
#include <cassert> a
#include FOO() error
#include_next <cassert> a
#include_next <cassert> /* a
*/ b
#include PATH_IN_MACRO
#include PATH_IN_MACRO()
#include PATH_IN_MACRO(a, b)
#define SOME_VAR 1
#ifdef SOME_VAR
#define MULTILINE_MACRO one \
two \
three
# define MULTILINE_MACRO_TEXT \
/* NOTE The contents of macro is too green :D */ \
char const s[] = "a\\b" \
"c\nd" \
std::uint##x##_t \
std::vector/**/<T> \
std::chrono::/*milli*/seconds
# define VARIADIC(a, ...) \
f(a##a) \
f(__VA_ARGS__) \
f(#__VA_ARGS__) \
f(__VA_ARGS__) \
f(0 __VA_OPT__(,) __VA_ARGS__) \
x __VA_OPT__(= { __VA_ARGS__ })
# define MACRO() BAD \ ESCAPED
# error dds
# warning dds
# line 2 "file.cpp"
# define A(x, y) x##y x#y
// OK(L, a) -> L"a"
# define OK(x, y) x###y
# define BAD(x, y) x####y
# define A /* multi line
with comment */ expr
# define A /* multi line
with comment */
23
#else // x
#42 // gcc extension = #line 42
// error
#wrong
# wrong
#endif x
#if DS()
#else x
#else /* */x
#else /* x
y */ z
#endif
// check that _XXX defines work, bug 397766
#ifndef _HEADER_GUARD
#define _HEADER_GUARD 1
#endif
#ifdef _HEADER_GUARD
#if (_HEADER_GUARD >= 1)
#endif
#endif
static int g_global;
template<class T, typename U, template<class> class = std::is_pointer>
struct class1
: private std::vector<T>, public U
{
class1()
try
: _member1(xxx)
{}
catch(...)
{}
class1(class1&&) = default;
~class1()
{}
void foo() { return; }
void foo() const { return; }
void foo() noexcept { return; }
void foo() const noexcept { return; }
virtual void foo() const noexcept { return; }
static void foo() { return; }
constexpr static void foo() const
noexcept(noexcept(std::is_pointer<U>::value)) override
{
xxx::template ttt<U>::type {};
xxx.template get<U>();
xxx.std::rdbuf();
auto x = C<'a'> + y;
}
int operator->*(T (C::*m)(int));
operator value_t ();
private:
protected:
public:
value_type _member1; // NOTE internal ?
value_type __internal;
value_type internal__;
value_type _M_internal;
value_t member2_;
value_type m_member3;
static int s_static;
static constexpr int s_static;
static inline int s_static;
static inline constexpr int s_static;
};
constexpr struct : xyz
{
using xyz::xyz;
using xyz::operator=;
int a : 1;
int b : 7;
} x {};
template<class T>
using is_pointer = std::is_pointer<T>::type;
template<class T>
constexpr auto is_pointer_v = std::is_pointer<T>::value;
uint64_t namespaces()
{
std::vector<T>;
boost::vector<T>;
detail::vector<T>;
details::vector<T>;
aux::vector<T>;
internals::vector<T>;
other::vector<T>;
}
task<> tcp_echo_server() {
char data[1024];
for (;;) {
size_t n = co_await socket.async_read_some(buffer(data));
co_await async_write(socket, buffer(data, n));
}
}
#if 1
double foo(const A);
#else // else
double foo(const A);
#endif // end
#if 0
double foo(const A);
#else // else
double foo(const A);
#endif // end
#if 1
double foo(const A);
#elif 1
double foo(const A);
#elif 0
double foo(const A);
#endif // end
#if 0
double foo(const A);
#elif 1
double foo(const A);
#elif 0
double foo(const A);
#endif // end
#if 0
double foo(const A);
#elif a
double foo(const A);
#elif 0
double foo(const A);
#elif a
double foo(const A);
#else // else
double foo(const A);
#endif // end
#if 0 // blah blah
double foo(const A);
#elif 1 // blah blah
double foo(const A);
#else // else
double foo(const A);
#endif // end
#if 0 || a
double foo(const A);
#else // else
double foo(const A);
#endif // end
#if 1 || a
double foo(const A);
#else // else
double foo(const A);
#endif // end
#if 0 && a
double foo(const A);
#else // else
double foo(const A);
#endif // end
#if 1 && a
double foo(const A);
#else // else
double foo(const A);
#endif // end
#if a
double foo(const A);
#elif 0
double foo(const A);
#endif // end
#if a
double foo(const A);
#elif 1
double foo(const A);
#endif // end
#if a
double foo(const A);
#elif a
double foo(const A);
#endif // end
int bar(void*p, void * pp)
{
# if 0
double foo();
# else // else
double foo();
# endif // end
}
#if abc 0
double foo();
#endif // end
#if xxx
double foo();
#else
double foo();
#endif // end
#if xxx
double foo();
#elif xxx // elseif
double foo();
#elif xxx // elseif
double foo();
#endif // end
// error
#
#d
# d
#if
#elif
#endif
#ifndef
#endif
#ifdef 0
#endif // end
static uint64_t intWithSuffix = 42ull;
static long intWithSuffixAndPrefix = 0b0101L;
static int octNum = 07232;
static int invalidOctNum = 09231;
static uint64_t hexNum = 0xDEADBEEF42;
static uint64_t invalidHexNum = 0xGLDFKG;
static char binNum = 0b0101010;
static int64_t intWithSuffix = -42LL;
static long intWithSuffixAndPrefix = -0b0101L;
static int octNum = -07232;
static int invalidOctNum = -09231;
static int64_t hexNum = -0xDEADBEEF42;
static int64_t invalidHexNum = -0xGLDFKG;
static char binNum = -0b0101010;
static uint64_t intWithSuffixWithSep = 4'2ull;
static long intWithSuffixAndPrefixWithSep = 0b0'10'1L;
static int octNumWithSep = 07'232;
static int invalidOctNumWithSep = 09'23'1;
static uint64_t hexNumWithSep = 0xD'EAD'BE'EF'42;
static uint64_t invalidHexNumWithSep = 0xGLD'FKG;
static char binNumWithSep = 0b0'1010'10;
static uint64_t invalidSep = 42'ull;
static uint64_t invalidSep = 42';
static double d1 = 42.;
static double d2 = .42;
static double d2a = -0.49;
static double d2b = -0.09;
static double d3 = 42.3e1;
static double d4 = .2e-12;
static double d5 = 32.e+12;
static double invalidD1 = 32.e+a12;
static float floatQualifier = 23.123f;
// Hexadecimal floating point (c++17)
static double d6 = 0x1ffp10;
static double d7 = 0X0p-1;
static double d8 = 0x1.p0;
static double d9 = 0xf.p-1L;
static double d10 = 0x0.123p-1;
static double d11 = 0xa.bp10l;
static double invalidD2 = 0x0.123p-a;
static float floatQualifier = 0xf.p-1f;
60min; // c++17
60.min;
60.3min;
0x1ffp10min;
2us
2d; // c++20
23._f
23._fd
2.3_f
2.3_fd
2._f
2._fd
2e4_f
2e4_fd
// error
23.fd
2e_fd
2e
1.y
1.0_E+2.0
1.0_E +2.0 // ok
1_p+2
1_p +2 // ok
4s.count()
4s. count()
4s .count() // ok
// float suffix
1.2f
1.2f3
1.2f32 // C++23
12f32
12BF32
12BF16
12.BF16 // C++23
static bool yes = true;
static bool no = false;
// *char*
static const char c1 = 'c';
static const char c1a = u8'c'; // utf-8 char (c++17)
static const char16_t c1b = u'c';
static const char32_t c1c = U'c';
static const wchar_t c1d = L'c';
static const char c2 = '\n';
static const char c2a = '\120'; // octal
static const char c2b = '\x1f'; // hex
static const char c2c = '\'';
static const char c2d = '\\';
static const wchar_t c2e = L'\x1ff'; // hex
static const wchar_t c2e = U'\x1fffffff'; // hex
// error
'\x123';
'\u1234';
'\U12345678';
U'\u12345';
u'\u123';
U'\U1234567';
U'\U123456789';
U'\x123456789';
// string
static const char* c3 = "string";
static const char* c4 = "\"string\n\t\012\x12\"";
static const char* c5 = "multiline \
string";
static const char* c6 = "multifragment" "other""string";
static const char* c6a = u8"string";
static const char16_t* c6b = u"string";
static const char32_t* c6c = U"string";
static const wchar_t* c6d = L"string";
static const char* rawString1 = R"(string)";
static const char* rawString1a = u8R"(string)";
static const char16_t* rawString1b = uR"(string)";
static const char32_t* rawString1c = UR"(string)";
static const wchar_t* rawString1d = LR"(string\nstring)";
static const char* rawString2 = R"ab(string\nstring%s)ab ")ab";
static const char* rawString3 = R"ab(string
string%)ab";
" %d %df fd" U"ds %d" R"(a%d)";
"\x{12343} \x{1} \o{12121} \u{1221a} \N{LATIN CAPITAL LETTER A WITH MACRON}"
"\x123xsk";
u"\x123xsk";
// error
u8"\x123xsk";
"\x{123x43} \o{121821} \u{12x21as} \N{LATIN CAPITAL letter A WITH MACRON}"
// printf format
"a%10sa%-10sa%*sa%-10.*sa%-*.*sa"
"a%ca%*ca%%a%ia%da%.6ia%.0ia%+ia%ia%xa%#xa"
"a%.0fa%.32fa%05.2fa%.2fa%5.2fa%Ea%aa"
// std::format
"a{{:6}}a{}a{:6}a{:*<6}a{:6d}a"
"a{0:}a{0:+}a{0:-}a{0: }a"
"a{:+06d}a{:#06x}a{:<06}a"
"a{:{}}a{0:{1}.{2}f}a"
;
// UDL (c++11)
operator""_a(const char*);
operator ""_a(const char*);
operator "" _a(const char*);
// invalid suffix
operator "" a(const char*);
operator ""a(const char*);
operator""a(const char*);
"string"_s; // user
"string"s; // standard
"string"_s-b; // -b is not part of the string
// Macro
MY_XXX;
BOOST_XXX;
__STDC_VERSION__;
__TIME__;
__cplusplus;
// Attributes
[[noreturn]] void foo();
[[deprecated]] void foo();
[[deprecated("because")]] void foo();
void foo([[carries_dependency]] int);
[[opt(1), debug]]
[[using CC: opt(1), debug]] // c++17
[[using CC: CC::opt(1)]] // c++17
[[gnu::assume_aligned(3'2l,2)]] void* f();
[[using gnu: assume_aligned(3)]]
[[clang::assume_aligned(3)]]
void f([[maybe_unused]] int val)
{
[[maybe_unused]] int x;
switch (x = foo(); x) {
case 1:
[[fallthrough]];
case XXX:
case Class::foo():
[[fallthrough]];
default:
;
}
// c++17: fold expression
(args + ... + (1 * 2));
(v.push_back(args), ...);
[[omp::parallel]] for (auto&& x : v)
x;
for (auto&& [first,second] : mymap) {
}
auto [x, y] = foo();
[x = 1, =y](){};
decltype((auto)) x = foo();
}
auto f() -> decltype(foo());
__attribute__((pure)) void f();
label:
goto label;
//BEGIN region
// TODO comment FIXME comment ### comment BUG comment
//END region
// \brief blah blah
/// \brief blah blah
/**
* Doxygen
* @param p1 text
* \brief <b>bold text</b>
* \dot
* a -> b
* \enddot
*
* \verbatim
* <dummy>
* \endverbatim
* <html>text</html>
*/
#endif
// Some GNU macros, cross-referenced from gcc.xml to isocpp.xml
__GCC_ATOMIC_CHAR16_T_LOCK_FREE
__GNUC__
__linux__
// Digraphs (see bug #411508)
%:include <stdio.h>
int main()
<%
[](){%>();
}
<:<:fallthrough]]
/**
* multi-line comment
*/
/* comment */
{ { } {
//BEGIN
}
//END
}
#if 0
#elif 1
#else
#endif
#if 1
int x; // variable shall not be grey
#endif
#if defined (A)
int y; // variable shall not be grey
#elif defined (B)
int z; // variable shall not be grey
#endif
/*!
* formula @f$a+b@f$ inside a block comment
*/
//! formula @f$a+b@f$ inside a inline comment
// formula @f$a+b@f$ inside a normal comment
/// \b sa
@@ -0,0 +1,250 @@
# This file is a testcase for the highlighting of Crystal code
# It's not executable code, but a collection of code snippets
#
require "lib_z"
require "./digest"
module Digest::Adler32
def self.initial : UInt32
LibZ.adler32(0, nil, 0).to_u32
end
def self.checksum(data) : UInt32
update(data, initial)
end
def self.update(data, adler32 : UInt32) : UInt32
slice = data.to_slice
LibZ.adler32(adler32, slice, slice.size).to_u32
end
def self.combine(adler1 : UInt32, adler2 : UInt32, len) : UInt32
LibZ.adler32_combine(adler1, adler2, len).to_u32
end
end
struct BigRational
Number.expand_div [Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128], BigRational
Number.expand_div [Float32, Float64], BigRational
end
module Crystal::Repl::Closure
VAR_NAME = ".closure_var"
ARG_NAME = ".closure_arg"
end
class FunctionType
getter arg_types : Array(ArgType)
getter return_type : ArgType
@@cvar = 3
@ivar = 7
def initialize(@arg_types, @return_type)
end
def //(other : Int::Unsigned) : BigInt
check_division_by_zero other
unsafe_floored_div(other)
end
def //(other : Int) : BigInt
check_division_by_zero other
if other < 0
(-self).unsafe_floored_div(-other)
@cvar += 1
else
unsafe_floored_div(other)
@ivar += 10
end
end
end
require "llvm/enums/atomic"
struct Atomic(T)
# Creates an Atomic with the given initial value.
def compare_and_set(cmp : T, new : T) : {T, Bool}
{% if T.union? && T.union_types.all? { |t| t == Nil || t < Reference } %}
address, success = Ops.cmpxchg(pointerof(@value).as(LibC::SizeT*), LibC::SizeT.new(cmp.as(T).object_id), LibC::SizeT.new(new.as(T).object_id), :sequentially_consistent, :sequentially_consistent)
{address == 0 ? nil : Pointer(T).new(address).as(T), success}
{% elsif T < Reference %}
# Use addresses again (but this can't return nil)
address, success = Ops.cmpxchg(pointerof(@value).as(LibC::SizeT*), LibC::SizeT.new(cmp.as(T).object_id), LibC::SizeT.new(new.as(T).object_id), :sequentially_consistent, :sequentially_consistent)
{Pointer(T).new(address).as(T), success}
{% else %}
Ops.cmpxchg(pointerof(@value), cmp, new, :sequentially_consistent, :sequentially_consistent)
{% end %}
end
def swap(value : T)
{% if T.union? && T.union_types.all? { |t| t == Nil || t < Reference } || T < Reference %}
address = Ops.atomicrmw(:xchg, pointerof(@value).as(LibC::SizeT*), LibC::SizeT.new(value.as(T).object_id), :sequentially_consistent, false)
Pointer(T).new(address).as(T)
{% else %}
Ops.atomicrmw(:xchg, pointerof(@value), value, :sequentially_consistent, false)
{% end %}
end
end
class Deque(T)
include Indexable::Mutable(T)
@start = 0
protected setter size
private getter buffer
def initialize(size : Int, value : T)
if size < 0
raise ArgumentError.new("Negative deque size: #{size}")
end
@size = size.to_i
@capacity = size.to_i
unless @capacity == 0
@buffer = Pointer(T).malloc(@capacity, value)
end
end
# Returns a new `Deque` that has this deque's elements cloned.
# That is, it returns a deep copy of this deque.
#
# Use `#dup` if you want a shallow copy.
def clone
{% if T == ::Bool || T == ::Char || T == ::String || T == ::Symbol || T < ::Number::Primitive %}
Deque(T).new(size) { |i| self[i].clone.as(T) }
{% else %}
exec_recursive_clone do |hash|
clone = Deque(T).new(size)
each do |element|
clone << element.clone
end
clone
end
{% end %}
end
def delete_at(index : Int) : T
unless 0 <= index < @size
raise IndexError.new
end
return shift if index == 0
if index > @size // 2
# Move following items to the left, starting with the first one
# [56-01234] -> [6x-01235]
dst = rindex
finish = (@start + @size - 1) % @capacity
loop do
src = dst + 1
src -= @capacity if src >= @capacity
@buffer[dst] = @buffer[src]
break if src == finish
dst = src
end
(@buffer + finish).clear
end
end
def each(& : T ->) : Nil
halfs do |r|
r.each do |i|
yield @buffer[i]
end
end
end
def pop : T
pop { raise IndexError.new }
end
macro [](*args)
array = uninitialized Array(Int32)
{% for arg, i in args %}
array.to_unsafe[{{i}}] = {{arg}}
{% end %}
array
end
def message : String
case self
when SUCCESS then "No error occurred. System call completed successfully."
when TXTBSY then Errno::ETXTBSY
when NOTCAPABLE then Errno::ENOTCAPABLE
else Errno::EINVAL
end
end
enum Signal
KILL = 0
BILL = 101
end
end
# :nodoc:
module Ops
# Defines methods that directly map to LLVM instructions related to atomic operations.
@[Primitive(:cmpxchg)]
def self.cmpxchg(ptr : T*, cmp : T, new : T, success_ordering : LLVM::AtomicOrdering, failure_ordering : LLVM::AtomicOrdering) : {T, Bool} forall T
end
@[Primitive(:atomicrmw)]
def self.atomicrmw(op : LLVM::AtomicRMWBinOp, ptr : T*, val : T, ordering : LLVM::AtomicOrdering, singlethread : Bool) : T forall T
end
end
@[Link("z")]
lib LibZ
alias Char = LibC::Char
alias SizeT = LibC::SizeT
fun zlibVersion : Char*
fun crc32_combine(crc1 : ULong, crc2 : ULong, len : Long) : ULong
alias AllocFunc = Void*, UInt, UInt -> Void*
alias FreeFunc = (Void*, Void*) ->
struct ZStream
next_in : Bytef*
avail_in : UInt
next_out : Bytef*
total_out : ULong
msg : Char*
state : Void*
zalloc : AllocFunc
zfree : FreeFunc
opaque : Void*
data_type : Int
adler : Long
end
# error codes
enum Error
OK = 0
VERSION_ERROR = -6
end
enum Flush
NO_FLUSH = 0
TREES = 6
end
MAX_BITS = 15
fun deflateInit2 = deflateInit2_(stream : ZStream*, level : Int32, method : Int32,
window_bits : Int32, mem_level : Int32, strategy : Int32,
version : UInt8*, stream_size : Int32) : Error
fun deflate(stream : ZStream*, flush : Flush) : Error
fun deflateSetDictionary(stream : ZStream*, dictionary : UInt8*, len : UInt) : Int
fun inflateInit2 = inflateInit2_(stream : ZStream*, window_bits : Int32, version : UInt8*, stream_size : Int32) : Error
fun inflate(stream : ZStream*, flush : Flush) : Error
fun inflateSetDictionary(stream : ZStream*, dictionary : UInt8*, len : UInt) : Error
end
@@ -0,0 +1,441 @@
/**
* This is a pseudo CSS file to test Kate's CSS syntax highlighting.
*/
/* Properties */
body {
font-size: 15pt;
font-family: Verdana, Helvetica, "Bitstream Vera Sans", sans-serif;
margin-top: 0px; /* yet another comment */
margin-bottom: 0px;
// this is no comment, it's just broken!
background-color: hsl(0, 0%, calc(95% - 3%));
font-family: "Droid Sans", Arial, sans-serif;
font-size: 11pt;
line-height: 1.5em;
background: #fff000;
text-shadow: 0 0 2px rgba(0, 0, 0, 0.3);
box-sizing: border-box;
font-variant-alternates: styleset(nice-style);
}
/* Selectors */
body, blockquote {
margin: 0;
}
header #logo {
width: 100px;
}
div#footer .link {
color: blue;
}
.something
{
margin-right: 0px;
color: #cdd;
color: #AAFE04;
color: rgb(10%,30%,43%);
background: maroon;
}
sidebar #subscribe .subscribe_form input[type="text"] {
font-size: 20px;
}
sidebar #subscribe .subscribe_form:nth-child(2n + 1):hover input[class*="small-"] {
font-weight: bold;
}
input[value=text]
input[value= text ]
input[value= text i]
input[value= "text" i]
input[value=i]
input[value= i] {
font-size: 20px;
}
#header,
a:hover,
p.intro:first-letter,
p:lang(nl),
img[align="right"]
{
border: 1px solid Qt::red !important;
-moz-border-radius: 15px; /* unknown properties render italic */
}
.nice-look {
}
ul {
list-style: thumbs;
}
/* SVG <a> */
svg|a {}
/* XHTML and SVG <a> */
*|a {}
*{}
.class{}
#id{}
:hover{}
:lang(fr){}
E{}
E F{}
E>F{}
E > F{}
E~F{}
E ~ F{}
E:first-child{}
E:visited{}
E::after{}
E:lang(c){}
E:lang(fr-ca){}
E + F{}
E+F{}
E[foo]{}
E[foo=warning]{}
E[foo="warning"]{}
E[foo~="warning"]{}
E[foo^="warning"]{}
E[foo$="warning"]{}
E[foo*="warning"]{}
E[lang|="en"]{}
DIV.warning{}
DIV .warning{}
E#myid{}
E #myid{}
E,E{}
E, E{}
E ,E{}
E , E{}
p:nth-child(2) {
background: red;
}
/* Elements that are not <div> or <span> elements */
body :not(div):not(span) {
font-weight: bold;
}
/* Elements that are not `.crazy` or `.fancy` */
/* Note that this syntax is not well supported yet. */
body :not(.crazy, .fancy) {
font-family: sans-serif;
}
:nth-child(odd) { color: lime; }
:nth-child(even) { color: lime; }
:nth-child(4) { color: lime; }
:nth-child(4n) { color: lime; }
:nth-child(3n+4) { color: lime; }
:nth-child(-n+3) { color: lime; }
:nth-child(n+8):nth-child(-n+15) { color: lime; }
.first span:nth-child(2n+1),
.second span:nth-child(2n+1),
.third span:nth-of-type(2n+1) {
background-color: lime;
unknown-property: lime;
}
:root{
--foo: if(x > 5) this.width = 10; /* valid custom property, invalid in any normal property */
}
:root,
:root:lang(en) {--external-link: "external link";}
:root:lang(de) {--external-link: "externer Link";}
a[href^="http"]::after {content: " (" var(--external-link) ")"}
one { --foo: 10px; }
two { --bar: calc(var(--foo) + 10px); }
three { --foo: calc(var(--bar) + 10px); }
.foo {
--gap: 20;
margin-top: var(--gap)px; /*20 px*/
margin-top: calc(var(--gap) * 1px); /*20px*/
}
foo {
width: calc(50% -8px); /* invalid */
width: calc(50%- 8px); /* invalid */
width: calc(50% +8px); /* invalid */
width: calc(50%+ 8px); /* invalid */
width: calc(2px -var(--a)); /* invalid */
width: calc(50%*-8px);
width: calc(50% - 8px);
width: calc(50% + -8px);
width: calc(50% +(8px));
width: calc(2px -(var(--a)));
}
sweet-alert input:focus::-moz-placeholder {
-webkit-transition: opacity 0.3s 0.03s ease;
transition: opacity 0.3s 0.03s ease;
opacity: 0.5;
}
@font-feature-values Font One {
@styleset {
nice-style: 12;
}
}
@font-feature-values Font Two {
@styleset {
nice-style: 4;
}
}
@font-palette-values --identifier {
font-family: Bixa;
}
@counter-style thumbs {
system: cyclic;
symbols: "\1F44D";
suffix: " ";
}
@font-face {
font-family: "Open Sans";
/* comments */
unknown: 2px;
src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
url("/fonts/OpenSans-Regular-webfont.woff") format("woff");
}
@page {
margin: 1cm;
}
@page :first {
margin: 2cm;
/* comments */
marks: crop cross;
}
@page :unknown {
margin: 2cm;
}
@document url("https://www.example.com/") {
h1 {
color: green;
}
}
@charset "UTF-8";
@import 'custom.css';
@import "common.css" screen;
@import url("fineprint.css") print;
@import url(fineprint.css) print;
@import url('bluish.css') speech;
@import url("chrome://communicator/skin/");
@import url('landscape.css') screen and (orientation:landscape);
@import url("othersheet.css") screen, print;
@namespace url(http://www.w3.org/1999/xhtml);
@namespace svg url(http://www.w3.org/2000/svg);
/* Animation (Keyframes) */
@keyframes important1 {
from { margin-top: 50px; }
50% { margin-top: 150px !important; } /* ignored */
to { margin-top: 100px; }
}
@keyframes important2 {
from { margin-top: 50px;
margin-bottom: 100px; }
to { margin-top: 150px !important; /* ignored */
margin-bottom: 50px; }
}
@keyframes slidein {
from {
margin-left: 100%;
width: 300%;
}
to {
margin-left: 0%;
width: 100%;
}
}
/* Media Queries */
@media print {
.container {
width: 100%;
}
a:hover { color: red }
/* comments */
a:hover { color: red }
#header
{
display: none;
}
}
@media screen and (min-width: 768px) and (max-width: 960px) {
.container {
width: 720px;
}
}
@media (max-width: 600px) {
.sidebar {
display: none;
}
}
@media print {
}
@media (height > 600px) {
body {
line-height: 1.4;
}
}
@media (400px <= width <= 700px) {
body {
line-height: 1.4;
}
}
@supports (display: grid) {
div {
display: grid;
}
}
@supports font-tech(color-COLRv1) {
font-family: "Bungee Spice";
}
@supports not (not (transform-origin: 2px)) {
div {}
}
@supports (display: grid) and (not (display: inline-grid)) {
div {}
}
/*
* CSS Syntax Highlight Sample File (Standard)
*
* This file contains most CSS syntax, CSS3 properties, @media, @font-face and
* @keyframes annotations.
*
* @author Guo Yunhe guoyunhebrave@gmail.com
* @date 2016-09-16
*/
/*
* Block comment
*
* Alert keywords:
* TODO BUG FIXME
*/
/* Region markers */
/*BEGIN Comment */
/*END Comment */
/*
* CSS Syntax Highlight Sample File (Complex)
*
* This file contains complex CSS syntax that can test unexpected situations.
*
* @author Guo Yunhe guoyunhebrave@gmail.com
* @date 2016-09-16
*/
/* Comments with special content */
/*
* .class-selector #id "string" 'comment' // comment {} [] () /* comment
* TODO BUG DEBUG
* body {
* margin: 0 !important;
* }
*/
/* Comments in special positions */
header/* comment here */.active /* comment here */ {
/* comment here */ color : /* comment here */ blue/* comment here */;
font-family: Arial /* comment here */,
"Droid Sans", /* comment here */
sans-serif/* comment here */;
}
@media screen /* comment here */ and (max-width: 300px /* comment here */) /* comment here */ {/* comment here */}
/* Strings with special content */
@import url("{} $variable /* comment */");
/* Without extra breaklines and spaces */
pre.primary:hover.large:nth-child(2n-1){font-size:17px;font-family:"Noto Sans";-webkit-box-shadow:1px 1px 3px rgba(0,0,0,0.3)}
/* With unnecessary breaklines and spaces */
blockquote .ref
{
flex : 0 1 30%;
flex-wrap : wrap;
}
@media screen and (orientation: landscape) {
.sidebar {
width: 500px; } }
/* Special selectors: HTML5 allows user defined tags */
header {
flex {
width: 300px;
}
}
/* CSS Nesting */
header {
.abc {
width: 300px;
}
width: 300px;
& width:hover {
width: 300px;
}
width: 300px;
}
@@ -0,0 +1,6 @@
abc,abc,"abc,","abc""def",abc"abc,"abc"def,"abc
def""ghi",abc,abc,abc,abc
abc,abc,abc,abc,abc,abc,abc,abc,abc,abc,abc
abc,abc,abc,abc,abc,abc,abc,abc,abc,abc,abc
abc
abc
Can't render this file because it contains an unexpected character in line 1 and column 30.
@@ -0,0 +1,5 @@
abc|abc|"abc|abc|abc|abc|abc|abc|abc|abc|abc
abc|abc|abc|abc|abc|abc|abc|abc|abc|abc|abc
abc|abc|abc|abc|abc|abc|abc|abc|abc|abc|abc
abc
abc
@@ -0,0 +1,6 @@
abc;abc;"abc;";"abc""def";abc"abc;"abc"def;"abc
def""ghi";abc;abc;abc;abc
abc;abc;abc;abc;abc;abc;abc;abc;abc;abc;abc
abc;abc;abc;abc;abc;abc;abc;abc;abc;abc;abc
abc
abc
@@ -0,0 +1,4 @@
abc abc "abc "abc abc abc abc abc abc abc abc
abc abc "abc "abc abc abc abc abc abc abc abc
abc
abc
@@ -0,0 +1,219 @@
/********
* Highlight testing module.
*
* Do not attempt to run this!
***********/
module highlighttest;
import X = null;
/++ Pragma directives. DDoc + DDoc embedded items. Special Tokens.
+
+ ---
+ // comment
+ #line 12 "hightlighttest.d" /* block comment */
+ #line __LINE__ __FILE__ /++ embedded block comment +/
+
+ pragma /* */ (msg, "what?");
+ pragma(/++ +/ lib, "insane.a");
+ pragma(inline);
+ pragma(linkerDirective);
+ pragma(mangle);
+ pragma(startaddress);
+ pragma(D_Custom_Extension, "custom data");
+ pragma(foo 0);
+ ---
+/
/// version condition
version = X;
version = 1_2_3;
version (X) ;
version(linux) {}
/// linkage
extern
(C) {}
extern :
;
extern (C++) {}
extern (C++, foo.bar.baz) {}
extern (D) {}
extern (Windows) {}
extern (Pascal) {}
extern (System) {}
extern (unknown) {}
extern (C,) {}
extern (C++, foo, bar) {}
/// alias & typedef
alias int.min minint;
typedef int myint;
int main(char[][] args) {
/// statements
if (1) {}
else {}
with (N) {x = B}
/// attributes
auto x = 1;
static if (true) {}
void (in X, out Y) {} // NOTE: using in like this is rare, more common to use as an expression and no way to tell apart?
/// deprecated
deprecated void fct ();
/// types
void a;
ushort u;
int[uint] AA;
class C;
enum N : int { A = 5, B }
typeof(u) u2;
/// expressions
x = cast(int) 55;
void* p = null;
p = cast(void*) new int;
x = 1 in AA; // NOTE: a THIRD use of in. How to detect??
assert (true);
/// libsymbols
string s = "";
throw new Exception;
TypeInfo ti = typeid(int);
/// tests
debug {}
debug (2) {}
debug (DSymb) {}
unittest {}
/// scope (as attribute and as statement)
scope struct S;
scope (exit) {}
scope
(success) {} // NOTE: rules cannot match across new-lines
scope (failure) {}
/// Properties
x = int.min;
s = (5-3).stringof;
/// strings
s = r"raw string";
s = x"00FF";
s = \n \a;
s = \u1234;
s = \U12345678;
s = \&amp; ;
char c = 'a';
s = "abc 012 \" \n \x12 \u1234 \U12345678";
s = `BQString '"`;
s = q{foo "bar" 123};
s = q"FOO
foo
FOO";
s = q"[foo [bar] q"[baz]"]";
s = q"(foo (bar) q"(baz)")";
s = q"<foo <bar> q"<baz>">";
s = q"{foo {bar} q"{baz}"}";
s = q"/foo/";
s = q"!foo!";
/// region markers
//BEGIN x
//END x
/// DDoc
/*******
* DDoc
*
* Section:
* New section.
* $(I italic)
*******/
/+++++++
+ DDoc
+ /+
+ +/
+++++++/
// comments
// FIXME NOTE
/* comment */
/+ comment /+ nested comment +/ +/
/// brace folding
{
}
/** normal text
* ---
* .x;
* ..
* ...
* ....
* .....
* _._
* _e1
* ---
*/
/// float and int literals
int i;
real r;
ireal ir;
r = .0;
r = 0f;
ir = 0e0i;
ir = 0.fi;
r = 0.0e0;
r = 0xF.Fp0;
r = 0x_._p0_;
i = 5;
i = -1;
i = 0b10;
i = 0070;
i = 00;
i = 0xF0;
/// ranges
int[] A;
i = A[1];
A = A[0..$];
A = A[0..0];
A = A[0..length];
/// labels
label:
goto label;
/// function, delegate
creal function () fp = function creal() { return 0f+0fi; };
void delegate (in int i, lazy int b) dg = delegate void (int, int) {}
/// in, out, body
// NOTE: highlighting in & out as statements here could be difficult
float F ()
in {}
out (result) {}
body {}
/// try, catch, finally
try {
throw new Exception("oh no... ");
} catch (Exception e) {
} finally {
}
/// mixin
mixin("return false;").stringof;
/// templates
macro; // what does this do?
template Tp (T) {
Tp t;
}
Tp!(int) y;
}
@@ -0,0 +1,11 @@
libdemo (0.2) UNRELEASED; urgency=low
* Fix rendering bug. Closes: #1001
-- Foo Bar <foo.bar@example.org> Thu, 05 Sep 2020 10:30:00 +0200
libdemo (0.1-1) UNRELEASED; urgency=low
* Initial release.
-- Foo Bar <foo.bar@example.org> Thu, 03 Sep 2020 10:22:07 +0200
@@ -0,0 +1,89 @@
/* Test file for kate's stata syntax highlighting
*/
*! version 1.2.0 2mar2003 E. Leuven
program define spellsplit
version 7
syntax [anything], spell(varlist min=2 max=2) [ by(varlist)]
tokenize `spell'
local date0 `1'
local date1 `2'
local f0 : format `date0'
local f1 : format `date1'
/* set default statistic */
local current "mean"
gettoken left anything : anything, match(prns)
while "`left'"!="" {
if "`prns'"!="" {
if !inlist("`left'","mean","sum") {
di as error "Statistic `left' not supported"
exit 198
}
local current "`left'"
}
else {
local `current'vars ``current'vars' `left'
}
gettoken left anything : anything, match(prns)
}
if ("`meanvars'"!="") {
confirm var `meanvars'
unab meanvars : `meanvars'
}
if ("`sumvars'"!="") {
confirm var `sumvars'
unab sumvars : `sumvars'
}
quietly {
g _count = 1
local xvars `meanvars' `sumvars' _count
/* create dummy by-var if no by option is specified */
if "`by'"=="" {
tempvar by
g byte `by' = 1
}
tempvar `xvars' `by'
/* create negative for subtraction when spell ends */
cap foreach v of varlist `xvars' {
g double ``v'' = -`v'
local txvars `txvars' ``v''
}
cap foreach v of varlist `by' {
g double ``v'' = `v'
local txvars `txvars' ``v''
}
stack `date0' `xvars' `by' `date1' `txvars', into(`date0' `xvars' `by') clear
/* calculate totals per date */
cap foreach v of varlist `xvars' {
egen double ``v'' = sum(`v'), by(`by' `date0')
}
/* unique dates only */
by `by' `date0', sort: keep if _n==1
/* calculate totals (+ when spell starts - when ends) */
sort `by'
cap foreach v of varlist `xvars' {
by `by': replace `v' = sum(``v'')
}
by `by': g `date1' = `date0'[_n + 1]
drop if `date0'>`date1'
drop _stack
drop if _count==0
order `by' `date0' `date1' `xvars'
format `date0' `f0'
format `date1' `f1'
cap for var `meanvars': replace X = X/_count
compress
}
end
@@ -0,0 +1,232 @@
This is a pseudo doxygen file to test Kate's doxygen syntax highlighting.
Normal text, no HL.
===================
a multiline comment may begin with a /*! */, too. That should work,
because it is the same "entrance rule".
popping tests:
/** multiline */ end of doxygen HL mode
/*! multiline */ end of doxygen HL mode
//! singleline, where */ should be ignored! still doxygen HL mode
/// singleline, where */ should be ignored! still doxygen HL mode
///< singleline, where */ should be ignored! still doxygen HL mode
begin and end immediately:
/********/ actually no doxygen comment - used for "info boxes" :)
/**/ <-- it really works --- end of doxygen HL mode
/*!*/ end of doxygen HL mode
<tag> <normal comment HL>
/** \code rest of line is normal comment HL */ end of doxygen HL mode
/** \code rest of line is normal comment HL
* comment HL mode
*/ end of doxygen HL mode
<tag> <word> <normal comment HL>
/** \file aword rest of line is normal comment HL */ end of doxygen HL mode
/** \file */aword <-- pop! no doxygen HL mode
/** \file aword rest of line is normal comment HL
* comment HL mode
*/ end of doxygen HL mode
<tag> <rest of line is string>
/** \brief A short description */ end of doxygen HL mode
/** \brief */A <-- pop! end of doxygen HL mode
/** \brief A short description
* comment HL mode
*/ end of doxygen HL mode
<tag> <word> <rest of line is string>
/** \page aword rest of line is string */ end of doxygen HL mode
/** \page */aword <-- pop! end of doxygen HL mode
/** \page aword rest of line is string
* comment HL mode
*/ end of doxygen HL mode
<tag> <word> <word> <normal comment HL>
/** \image aword aword rest of line is normal HL */ end of doxygen HL mode
/** \image aword */aword <-- pop! end of doxygen HL mode
/** \image */aword aword <-- pop! end of doxygen HL mode
/** \image aword aword rest of line is normal HL
* comment HL mode
*/ end of doxygen HL mode
Tests for HTML tags in doxygen HL mode:
=======================================
/** <a href="blubb" href='blubb'> */ end of doxygen HL mode
/** <a href="blubb" href='blubb'*/> end of doxygen HL mode
/** <a href="blubb" href='blubb*/'> end of doxygen HL mode
/** <a href="blubb" href='blub*/b'> end of doxygen HL mode
/** <a href="blubb" href='b*/lubb'> end of doxygen HL mode
/** <a href="blubb" href='*/blubb'> end of doxygen HL mode
/** <a href="blubb" href=*/'blubb'> end of doxygen HL mode
/** <a href="blubb" href*/='blubb'> end of doxygen HL mode
/** <a href="blubb" hre*/f='blubb'> end of doxygen HL mode
/** <a href="blubb" */href='blubb'> end of doxygen HL mode
/** <a href="blubb"> */ end of doxygen HL mode
/** <a href="blubb"*/> end of doxygen HL mode
/** <a href="blubb*/"> end of doxygen HL mode
/** <a href="blub*/b"> end of doxygen HL mode
/** <a href="*/blubb"> end of doxygen HL mode
/** <a href=*/"blubb"> end of doxygen HL mode
/** <a href*/="blubb"> end of doxygen HL mode
/** <a h*/ref="blubb"> end of doxygen HL mode
/** <a */href="blubb"> end of doxygen HL mode
/** <a*/ href="blubb"> end of doxygen HL mode
/** <*/a href="blubb"> end of doxygen HL mode
//! <a href="blubb" href='blubb'> */ stay in doygen HL mode
//! <a href="blubb" href='blubb'*/> stay in doygen HL mode
//! <a href="blubb" href='blubb*/'> stay in doygen HL mode
//! <a href="blubb" href='blu*/bb'> stay in doygen HL mode
//! <a href="blubb" href='*/blubb'> stay in doygen HL mode
//! <a href="blubb" href=*/'blubb'> stay in doygen HL mode
//! <a href="blubb"> */ stay in doygen HL mode
//! <a href="blubb"*/> stay in doygen HL mode
//! <a href="blubb*/"> stay in doygen HL mode
//! <a href="blub*/b"> stay in doygen HL mode
//! <a href="*/blubb"> stay in doygen HL mode
//! <a href=*/"blubb"> stay in doygen HL mode
//! <a href*/="blubb"> stay in doygen HL mode
//! <a h*/ref="blubb"> stay in doygen HL mode
//! <a */href="blubb"> stay in doygen HL mode
//! <a*/ href="blubb"> stay in doygen HL mode
//! <*/a href="blubb"> stay in doygen HL mode
//! <a href="blubb"> stay in doygen HL <mode
here should be normal HL mode (no doxygen!)
Tests for HTML tags in doxygen HL mode with tags:
=================================================
<tag> <normal comment HL>
/** \code rest <a href="blubb"> of </a href='blubb'> line is normal comment HL */ end of doxygen HL mode
/** \code rest <a href="blubb"> of </a href='blubb'*/> end of doxygen HL mode
/** \code rest <a href="blubb"> of </a href='blubb*/'> end of doxygen HL mode
/** \code rest <a href="blubb"> of </a href='*/blubb'> end of doxygen HL mode
/** \code rest <a href="blubb"> of </a href=*/'blubb'> end of doxygen HL mode
/** \code rest <a href="blubb*/"> of </a href=*/'blubb'> end of doxygen HL mode
/** \code rest <a href=*/"blubb"> of </a href='blubb'> end of doxygen HL mode
/** \code rest <a h*/ref="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \code rest <*/a href="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \code rest of line is normal comment HL
* comment HL mode <html> text </html>
*/ end of doxygen HL mode
<tag> <word> <normal comment HL>
/** \file awo<html_should_be_ignored_here>rd rest of line is normal comment HL */ end of doxygen HL mode
/** \file awo<html_should_be_ignored_here>*/rd end of doxygen HL mode
/** \file awo<html_should_be_i*/gnored_here>rd end of doxygen HL mode
/** \file awo<*/html_should_be_ignored_here>rd end of doxygen HL mode
/** \file a*/wo<html_should_be_ignored_here>rd end of doxygen HL mode
/** \file aword rest of line is normal co<code>mment HL
* comment HL mode
*/ end of doxygen HL mode
<tag> <rest of line is string>
/** \brief A short <a href="blubb"> of </a href='blubb'> description */ end of doxygen HL mode
/** \brief A short <a href="blubb"> of </a href='blubb'*/> end of doxygen HL mode
/** \brief A short <a href="blubb"> of </a href='*/blubb'> end of doxygen HL mode
/** \brief A short <a href="blubb"> of </a href=*/'blubb'> end of doxygen HL mode
/** \brief A short <a href="blubb"> of </a href*/='blubb'> end of doxygen HL mode
/** \brief A short <a href="blubb"> of </a */href='blubb'> end of doxygen HL mode
/** \brief A short <a href="blubb"> of <*//a href='blubb'> end of doxygen HL mode
/** \brief A short <a href="blubb"*/> of </a href='blubb'> end of doxygen HL mode
/** \brief A short <a href="blubb*/"> of </a href='blubb'> end of doxygen HL mode
/** \brief A short <a href="*/blubb"> of </a href='blubb'> end of doxygen HL mode
/** \brief A short <a href=*/"blubb"> of </a href='blubb'> end of doxygen HL mode
/** \brief A short <a href*/="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \brief A short <a h*/ref="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \brief A short <a href="blubb"> of </a href='blubb'> description
* comment HL mode
*/ end of doxygen HL mode
<tag> <word> <rest of line is string>
/** \page aword A short <a href="blubb"> of </a href='blubb'> description */ end of doxygen HL mode
/** \page aword A short <a href="blubb"> of </a href='blubb'*/> end of doxygen HL mode
/** \page aword A short <a href="blubb"> of </a href='*/blubb'> end of doxygen HL mode
/** \page aword A short <a href="blubb"> of </a href=*/'blubb'> end of doxygen HL mode
/** \page aword A short <a href="blubb"> of </a href*/='blubb'> end of doxygen HL mode
/** \page aword A short <a href="blubb"> of </a */href='blubb'> end of doxygen HL mode
/** \page aword A short <a href="blubb"> of <*//a href='blubb'> end of doxygen HL mode
/** \page aword A short <a href="blubb"*/> of </a href='blubb'> end of doxygen HL mode
/** \page aword A short <a href="blubb*/"> of </a href='blubb'> end of doxygen HL mode
/** \page aword A short <a href="*/blubb"> of </a href='blubb'> end of doxygen HL mode
/** \page aword A short <a href=*/"blubb"> of </a href='blubb'> end of doxygen HL mode
/** \page aword A short <a href*/="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \page aword A short <a h*/ref="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \page aword A short <*/a href="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \page aword A shor*/t <a href="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \page awor*/d A short <a href="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \page */aword A short <a href="blubb"> of </a href='blubb'> end of doxygen HL mode
/** \page aword A short <a href="blubb"> of </a href='blubb'> description
* comment HL mode
*/ end of doxygen HL mode
<tag> <word> <word> <rest of line is string>
/** \image aword aword rest of line is normal HL */ end of doxygen HL mode
/** \image aword aword rest of line is*/ end of doxygen HL mode
/** \image aword aword*/ end of doxygen HL mode
/** \image aword aw*/ord end of doxygen HL mode
/** \image aword */aword end of doxygen HL mode
/** \image aword*/ end of doxygen HL mode
/** \image awo*/rd end of doxygen HL mode
/** \image */aword end of doxygen HL mode
/** \ima*/ge end of doxygen HL mode
/** \image aword aword rest of line is normal HL
* comment HL mode
*/ end of doxygen HL mode
Some further tests for singlelinecomments (* / should not pop!)
===============================================================
/// a singlelinecommment blubb blubb */. stay in doxygen HL mode
/// \code a singlelinecommment blubb b*/lubb. stay in doxygen HL mode
end of doxygen HL mode
/// \endcode
/// \code*/ a singlelinecommment blubb blubb. stay in doxygen HL mode
end of doxygen HL mode
/// \code a multilinecommment blubb blubb
/// blubb blubb
/// \endcode
/// \brief a descriptive text (string) stay in doxygen HL mode
/// \brief a descriptive text (string)*/ description should go on here
/// \brief a descriptive text */(string) description should go on here
/// \brief */a descriptive text (string) description should go on here
/// \ref aword a descriptive text (string) */ description should go on here
/// \ref aword a descriptive text (str*/ing) description should go on here
/// \ref aword a des*/criptive text (string) description should go on here
/// \ref aword*/ a descriptive text (string) description should go on here
/// \ref aw*/ord a descriptive text (string) description should go on here
/// \ref */aword a descriptive text (string) description should go on here
HTML comment tests:
===================
//! \ref word de<!--*/ -->scriptive text (string)
normal HL mode.
//! \ref w descriptive text (string)
/** \ref word de<!--*/ -->scriptive text (string)
normal HL mode.
/** \ref w <!--
* HTML comments
* -->
* normal doxygen HL mode.
*/
And final tests for a word: a single char:
===========================================
<tag> <word> <rest of line as string>
//! \ref word descriptive text (string)
//! \ref w descriptive text (string)
<tag> <word> <word> <rest is normal HL>
//! \image word1 word2 b descriptive text (string)
//! \image a word b descriptive text (string)
<tag> <rest of line is string>
//! \brief A b c d e description should go on here
<tag> <word> <rest of line is normal doxygen HL mode>
//! \file word rest of line is normal comment HL
//! \file a word rest of line is normal comment HL
no doxygen HL mode here.
== END OF TESTFILE ==
@@ -0,0 +1,107 @@
port module Test exposing
( (&&)
, Expect(..)
, Test
, run
)
{-| Module documentation
# Test
@docs Test, Expect
# Functions
@docs run
# Operator
@docs (&&)
-}
import Multiline as ML
exposing
( Data(..)
, Payload(..)
, response
)
import Singleline as SL exposing (Dale(..), Single)
-- test file for Elm syntax highlighting in KDE's Kate
-- this is a single-line comment
{-
this is a multi-line comment
-}
infix left 0 (|>) = apR
infix right 3 (&&) = and
infix non 4 (>=) = ge
type T
= T
| A
| G
| C
type alias Alt =
T
operator : Int -> Int -> Int
operator =
(+)
conditional : number -> number -> Maybe number
conditional a b =
if b == 0 then
Nothing
else if a == 0 then
Just 0
else
Just (a / b)
lambda = Int -> Int
lambda a =
(\a -> a + 35)
{-| Documentation comment
Should be same as comment
-}
caseStatement : Maybe number -> number -> number
caseStatement a b =
case a of
Just a_ ->
a_
_ ->
b
record : { float : Float, int : Int }
record =
{ float = 1.455321, int = 83 }
tuple : ( Float, Float )
tuple =
( 3.14, 9.553 )
port portTest : () -> Cmd msg
@@ -0,0 +1,68 @@
% testing for the erlang syntax highlighter
% NOTE alerts work in comments to TODO !
% pragmas (show as keywords)
-module
-export
-define
-undef
-ifdef
-ifndef
-else
-endif
-include
-include_lib
% key words
after begin case catch cond end fun if let of query receive all_true some_true
% operators
div rem or xor bor bxor bsl bsr and band not bnot
+ - * / == /= =:= =/= < =< > >= ++ -- = ! <-
% separators (show as functions)
( ) { } [ ] . : | || ; , ? -> #
% functions - predefined (part of erlang module) - show as functions
abs accept alarm apply atom_to_list binary_to_list binary_to_term check_process_code
concat_binary date delete_module disconnect_node element erase exit float float_to_list
garbage_collect get get_keys group_leader halt hd integer_to_list is_alive is_atom is_binary
is_boolean is_float is_function is_integer is_list is_number is_pid is_port is_process_alive
is_record is_reference is_tuple length link list_to_atom list_to_binary list_to_float list_to_integer
list_to_pid list_to_tuple load_module loaded localtime make_ref module_loaded node nodes now
open_port pid_to_list port_close port_command port_connect port_control ports pre_loaded process_flag
process_info processes purge_module put register registered round self setelement size
spawn spawn_link spawn_opt split_binary statistics term_to_binary throw time tl trunc tuple_to_list
unlink unregister whereis
% functions - inferred
module:function
function()
% atoms (show as "char")
% begin with underscore, lowercase, contain numbers letters and @ - or anything between ''
middle_underscore
abc ab4d a@cd8 a@
'And this is (\012) an atom \' Atoo' Variable 'atom again'
% variables (begin with capital letter or underscore, contain numbers, letters and @)
_leadingUnderscore AbdD@ B45@c
% this is a string
"a string sits between \" double quotes" atom "more string"
% integers (decimal)
1. 234 $A
% integers (specified base)
2#10101 34#567
% float
12.23 12.9e-67 12.8E+89 33.34e89
% and finally some real code, so we can see what it looks like...
-module(codetest). % everything is in a module
-export([fac/1]). % name and number of arguments - need this to be called outside of the module
fac(N) when N > 0 -> N * fac(N-1);
fac(N) when N == 0 -> 1.
@@ -0,0 +1,97 @@
-- Test file for Kate's Euphoria syntax highlighting/code folding.
-- BEGIN region marker test
-- code here
-- END region marker test
-- The N Queens Problem:
-- Place N Queens on an NxN chess board
-- such that they don't threaten each other.
constant N = 8 -- try some other sizes
constant ROW = 1, COLUMN = 2
constant TRUE = 1, FALSE = 0
type square(sequence x)
-- a square on the board
return length(x) = 2
end type
type row(integer x)
-- a row on the board
return x >= 1 and x <= N
end type
function threat(square q1, square q2)
-- do two queens threaten each other?
if q1[COLUMN] = q2[COLUMN] then
return TRUE
elsif q1[ROW] - q1[COLUMN] = q2[ROW] - q2[COLUMN] then
return TRUE
elsif q1[ROW] + q1[COLUMN] = q2[ROW] + q2[COLUMN] then
return TRUE
elsif q1[ROW] = q2[ROW] then
return TRUE
else
return FALSE
end if
end function
function conflict(square q, sequence queens)
-- Would square p cause a conflict with other queens on board so far?
for i = 1 to length(queens) do
if threat(q, queens[i]) then
return TRUE
end if
end for
return FALSE
end function
integer soln
soln = 0 -- solution number
procedure print_board(sequence queens)
-- print a solution, showing the Queens on the board
integer k
position(1, 1)
printf(1, "Solution #%d\n\n ", soln)
for c = 'a' to 'a' + N - 1 do
printf(1, "%2s", c)
end for
puts(1, "\n")
for r = 1 to N do
printf(1, "%2d ", r)
for c = 1 to N do
if find({r,c}, queens) then
puts(1, "Q ")
else
puts(1, ". ")
end if
end for
puts(1, "\n")
end for
puts(1, "\nPress Enter. (q to quit) ")
while TRUE do
k = get_key()
if k = 'q' then
abort(0)
elsif k != -1 then
exit
end if
end while
end procedure
procedure place_queen(sequence queens)
-- place queens on a NxN chess board
-- (recursive procedure)
row r -- only need to consider one row for each queen
if length(queens) = N then
soln += 1
print_board(queens)
return
end if
r = length(queens)+1
for c = 1 to N do
if not conflict({r,c}, queens) then
place_queen(append(queens, {r,c}))
end if
end for
end procedure
@@ -0,0 +1,31 @@
* This file is an example to test the syntax highlighting file fortran-fixed.xml
* (for fortran, fixed format)
c <-- this is a comment in the old fortran 77 style (fixed form)
c In the free form file, so we shouldn't use this kind of comments!
c But fortran 90 still understands fixed form, when parsing sources with
c the *.f extension.
* this 'c' shouldn't be highlighted as a comment!
c
* Prints the values of e ** (j * i * pi / 4) for i = 0, 1, 2, ..., 7
* where j is the imaginary number sqrt(-1)
PROGRAM CMPLXD
IMPLICIT COMPLEX(X)
PARAMETER (PI = 3.141592653589793, XJ = (0, 1)) this text should be highlighted as a comment because it is after the 72th column (ignored by the compiler)
DO 1, I = 0, 7
X = EXP(XJ * I * PI / 4)
IF (AIMAG(X).LT.0) THEN
PRINT 2, 'e**(j*', I, '*pi/4) = ', ! I am an in-line comment
* REAL(X), ' - j',-AIMAG(X) ! the character at the 6th column indicate a continuation line and should be highlighted as a continuation character
ELSE
PRINT 2, 'e**(j*', I, '*pi/4) = ',
* REAL(X), ' + j', AIMAG(X)
END IF
FORMAT (A, I1, A, F10.7, A, F9.7)
CONTINUE
ENDDO
STOP
END
@@ -0,0 +1,177 @@
! This file is an example to test the syntax highlighting file fortran-free.xml
! (for fortran, free format)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! THIS IS AN EXAMPLE OF A MODULE !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
module module_example
! use 'implicit none' when you want all variables to be declared
implicit none
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! PUBLICS AND PRIVATES
! In fortran 90 you can define your own operator
public :: operator(.norm.)
public :: operator(+) ! <-- you can also overload the usual operators
public :: factorial
public :: example_fn
private :: point3d_add
private :: point3d_norm
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! USER-DEFINED TYPES...
! This is a definition to use in declarations of real variables,
! parameters, etc.
integer, parameter, public :: kr = selected_real_kind(10)
! This is a user-defined type
type, public :: point3d
real(kind=kr) :: x, y, z
end type point3d
! This type is useless: it is only an example of type definition!
type, public :: example_type
complex(kind=kr) :: c ! <-- a complex number (two reals of kind kr)!
real, dimension(-10:10) :: & ! <-- this line does not end here!
r1, r2 ! <-- this is the final part of the previous line
real, pointer, dimension(:) :: pointer_to_array_of_real
real, dimension(:), pointer :: array_of_pointer_to_real
end type example_type
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! INTERFACES...
! Interface for the norm of a 3-D vector
interface operator(.norm.)
module procedure point3d_norm
end interface
! Interface for the operator '+'
interface operator(+)
module procedure point3d_add
end interface
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! SOME DECLARATIONS...
! A real number can be declared with the following line:
real(kind=kr) :: real_var1
! But if you are not interested on the precision of floating point numbers,
! you can use simply:
real :: real_var2
! An array can be declared in two ways:
real(kind=kr), dimension(1:10, -4:5), private :: a, b, c
real(kind=kr), private :: d(1:10, -4:5)
! This is a string with fixed lenght
character(len=10) :: str_var
! This is an allocatable array, which can be a target of a pointer
type(example_type), private, dimension(:), allocatable, target :: &
many_examples
! Fortran 90 hasn't got its own preprocessor, it uses the C preprocessor!
#ifdef XXX
#endif
contains
! The sum of two points
pure function point3d_add(a, b) result(rs)
type(point3d) :: rs
type(point3d), intent(in) :: a, b
rs%x = a%x + b%x
rs%y = a%y + b%y
rs%z = a%z + b%z
end function point3d_add
! The norm of a point
pure function point3d_norm(a) result(rs)
real(kind=kr) :: rs
type(point3d), intent(in) :: a
rs = sqrt(a%x * a%x + a%y * a%y + a%z * a%z)
end function point3d_norm
! A simple recursive function
recursive function factorial(i) result (rs)
integer :: rs
integer, intent(in) :: i
if ( i <= 1 ) then
rs = 1
else
rs = i * factorial(i - 1)
end if
end function factorial
! This is a useless function
subroutine example_fn(int_arg, real_arg, str_arg)
integer, intent(in) :: int_arg
real(kind=kr), intent(out) :: real_arg
character(len=*), intent(in) :: str_arg
type(example_type), pointer :: p
integer :: n, i, j
logical :: flag
flag = .true. ! .true. is not an operator!
if ( flag .and. flag ) then ! .and. is a pre-defined operator
print *, "blabla"
end if
! Examples of inquiry functions: allocated, lbound, ubound.
if ( .not. allocated(many_examples) ) then
allocate( many_examples(10) )
end if
print *, "Lower bound = ", lbound(many_examples, 1)
print *, "Upper bound = ", ubound(many_examples, 1)
p => many_examples(5) ! <-- p is a pointer
! A strange way to calculate i*i: add the first i odd numbers
i = 6
j = 0
do n = 1, i
j = j + (2*n - 1)
end do
print *, "i*i = ", i*i, j
real_arg = real(j) ! <-- here the highlighting is not very good:
! it is unable to distinguish between this and a definition like:
! real(kind=kr) :: a
deallocate( many_examples )
end subroutine example_fn
end module module_example
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! THIS IS THE MAIN PROGRAM !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
program example
use module_example
! this is another example of use of the 'implicit' keyword
implicit double precision (a-h,o-z)
real(kind=kr) :: var_out
type(point3d) :: &
a = point3d(0.0_kr, 1.0_kr, 2.0_kr), &
b = point3d(4.0_kr, 5.0_kr, 6.0_kr)
print *, "a + b = ", .norm. (a + b)
print *, "factorial of 5 = ", factorial(5)
call example_fn(1, var_out, "hello!")
end program example
@@ -0,0 +1,499 @@
### Comments
# TODO
# BEGIN
# fg sfg sfh sft
# END
#
# text in (parenthesis) is ok, (even
# over several lines)
# escaped \) and \( are ok
# an unbalanced single ) is not ok
# This is due to fish comment handling in command substitutions
# which cannot reasonably handled by kate syntax highlighting
### Commands and paths
ls -l |sort
ls -1
/usr/bin/ls -l /usr/local/test/ -xyz # option as indicator of CommandArgs context
./bin/ls -l /usr/abc**/tes?/lkhlk -xyz # tabulator as separator
../bin/ls -l /usr/abc**/tes?/lkhlk
~/bin/ls -l ../usr/lo\ cal/test
~user/bin/ls -l /usr/{local,remote}}/test|cat # show error
/usr/bin/../lib/ls -l /usr/local/test.???|cat
/usr/bin\ sdfg/ls -l /usr/local/test.*
usr/bin/other -l ~user/local/test
\ usr/bin/other -l ~user/local/test
/usr/bin/lsother
../test/root/bin/fish -c "echo $t8"
test/root/bin/fish -c "echo $t8"
u?r/bin/ls
usr/b?n/ls
u*ls # doesn't work, but ok
"ls" /tmp/testtest # Quotes in commands are expanded
/us"r/bin"/xy/ls
abcd$a # show error
other) abc # show error
<other abc # show error
other> abc # ok
oth>er abc # ok
ot(her) abc # show error
-cmd
déjà-vu
ls /ho"me/te"st'user'/abc$dir[3]/ab(echo cdefg)cd/xyz
cat\ alog -abc
ls path_not_detected
ls * no_path
ls *path_detected
ls/
ls;echo xy
flex++
echo [abc] abc
#specials
command -s ls
builtin --names jobs
exec bash
exec $test
set -e i[-1]
set test1[-1..1] $test; echo $test1
set test1[1..$n] $test; echo $test1
set test1[$n..1] $test; echo $test1
set test1[2..4 -2..-4] $test1[4..2 -4..-2]; echo $test1
set test1[2..4 -2..-4][1] $test1[4..2 -4..-2][1]
# ~~~ invalid
set test1\
[2..4 -2..-4]\
[1] a
#~~ invalid
set test1 \
#bla bla
a b c
set page_url http://fishshell.com/docs/$version_string/$fish_help_page # ???
string split . example.com
set b (string repeat -n 512 x)
read -gi test # ok
read -gi $test
read -gi "test"
read -gi (echo test)
set x (string split --max 1 --right / (status current-filename) #Comment test)
set test (exec $cmd)
# direct path
test -d $tmpldir/resources
### Options
cat -l /usr/local/test>logfile
ls --longopt=/test
ls -l"kasdflakjs" -r/usr/test -x../test/../bla -z~xyz/hello
### Arguments
echo abc"def"ghi
echo abc/def
echo abc[de]
echo abc(echo def)ghi
echo abc{de,f}ghi
# Path Detection
cd abc*efghi # fish assumes * is glob -> path
cd abc?efghi
cd ..
cd .. #
cd .
cd . #
cd ~
cd ~abc/abc/*.txt
cd ./abc
cd ../abc
cd \ abc/tmp\ .txt
test .. abc
### Escapes
touch a\?bc\[\]ax\~dsf\#gsd\af\(\)dg\?sd\ fg\bhh\%j\$k\\l\?sed\*jk\>hj\<hou\&h\;hgkj\^kj\"kjh\'jhg
touch sdf\xa5lh\Xb7kll\157j\158hk\ua47bz\U123b5678fs\cxzdfga
touch "a\?bc\[\]a" # no escaping in Quotes
touch fgh\y1 # \y is no escape sequence in fish, show it as normal text like fish itself
### Builtins
. hallo
source hallo
eval ls . /tmp
eval ls .../tmp
eval $var
eval abc
eval {l,a}s # lists ./as. colours not ok, but we cut here
eval "echo bla"
history merge
true ;ls
echo (true)
echo (true #comment)
echo (true>>xyz/abc)
true -error # show error
pwd > abc
command -s ls;cat test
builtin -n;builtin echo
complete -c myprog -s o -l output -a "yes no"
builtin jobs
math -s0 10.0 / 6.0
#special keywords as directory names:
/usr/function/testtest /usr/function/testtest
/usr/for/testtest /usr/for/testtest
/usr/begin/testtest /usr/begin/testtest
/usr/switch/testtest /usr/switch/testtest
/usr/if/testtest /usr/if/testtest
/usr/while/testtest /usr/while/testtest
/usr/command/testtest /usr/command/testtest
/usr/builtin/testtest /usr/builtin/testtest
/usr/eval/testtest /usr/eval/testtest
/usr/exec/testtest /usr/exec/testtest
/usr/set/testtest /usr/set/testtest
/usr/test/testtest /usr/test/testtest
### test
test NUM1 -eq NUM2
test -f /tmp/abc -a -e /tmp/def;cat /tmp/abc;
if test \( -f /foo -o -f /bar \) -a \( -f /baz -o -f /bat \)
echo Success.
end
[ 25 -eq $NUM2 ]
[ "abc" = "$STRING2" ]
if [ ! \(STRING1 != STRING2\) ];ls;end
if [ -f abc ]# show error
end
if [ -f abc ] # ok
end
if [ ! \(STRING1 != STRING2\) ] ls;end # show error
if [ "abc" != "def" ] # hallo
echo x;end
### Redirections
ls < SOURCE_FILE # stdin
ls > DESTINATION # stdout
ls ^ DESTINATION # stderr
ls >> DESTINATION_FILE # append
ls ^^ DESTINATION_FILE # append
ls >? DESTINATION # noclobber
ls ^? DESTINATION
ls ^? ~
ls ^? ~testuser/abc
ls ^?/DESTINATION
ls ^?#DESTINATION # show error
ls > $abc[5]
ls >"abc"/defg$v/xyz
ls >& # show error
ls > &1 # show error
ls abc>&25 xyz /tmp/xyz $abc
ls /tmp/tst>&25? # show error
ls /tmp/tst>&25 ? # ok
ls 3>&- xyz
ls 1<DESTINATION
echo Hello > all_output.txt ^&1 xyz
ls 2>&-;echo end
ls xyz 2>|cat
ls>x
abs>x
/bin/ls>x
/bin/abs>x
### Quoting
echo 'abcdefg'
echo 'abc\'de\\fg'
echo 'abc\defg'
echo "1\"23\$45\\6"
echo '1\"23\$45\\6'
echo '
hallo
'
echo "$i: '$$name[1][$i]'"
### Piping, Pipelines and background jobs
ls -l /tmp/hello 1<DEST| sort
comand_1;command_2
comand_1 ;command_2
ls;ls
run_long_job & ls # yes & is a command sequencing operator like | and ;
cat foo.txt | head
make fish 2>| less #show error
### Variable Expansion
echo $PATH
echo $PATH[1..3]
echo $PATH[-1..3 5 9..15]
echo $PATH[$n[2]]
echo $test[1..$n]
echo $test[$n..1]
echo The plural of $WORD is "$WORD"s
echo The plural of $WORD is {$WORD}s
echo $$foo[$i]
echo $test[(count $test)..1]
echo $test[1..(count $test[3])]
echo $$foo[1..-1][5]
echo $$foo[1..-1]\
[5][2]\
[5]
#show error
echo $PATH[error
echo $PATH[1..error]
echo $PATH[1 2 34 ]
echo $PATH[1.. 2]
echo $PATH[1 ..2]
### Brace Expansion
echo input.{c,12h,TXT}
echo input.{abc$test[(count $test)..1],(echo $txt)}
echo input.{a{b,c},12h,TXT}} # show error
### Index range expansion
echo (echo $a)[2..5]
echo (echo $a)[2..5 1..3]
echo (echo $a)[-1..1]
### Process expansion
fg %ema # ???
### Command substitution
echo -n -s "$USER" @ "$__fish_prompt_hostname" ' ' (set_color $color_cwd) (/usr/bin/ls) (set_color normal)
echo (#hallo)abc # ok
echo (ls #hallo)abc # ok, die context-Tiefe ist anders
echo (ls;#hallo)abc # als hier.
echo (ls#hallo)abc # ok: # may be inner part of function names!
echo (/usr/bin/ls)
echo (ls >>mem/abc)
echo (echo $test[2])
echo (/usr"/bi"n/ls /tmp)
echo (seq 10)[1][2]
# ~~~ not an index
echo (seq 10)\
[1][2]
# ~~~ not an index
echo (seq 10)\
[1]\
[2]
#~~ not an index
# multline command substitution
set x (echo dirlist; # blabla
ls)
## same, but commented out:
# set x (echo dirlist; # blabla
# ls)
set pi (math "scale=10; 4*a(1)")
### Continuation lines
ls \
/usr/bin
test "STRING1"="STRING2" -a \
"STRING3" = (echo "STRING4")
echo input.{abc\
,12h,\
TXT}
echo (\
ls)
# no line continuation within single quotes
echo 'abcdefg\
s$dfg sdf'
# but within double quotes
echo "123456\
78910"
echo $PATH[1..3\
]
ls /usr\
local/bin
echo foo\ bar
echo foo\
bar
for i \
in \
a b c
echo $i
end
# Bug?
# Depending on weakDeliminators, either this works:
cat\ alog -abc
# or this:
builtin\
--names jobs
builtin \
--names jobs
command \
ls
eval \
ls . /tmp
eval\
ls .../tmp
set \
-e i[-1]
set \
test1[-1..1] \
$test; \
echo $test1
read \
-gi test
# see https://github.com/fish-shell/fish-shell/pull/1987
echo before comment \
# comment
# comment2
after comment # just another argument
echo before comment\
# comment ^ no space
# comment2
after comment # a command
from root
echo "hello" | \
#remove 'l'
#and more
tr -d 'l'
### Trouble
make; and make install; or make clean # ok
printf '%s\t%s\n' flounder fish # ok
diff (sort a.txt | psub) (sort b.txt | psub)
source-highlight -f esc (cpp main.c | psub -s .c)
while test -f foo.txt # comment
echo hallo
end
for i in {1,(ls),3} # comment
echo $i
end
# function
function __hidden # comment
cd /
end
function ll \
-d "multiline
description"
ls -l $argv
end
function ls --description="Description" -a a b c # comment
command ls --color=auto $argv
if test -f foo.txt
echo foo.txt exists
else if test -f bar.txt # comment
echo bar.txt exists
else
echo foo.txt and bar.txt do not exist
end # comment
end
function test;echo hallo;end # comment
switch $animal # comment
case cat # comment
echo evil
case wolf \
dog
echo mammal
case '*'
echo I have no idea what a $animal is
end
if test (count $argv) = 1
echo $argv
else
echo "?"
end
if not test -f spoon #comment
echo There is no spoon
else
exit 1
end
for file in $cfgfiles
if test -f $file
string match -r '\[Dialer' < $file | string replace -r '\[Dialer (.+)\]' '$1'
end
end | sort -u | string match -v Defaults
for i in *.c
if grep smurf $i # comment
echo Smurfs are present in $i
break
end
end
if begin contains -- $argv --force # ohne ; nach begin: geht
or not status --is-interactive and not status --is-login
end
echo ""
end
begin # comment
for i in *.tmp
if grep smurf $i
continue
end
rm $i
end
end
if [ $status -eq 1 ]
set sta pass
else
set sta fail
end
exec "$test"
# Process Expansion
# see fish issue 4230
kill -STOP %self
endcmd # is a command
for inc in a # inc is a variable
end
switch d;case "*" ; case d;echo; end
if ; else if ; else if ; if ; else ; end;else ; end
@@ -0,0 +1,148 @@
/* This test file tests Kate's ANTLR highlighting
compilable bt ANTLR although not directly:
grammar can be alone file for both parser and lexer
or two files
This file is merged TestParser.g4 and TestLexer.g4
this lines also tests regions of multiline comment
*/
//file TestParser.g4
parser grammar TestParser;
options { tokenVocab = TestLexer; }
// The main entry point for parsing a grammar.
startRule
: (expression | STRING)+ EOF
;
expression
: expression PLUS mulExpr
| expression MINUS mulExpr
| mulExpr
;
mulExpr
: mulExpr MUL unaryExpr
| mulExpr DIV unaryExpr
| unaryExpr
;
unaryExpr
: atom
| LPAR expression RPAR
;
atom
: IDENT
| number
;
number
: INT
| FLOAT
;
//================================
//file TestLexer.g4
lexer grammar TestLexer;
/*'channels' and '{' must be in one line
to correct highlighting, highlighter can't
recognize regular expression "(options|tokens|channels)(?=([\s]*{))"
where apart from \s whitrspaces are end of lines
*/
channels { OFF_CHANNEL , COMMENT }
PLUS
: '+'
;
MINUS
: '-'
;
MUL
: '*'
;
DIV
: '/'
;
LPAR
: '('
;
RPAR
: ')'
;
IDENT
: Nondigit
( Nondigit
| Digit
)*
;
fragment
Digit
: [0-9]
;
fragment
NonzeroDigit
: [1-9]
;
fragment
Nondigit
: [a-zA-Z_]
;
Sign
: '+' | '-'
;
INT
: Sign? (NonzeroDigit Digit* | '0')
;
fragment
DigitSequence
: Digit+
;
fragment
ExponentPart
: [eE] Sign? DigitSequence
;
fragment
FractionalConstant
: DigitSequence? '.' DigitSequence
| DigitSequence '.'
;
FLOAT
: (FractionalConstant ExponentPart? | DigitSequence ExponentPart)
;
fragment
EscapeSequence
: '\\' ['"?abfnrtvhe\\]
;
//between [] is charset , test escape \
fragment
SChar
: ~["\\\r\n]
| EscapeSequence
;
STRING
: '"' SChar* '"'
;
@@ -0,0 +1,157 @@
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from your_application...done.
(gdb) break main
# this is a comment
(gdb) run <arguments for your application>
...
Breakpoint 1 at 0x400b56: file yourmain.cpp, line 3
3: int main(int argc, char* argv[])
(gdb) continue
(gdb) backtrace
#0 0x7f59e39bf18d in poll () from /usr/lib/libc.so.6
#1 0x7f59df6c8c7c in ?? () from /usr/lib/libglib-2.0.so.0
#2 0x7f59df6c8d8c in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#3 0x7f59e480b23f in QEventDispatcherGlib::processEvents(...)
from /usr/lib/libQt5Core.so.5
...
(gdb) where
#0 main (argc=1, argv=0x7fffffffca88) at ../../debugging/ex_debugger/main.cpp:11
(gdb) list
10 bool run = true;
11 while (run) {
12 // infinite loop! can you make it quit?
13 }
(gdb) info locals
app = <incomplete type>
run = true
complexData = {{d = 0x61d430, e = 0x61d430}}
(gdb) info scope main.cpp:12
Scope for main.cpp:12:
Symbol argc is a variable at frame base reg $rbp offset 0+-8, length 4.
Symbol argv is a variable at frame base reg $rbp offset 0+-16, length 8.
(gdb) ptype run
type = bool
(gdb) print run
run = true
(gdb) set run = false
(gdb) print run
run = false
(gdb) print myString.size()
42
(gdb) ptype MyType
type = class MyType {
private:
int foo;
public:
int foo() const;
...
}
(gdb) break QMessageLogger::warning
Breakpoint 1 at 0x7ffff6f143f0 (8 locations)
(gdb) command 1
Type commands for breakpoint(s) 1, one per line.
End with a line saying just \"end\".
> backtrace
> continue
> end
(gdb) catch throw # or when an exception is thrown
Catchpoint 2 (throw)
(gdb) break main.cpp:12 # or when certain code is executed
Breakpoint 3 at 0x401216: file ../../debugging/ex_debugger/main.cpp, line 12.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x7ffff6f143f0 <QMessageLogger::warning(char const*, …
...
2 breakpoint keep y 0x7ffff66d9b90 exception throw
3 breakpoint keep y 0x000000401216 in main(int, char**)
at debugging/ex_debugger/main.cpp:12
(gdb) condition 3 argc > 5
# ^-- breakpoint id, see `info breakpoints` above
(gdb) call myFunction()
(gdb) set pagination off
(gdb) set logging file /tmp/warnings.log
(gdb) set logging on
Copying output to /tmp/warnings.log.
(gdb) info threads
Id Target Id Frame
2 Thread 0x7fffe10e1700 (LWP 7271) \"QXcbEventReader\"
0x7ffff0b6718d in poll () from /usr/lib/libc.so.6
* 1 Thread 0x7ffff7edd840 (LWP 7267) \"kwrite\"
0x7ffff0b6718d in poll () from /usr/lib/libc.so.6
(gdb) thread
[Current thread is 1 (Thread 0x7ffff7edd840 (LWP 7267))]
(gdb) thread 2
[Switching to thread 2 (Thread 0x7fffe10e1700 (LWP 9765))]
(gdb) thread apply all backtrace
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x7ffff7ddbb80 0x7ffff7df5610 Yes (*) /lib64/ld-linux-x86-64.so.2
0x7ffff7690460 0x7ffff7ab723c Yes /opt/qt/5.5/gcc_64/lib/libQt5Gui.so.5
0x7ffff6efdb80 0x7ffff71af318 Yes /opt/qt/5.5/gcc_64/lib/libQt5Core.so.5
0x7ffff6c02f60 0x7ffff6c5f852 Yes (*) /usr/lib/libGL.so.1
0x7ffff69d3ac0 0x7ffff69e0931 Yes (*) /usr/lib/libpthread.so.0
0x7ffff66d5fa0 0x7ffff6781d89 Yes /usr/lib/libstdc++.so.6
0x7ffff6353510 0x7ffff63bb33a Yes (*) /usr/lib/libm.so.6
...
(*): Shared library is missing debugging information.
(gdb) list 64
59 * If no red can be seen, then the cached implementation is \"good enough\".
60 */
61 void paintEvent(QPaintEvent *event)
62 {
63 const QRect rect = event->rect();
64
65 QPainter painter(this);
66 painter.setRenderHint(QPainter::Antialiasing);
67 painter.fillRect(rect, Qt::black);
68
(gdb) dprintf main.cpp:64,\"paint rect(w=%d,h=%d)\\n\",rect.width(),rect.height()
Dprintf 1 at 0x403a1e: file path/to/main.cpp, line 64.
(gdb) continue
Continuing.
paint rect(w=202,h=200)
paint rect(w=213,h=203)
(gdb) target remote <device ip>:<port>
Remote debugging using <device ip>:<port>
Reading /lib64/ld-linux-x86-64.so.2 from remote target...
warning: File transfers from remote targets can be slow.
Use \"set sysroot\"to access files locally instead.
...
(gdb) set sysroot /path/to/sysroot
(gdb) print myMap
$1 = QMap<QString, int> = {
[\"bar\"] = 1,
[\"foo\"] = 2
}
(gdb) print money
$1 {
{value = 1.20000005, currency = Money::Euro},
{value = 3.4000001, currency = Money::Dollar}
}
(gdb) python
> import sys
> sys.path.insert(0, '/path/to/addon/debugging/ex_gdb_pretty_printer')
> import money_printer
> end
(gdb) print money
$2 = {
\"1.200000 Euro\",
\"3.400000 Dollar\"
}
(gdb) continue
(gdb) detach
(gdb) quit
@@ -0,0 +1,9 @@
python
import sys
sys.path.insert(0, '/home/milian/projects/compiled/kf5/share/kdevgdb/printers/')
sys.path.insert(0, '/home/milian/projects/kdab/training-material/addon/debugging/ex_gdb_pretty_printer')
import money_printer
import money_printer_qtcreator
end
source /home/milian/projects/compiled/kf5/share/kdevgdb/printers/gdbinit
@@ -0,0 +1,89 @@
// This is a test file for the Katepart GLSL Syntax Highlighting.
normal text
// this is a single-line comment
normal text
/* this
is a multi-line
comment */
normal text
some_symbol.some_member;
some_symbol.some_member_function();
some_function();
// this is a function
void main()
{
float f = 1.4e3; // decimal float literal
int i1 = 2884; // decimal int literal
int i2 = 0x44; // hex int literal
int i3 = 0456; // octal int literal
}
// this is a structure
struct some_struct
{
vec3 some_member_vector;
};
# this is
#preprocessor code
// all keywords
break continue do for while
if else
true false
discard return
struct
// all basic types
float int void bool
mat2 mat3 mat4
vec2 vec3 vec4
ivec2 ivec3 ivec4
bvec2 bvec3 bvec4
sampler1D sampler2D sampler3D
samplerCube sampler1DShadow sampler1DShadow
// all type qualifiers
attribute const uniform varying
in out inout
// attensions:
// FIXME
// TODO
// BUG
// some of the std functions
radians degrees sin cos tan asin acos atan
// some of the std variables
gl_Position gl_PointSize gl_ClipVertex
#version 330 core
// single line comment
/* single line commonet */
/*
multi line comment
*/
in ColorFormat {
vec3 color;
} fs_in;
out vec4 fragColor;
vec3 fun(const in vec3 foo) {
foo[2] = foo.x;
return foo;
}
void main()
{
fragColor = vec4( fs_in.color, 1.0 );
}
@@ -0,0 +1,31 @@
# Examples taken from https://graphql.org/learn/schema/#type-language
#
# Alerts: TODO FIXME
query Hero($episode: Episode, $withFriends: Boolean!) {
hero(episode: $episode) {
name
friends @include(if: $withFriends) {
}
}
}
query {
droid(id: "2000", num: 42, active: true) {
name
}
}
type Person @addExternalFields(source: "profiles") @excludeField(name: "photo") {
name: String
}
# block strings (from https://github.com/graphql/graphql-spec/blob/master/spec/Section%202%20--%20Language.md)
"""
This starts with and ends with an empty line,
which makes it easier to read.
"""
"""This does not start with or end with any empty lines,
which makes it a little harder to read."""
@@ -0,0 +1,197 @@
%title
= @title
\= @title
%script{
"type": "text/javascript",
"src": "javascripts/script_#{2 + 7}",
"data": {
"controller": "reporter",
},
}
%div{:id => [@item.type, @item.number], :class => [@item.type, @item.urgency]}
%div{:id => "#{@item.type}_#{@item.number}", :class => "#{@item.type} #{@item.urgency}"}
.item{:class => @item.is_empty? && "empty"}
%a(title=@title href=href) Stuff
%a(title=@title){:href => @link.href} Stuff
%a{:href=>"/posts", :data => {:author_id => 123, :category => 7}} Posts By Author
.book-info{:data => {:book => {:id => 123, :genre => 'programming'}, :category => 7}}
%div#things
%span#rice Chicken Fried
%p.beans{ :food => 'true' } The magical fruit
%h1.class.otherclass#id La La La
%br/
%meta{'http-equiv' => 'Content-Type', :content => 'text/html'}/
%p[user]{:class => 'alpha bravo'}
%blockquote<
%div
Foo!
%img
%img>
%img
%img
%pre><
foo
bar
%img
-# file: app/views/users/show.haml
%p
hello
%div[@user, :greeting]
%bar[290]/
Hello!
- user = User.find(1)
.foo.moo{:class => ['bar', 'alpha']}(class='baz')
!!! XML
%peanutbutterjelly
/ This is the peanutbutterjelly element
I like sandwiches!
/
%p This doesn't render...
%div
%h1 Because it's commented out!
%p
/[if IE]
%a{ :href => 'http://www.mozilla.com/en-US/firefox/' }
%h1 Get Firefox
%p foo
-# This is a comment
%p bar
%p foo
-#
This won't be displayed
Nor will this
Nor will this.
%p bar
%p
= ['hi', 'there', 'reader!'].join " "
= "yo"
= link_to_remote "Add to cart",
:url => { :action => "add", :id => product.id },
:update => { :success => "cart", :failure => "error" }
- foo = "hello"
- foo << " there"
- foo << " you!"
%p= foo
- links = {:home => "/",
:docs => "/docs",
:about => "/about"}
- (42...47).each do |i|
%p= i
%p See, I can count!
%p
- case 2
- when 1
= "1!"
- when 2
= "2?"
- when 3
= "3."
~ "Foo\n<pre>Bar\nBaz</pre>"
%p This is #{h quality} cake!
%p
Look at \\#{h word} lack of backslash: \#{foo}
And yon presence thereof: \{foo}
&= "I like cheese & crackers"
& I like #{"cheese & crackers"}
= "I feel <strong>!"
!= "I feel <strong>!"
! I feel #{"<strong>"}!
%whoo
%hoo= h( |
"I think this might get " + |
"pretty long so I should " + |
"probably make it " + |
"multiline so it doesn't " + |
"look awful.") |
%p This is short.
!!!
%html{ :xmlns => "http://www.w3.org/1999/xhtml", :lang => "en", "xml:lang" => "en"}
%head
%title BoBlog
%meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}
%meta(http-equiv="Content-Type" content = "text/html; charset=utf-8" class=21 id='d3')
%link{rel: 'stylesheet', href: 'main.css', type: 'text/css'}
:css
body {
font-size: 16px;
margin-top: 0px;
margin-bottom: 0px;
font-family: Arial, sans-serif;
}
p {
margin: 0px;
padding: 0px;
}
%body
#header
%a{
href: root_path,
name: "home"
}
%h1 BoBlog
%h2 Bob's Blog
#content
- @entries.each do |entry|
.entry{ id: entry.id }
%h3.title= entry.title
%p.date
Posted on #{entry.posted.strftime("%A, %B %d, %Y")}
%p.body= entry.body
= button_to "Load more", entries_path,
class: "btn btn-primary",
method: :get,
params: { last_id: @entries.map(&:id).min },
form: { data: { turbo_stream: true } }
:ruby
provide(:title, user_title(@user))
provide(:og, user_opengraph(@user))
provide(:meta, user_twitter_card(@user))
parent_layout 'user/profile'
#footer
%p
All content copyright © Bob
#filterTest
%p Just testing some more HAML filters
:coffee
window.alert "Hello from CoffeeScript #{1}"
:coffeescript
window.alert "Hello from CoffeeScript again, #{1 + 1}"
:css
#filterTest {
display: none;
}
:erb
For some reason <%= "ERB works too #{@abcdef}" %>.
:plain
Anything else should be treated as plain text.
This also means that the following shouldn't be highlighted:
%h1#superawesomeheading Heading 1
%div Filter test done
@@ -0,0 +1,8 @@
THIS IS INVALID
:020000006428721
:10000800803120007F08FD002700931D0C280D2853
:0603D800890BEA29003444
:020000040001F9
:04000E0084EFFFDE9E
:04000E0884EFFFDE9E
:00000001FF
@@ -0,0 +1,142 @@
-- test file for Haskell syntax highlighting in KDE's Kate
-- The test file for literate Haskell can be easily created like this:
-- cat highlight.hs | sed -e "s|^|> |" -e "s|> -- ||" -e "s|^> $||" > highlight.lhs
-- You only have to manually edit the multi-line comment below.
-- this is a single-line comment
{- this is a multi-line comment
Things like "a string" or a 'c' character shouldn't be highlighted in here.
-- I could even start a new
-- one-line comment.
-}
import Prelude --
import Prelude ---
-- a data definition
data Tree a = Br (Tree a) (Tree a) | Leaf a | Nil deriving (Show, Eq)
-- function definition, "funnyfunction::", "Integer", "Int", "Bool" should be highlighted
funnyfunction::(Tree a)=>[a]->Integer->Int->Bool
-- strings and chars
-- first line of function definitions (type declaration) should be highlighted
strangefunction::Int->String
strangefunction 1 = "hello"
strangefunction 2 = "what's up"
strangefunction 3 = (strangefunction 1) ++ ", " ++ (strangefunction 2)
strangefunction 4 = 'a':'b':'c':'"':[] -- will return "abc"
strangefunction 5 = '\n':[]
strangefunction 6 = '\invalidhaskell':[]
-- function name including the single quote character
-- and infix operator (`div`)
justtesting'::Int->Int
justtesting' 2 = 2+1
justtesting' 9 = 7 `div` 2
-- same definition as above, slightly different function name and a couple more whitespaces
justtesting'' :: Int -> Int
justtesting'' 2 = 3
justtesting'' 9 = 3 + 9 - 9
-- the following lines are copied out of Haskell's "Prelude.hs"
infixl 7 *, /, `quot`, `rem`, `div`, `mod`, :%, %
-- everything highlighted except the "a"
class Bounded a where
minBound, maxBound :: a
class (Num a, Ord a) => Real a where
toRational :: a -> Rational
-- finally, some keyword lists
-- keywords
case, class, data, deriving, do, else, family, forall, if, in, infixl, infixr,
instance, let, module, of, pattern, primitive,
then, type, where
-- infix operators
quot, rem, div, mod, elem, notElem, seq
-- this stuff is not handled yet
!!, %, &&, $!, $, *, **, -,., /=, <, <=, =<<, ==, >, >=, >>, >>=, ^, ^^, ++, ||
-- functions
abs, acos, acosh, all, and, any, appendFile,
approxRational, asTypeOf, asin, asinh, atan, atan2, atanh, basicIORun,
break, catch, ceiling, chr, compare, concat, concatMap, const, cos, cosh,
curry, cycle, decodeFloat, denominator, digitToInt, div, divMod, drop,
dropWhile, either, elem, encodeFloat, enumFrom, enumFromThen,
enumFromThenTo, enumFromTo, error, even, exp, exponent, fail, filter, flip,
floatDigits, floatRadix, floatRange, floor, fmap, foldl, foldl1, foldr,
foldr1, fromDouble, fromEnum, fromInt, fromInteger, fromIntegral,
fromRational, fst, gcd, getChar, getContents, getLine, head, id, inRange,
index, init, intToDigit, interact, ioError, isAlpha, isAlphaNum, isAscii,
isControl, isDenormalized, isDigit, isHexDigit, isIEEE, isInfinite, isLower,
isNaN, isNegativeZero, isOctDigit, isPrint, isSpace, isUpper, iterate, last,
lcm, length, lex, lexDigits, lexLitChar, lines, log, logBase, lookup, map,
mapM, mapM_, max, maxBound, maximum, maybe, min, minBound, minimum, mod,
negate, not, notElem, null, numerator, odd, or, ord, otherwise, pi, pred,
primExitWith, print, product, properFraction, putChar, putStr, putStrLn,
quot, quotRem, range, rangeSize, read, readDec, readFile, readFloat,
readHex, readIO, readInt, readList, readLitChar, readLn, readOct, readParen,
readSigned, reads, readsPrec, realToFrac, recip, rem, repeat, replicate,
return, reverse, round, scaleFloat, scanl, scanl1, scanr, scanr1, seq,
sequence, sequence_, show, showChar, showInt, showList, showLitChar,
showParen, showSigned, showString, shows, showsPrec, significand, signum,
sin, sinh, snd, span, splitAt, sqrt, subtract, succ, sum, tail, take,
either, elem, encodeFloat, enumFrom, enumFromThen, enumFromThenTo,
enumFromTo, error, even, exp, exponent, fail, filter, flip, floatDigits,
floatRadix, floatRange, floor, fmap, takeWhile, tan, tanh, threadToIOResult,
toEnum, toInt, toInteger, toLower, toRational, toUpper, truncate, uncurry,
undefined, unlines, until, unwords, unzip, unzip3, userError, words,
writeFile, zip, zip3, zipWith, zipWith3
-- type constructors
Bool, Char, Double, Either, FilePath, Float, IO, IOError, Integer, Int, Maybe,
Ordering, Rational, Ratio, ReadS, ShowS, String
-- classes
Bounded, Enum, Eq, Floating, Fractional, Functor, Integral, Ix, Monad, Num, Ord, Read, RealFloat,
RealFrac, Real, Show
-- data constructors
EQ, False, GT, Just, LT, Left, Nothing, Right, True
-- promoted data constructors
'True
-- pragma with compiler flags
{-# OPTIONS_GHC -fno-warn-orphans #-}
-- multiline pragma with language extensions
{-# LANGUAGE OverlappingInstances,
BangPatterns
#-}
@@ -0,0 +1,53 @@
/* highlighting test case for Java */
// single line comment with ### TODO FIXME
/* multiline comment with ### TODO FIXME */
/** Javadoc comment with ### TODO FIXME
* @param foo bla bla ATTENTION
* @return abc cde
* @see javadoc.xml
*/
package org.kde.itinerary;
import org.qtproject.qt5.android.bindings.QtActivity;
import java.io.*;
import java.util.*;
public class Activity extends QtActivity
{
private static final String TAG = "org.kde.itinerary";
public void launchViewIntentFromUri(String uri)
{
Uri mapIntentUri = Uri.parse(uri);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, mapIntentUri);
startActivity(mapIntent);
}
@Override
protected String stuff()
{
while (true) {
}
int num = 1;
num = 0x2;
double f = .4e+49;
var other = "string";
var multilineString = """
string \\ \n
sdsda""";
long int_dec = 1__23_48l;
long int_oct = 072034__4l;
long int_hex = 0xa__12Ff_13L;
int int_bin = 0B1011___01;
double float_hex = 0x1f__a2.d_f10P+1074D;
float float_dec = 1__24.1_32e-1____23F;
float[] float_d = {1.,1.E+3,1.E+3f,1.F,1.1E+3d,1.1E+3,1.1f,1.1,.1E+3f,.1E+3,.1f,.1,1E+3f,1E+3,1f,1d};
assert 1 > 0;
}
}
@@ -0,0 +1,140 @@
h1. Biggest heading
h2. Bigger heading
h3. Big heading
h4. Normal heading
h5. Small heading
h6. Smallest heading
*strong* *strong*
_emphasis_ _emphasis_
??citation?? ??citation??
-deleted- -deleted-
+inserted+ +inserted+
^superscript^ ^superscript^
~subscript~ ~subscript~
{{monospaced}} {{monospaced}}
bq. Some block quoted text
on two lines
{quote}
here is quotable
content to be quoted
{quote}
{color:red}
look ma, red text!
{color}
(empty line)
\\
----
---
--
[#anchor]
[^attachment.ext]
[https://kate-editor.org]
[Kate|http://kate-editor.org]
[mailto:no-real-address-spam@kate-editor.org]
[file:///c:/temp/foo.txt]
[file:///z:/file/on/network/share.txt]
{anchor:anchorname}
[~username]
* some
* bullet
** indented
** bullets
* points
- different
- bullet
- types
# a
# numbered
# list
# a
# numbered
#* with
#* nested
#* bullet
# list
* a
* bulleted
*# with
*# nested
*# numbered
* list
!http://kate-editor.org/image.gif!
!attached-image.gif!
!image.jpg|thumbnail!
!image.gif|align=right, vspace=4!
!quicktime.mov!
!spaceKey:pageTitle^attachment.mov!
!quicktime.mov|width=300,height=400!
!media.wmv|id=media!
||heading 1||heading 2||heading 3||
|col A1|col A2|col A3|
|col B1|col B2|col B3|
{noformat}
preformatted piece of text
so *no* further _formatting_ is done here
{noformat}
{panel}
Some text
{panel}
{panel:title=My Title|borderStyle=dashed|borderColor=#ccc|titleBGColor=#F7D6C1|bgColor=#FFFFCE}
a block of text surrounded with a *panel*
yet _another_ line
{panel}
{code:xml}
<test>
<another tag="attribute"/>
</test>
{code}
{code:xml|borderStyle=solid}
<test>
<another tag="attribute"/>
</test>
{code}
{code:title=file.xml}
<test>
<another tag="attribute"/>
</test>
{code}
{code:title=Bar.java|borderStyle=solid}
// Some comments here
public String getFoo()
{
return foo;
}
{code}
@@ -0,0 +1,262 @@
#! shebang
#! no-shebang
/* comment */
function fun()
{
var boo = { 'key': [ 1, 2.0, 3.0e1, 004, 0x5 ] };
}
class MyClass; // reserved keywords
class ClassWithPrivateField {
static #privateStaticField = 42;
static publicStaticMethod() {
return ClassWithPrivateField.#privateStaticField;
}
#message;
#privateMethod() {
return 42;
}
publicMethod() {
return this.#privateMethod();
}
get #decoratedMessage() {
return this.#message
}
set #decoratedMessage(msg) {
this.#message = msg;
}
}
// Member objects: text after "."
object.property instanceof Number;
iden1.iden2 . iden3.class class;
iden1?.iden2 . iden3.class class;
iden1.#iden2 . iden3.class class;
var escapes = "aa\b\n\0a\"a\x12a\32a\u{123}a\$\%\ \#\y\aaa\
aaa";
var octal = 0o124;
var bin = 0b1010;
日本語().ლಠ益ಠლ.ñá = 42;
δ /No-Regex/
// Only highlight valid regular expressions, of a single line, after strings
// See: https://github.com/microsoft/TypeScript-TmLanguage/issues/786
"text" /No-Regex
"text" /Regex[:)]*/;
const a = "6" / 2; /*comment*/ const b = 5;
console.log("4" / "2"); // 2
// Single quote
const a = '6' / 2; /*comment*/ const b = 5;
console.log('4' / '2'); // 2
// Template
const a = `6` / 2; /*comment*/ const b = 5;
console.log(`4` / `2`); // 2
// Built-in
const os = require('os');
JSON.stringify("hello");
console.error("hello");
Math.LOG10E;
Number.MAX_SAFE_INTEGER;
String.raw`raw text \.\n${}`
// Tagged template literals
tagFunc`
Hello world!
${ alert("Hello!"); }`;
obj.something.tagFunc`Setting ${setting} is ${value + 5}!`;
/*
NOTE: The words "todo", "fixme" and "note" should be rendered in a different style
within comments, match should be caseless (to test for regexp insensitive attribute).
The regex used for this rule is */
String = /\b(?:fixme|todo|note)\b/
/* Thus, for example "Notebook" is not caught by
this rule. (the "?:" in the subpattern is there to avoid the regex engine wasting time
saving a backref, which is not used for anything. I do not know if the overhead of parsing
that is greater than the time saved by not capturing the text...)
The rule for catching these words is placed in a context "Comment common", which is used
by both comment contexts (single line, multiline) using the new "IncludeRules" item.
*/
// test if regex support works - nice with new fallthrough prop in context:)
somestring.replace( /dooh/ , "bah!");
re=/foo/ig; // hehe
somestring.search(
/^foo\w+\s\d{0,15}$/
);
re =
/dooh/;
// This is supposedly legal:
re = somebool ? /foo/ : /bar/;
// NOTE - Special case: an empty regex, not a comment.
// The rule uses a positive lookahead assertion to catch it: "//(?=;)".
re = //;
re = /a|b/;
/*
Tests for the regex parser.
It will parse classes, quantifiers, special characters and regex operaters,
as specified in the netscape documentation for javascript.
Regexps are only parsed in their clean form, as the RegExp(string) constructor
is using a quoted string.
TODO: Find out if more regex feats should be supported.
Consider using more itemDatas - assertion, quantifier are options.
*/
re = /^text\s+\d+\s*$/;
re = /a pattern with caret \(^\) in it/;
re = /(\d{0,4})\D/;
re = /[a-zA-Z_]+/;
re = /[^\d^]+/;
re = /\s+?\w+\.$/;
re = /\/\//;
re = /a|b/;
// the following are not regexps in E4X (=xml embedded into JavaScript)
var p = <p>Hello World</p>
var p = /</
var p = />/
// a test if #pop back from a comment will work
re = /*/foo/*/ /bar/;
// ^ POP
// ^ we got back after pop in comment, if there is regexp attribs here :-)
/*
Some tests if the fallthrough works.
The fallthrough happens if a regexp is not found in a possible (!) position,
which is after "search(" or "replace(" or "=" or "?" or ":" in version 0.1 of the xml file
*/
var foo = 'bar';
// ^ fallthrough!
somestring.replace( new RegExp("\\b\\w+\\b"), "word: $1");
// ^ fallthrough expected. ("new" whould be bold)
something.method =
function ( a, b, c ) { /* ... */ }
// ^ fallthrough ?!
something.other =
function ( d, e, f ) { /* ... */ }
// fallthrough expected at col 0 ("function" should be bold)
var ary = new Array(5);
// ^ fallthrough ? (if keyword is correctly rendered)
var b = a ? 1 : 0;
// ^ ^ fallthroughs. numbers must be rendered correctly.
var c = d ? true : false;
var conditinalstring = b ?
"something" :
"something else";
// guess...
/*
Normal program flow...
*/
if (something)
dostuff();
else
dont();
return;
try { bla() } catch (e) { alert("ERROR! : " + e) }
for (int i=0; i < j; i++)
document.write("i is" + i + "<br>");
while (something)
{
block();
picky:
if (!1)
break;
else
continue;
}
with (a) {
do {
stuff( b ); // a.b if it exists
} while (itmakessense);
}
switch (i) {
case 0:
f();
break;
default:
break;
}
// Numerics
var a = 0xA;
var b = 0b1;
var c = 0o7;
var c = 07;
var c = 08;
var d = 1.1E+3;
var e = 1.E+3;
var f = .1E+3;
var g = 1E+3;
var h = 1.1;
var i = 1.;
var j = .1;
var k = 1;
// Bigint
const binBig = 0b101n;
const octBig = 0o567n;
const hexBig = 0xC0Bn;
const decBig = 123n;
// Invalid numbers
var l = 0xA1t;
var m = 0b0123;
var n = 0o29;
var n = 000_7;
// Number with separator
let a = 0xA_b_1
let a = 0xA_b_1n
let a = 0xA_b_1_
let a = 0xA_b__1
let b = 0o1_2_3
let b = 0o1_2_3n
let b = 0o1_2_3_
let b = 0o1_2__3
let b = 0o1_2_38
let b = 01_2_3
let b = 01_2_3n
let b = 01_2_3_
let b = 01_2__3
let c = 0b0_1_1
let c = 0b0_1_1n
let c = 0b0_1_1_
let c = 0b0_1__1
let d = 1_2_3
let d = 1_2_3n
let d = 1_2_3_
let d = 1_2__3
let d = 01_2_8
@@ -0,0 +1,102 @@
local utils = import 'utils.libsonnet';
/* A C-style
comment.
*/
# A Python-style comment.
// Define a "local" function.
// Default arguments are like Python:
local my_function(x, y=10) = x + y;
local object = {
// A method
my_method(x): x * x,
};
local string1 = 'Farmer\'s Gin';
local string_newline1 = 'this is
a valid string
with newlines';
local string_newline2 = "this is
also
a valid string";
local timcollins = |||
The Tom Collins is essentially gin and
lemonade. The bitters add complexity.
|||;
local obj = {
"foo": 1,
"bar": {
"arr": [1, 2, 3],
"number": 10 + 7,
},
};
// Define a local function.
// Default arguments are like Python:
local my_function(x, y=10) = x + y;
// Define a local multiline function.
local multiline_function(x) =
// One can nest locals.
local temp = x * 2;
// Every local ends with a semi-colon.
[temp, temp + 1];
local object = {
// A method
my_method(x): x * x,
};
local large = true;
{
// Functions are first class citizens.
call_inline_function:
(function(x) x * x)(5),
call_multiline_function: multiline_function(4),
// Using the variable fetches the function,
// the parens call the function.
call: my_function(2),
// Like python, parameters can be named at
// call time.
named_params: my_function(x=2),
// This allows changing their order
named_params2: my_function(y=3, x=2),
// object.my_method returns the function,
// which is then called like any other.
call_method1: object.my_method(3),
standard_lib:
std.join(' ', std.split("foo/bar", '/')),
len: [
std.length('hello'),
std.length([1, 2, 3]),
],
cocktails: {
local factor = if large then 2 else 1,
// Ingredient quantities are in fl oz.
'Tom Collins': {
ingredients: [
{ kind: string1, qty: 1.5*factor },
{ kind: 'Lemon', qty: 1 },
{ kind: 'Simple Syrup', qty: 0.5E+1 },
{ kind: 'Soda', qty: 2 },
{ kind: 'Angostura', qty: 'dash' },
],
garnish: 'Maraschino Cherry',
served: 'Tall',
description: timcollins,
},
},
}
@@ -0,0 +1,173 @@
<%--
This page won't actually work, as it is simply designed to display jsp syntax highlighting.
--%>
<%@ page info="A Page to Test Kate Jsp Syntax Highlighting" language="java" errorPage="/test-error-page.jsp"%>
<%@ include file="/include/myglobalvars.jsp"%> --%>
<%@ page import="java.util.*,
java.io.*,
java.math.*" %>
<%@ taglib uri="/WEB-INF/lib/si_taglib.tld" prefix="si"%>
<jsp:useBean id="aPageBean" scope="page" class="my.package.MyPageBean"/>
<jsp:useBean id="aRequestBean" scope="request" class="my.package.MyRequestBean"/>
<%
// We can decipher our expected parameters here.
String parm1 = noNull(request.getParameter(PARAMETER_1)).trim();
String parm2 = noNull(request.getParameter(PARAMETER_2)).trim();
String parm3 = noNull(request.getParameter(PARAMETER_3)).trim();
String parm4 = noNull(request.getParameter(PARAMETER_4)).trim();
String parm5 = noNull(request.getParameter(PARAMETER_5)).trim();
// A sample collection of Integers to display some code folding.
List intList = getIntList(10);
%>
<html>
<title>A Sample Jsp</title>
<head>
<script language="javascript"><!--
function doAlert1() {
alert("This is the first javascript example.");
}
function doAlert2() {
alert("This is the second javascript example.");
}
//--></script>
<style type="text/css">
body{ color: yellow; }
</style>
</head>
<body>
<%-- The top label table. --%>
<table width="400" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><font size="3"><b>The following parameters were detected:</b></font></td>
</tr>
</table>
<%-- Display the parameters which might have been passed in. --%>
<table width="400" cellpadding="0" cellspacing="0" border="0">
<%-- Label; Actual Parameter String; Value Detected --%>
<tr>
<td><b>PARAMETER_1</b></td>
<td align="center"><%=PARAMETER_1%></td>
<td align="right">&quot;<%=parm1%>&quot;</td>
</tr>
<%-- Label; Actual Parameter String; Value Detected --%>
<tr>
<td><b>PARAMETER_2</b></td>
<td align="center"><%=PARAMETER_2%></td>
<td align="right">&quot;<%=parm2%>&quot;</td>
</tr>
<%-- Label; Actual Parameter String; Value Detected --%>
<tr>
<td><b>PARAMETER_3</b></td>
<td align="center"><%=PARAMETER_3%></td>
<td align="right">&quot;<%=parm3%>&quot;</td>
</tr>
<%-- Label; Actual Parameter String; Value Detected --%>
<tr>
<td><b>PARAMETER_4</b></td>
<td align="center"><%=PARAMETER_4%></td>
<td align="right">&quot;<%=parm4%>&quot;</td>
</tr>
<%-- Label; Actual Parameter String; Value Detected --%>
<tr>
<td><b>PARAMETER_5</b></td>
<td align="center"><%=PARAMETER_5%></td>
<td align="right">&quot;<%=parm5%>&quot;</td>
</tr>
</table>
<br><br>
<%-- Display our list of random Integers (shows code folding). --%>
<table width="400" cellpadding="0" cellspacing="0" border="0">
<%
if (intList != null && intList.size() > 0) {
%>
<tr><td><b>Here are the elements of intList...</b></td></tr>
<%
Iterator intListIt = intList.iterator();
while (intListIt.hasNext()) {
Integer i = (Integer) intListIt.next();
%>
<tr><td><%=i.toString()%></td></tr>
<%
}
} else {
%>
<tr><td><font color="blue"><b><i>Oooops, we forgot to initialize intList!</i></b></font></td></tr>
<%
}
%>
</table>
<br><br>
<%-- We can call javascript functions. --%>
<table width="400" cellpadding="0" cellspacing="0" border="0">
<tr><td colspan="2"><b>Test our javascript...</b></td></tr>
<tr>
<td><input type="button" name="button1" value="Alert 1" onmouseup="javascript:doAlert1()"></td>
<td><input type="button" name="button2" value="Alert 2" onmouseup="javascript:doAlert2()"></td>
</tr>
</table>
<br><br>
<%-- If we actually had defined a tag library. --%>
<table width="400" cellpadding="0" cellspacing="0" border="0">
<tr><td>
<my:SampleTag prop1="first" prop2="third">
<my:SampleTagChild nameProp="value1"/>
<my:SampleTagChild nameProp="value2"/>
</my:SampleTag>
</td></tr>
</table>
<br><br>
<%-- Expression language. --%>
<table width="400" cellpadding="0" cellspacing="0" border="0">
<c:if test="${!empty param.aParam}">
<c:set var="myParam" scope="session" value="${param.aParam}"/>
</c:if>
<tr><td>myParam's value: &quot;<c:out value="${myParam}" default=="Default"/>&quot;</td></tr>
</table>
</body>
</html>
<%!
/* A place for class variables and functions... */
// Define some sample parameter names that this page might understand.
private static final String PARAMETER_1 = "p1";
private static final String PARAMETER_2 = "p2";
private static final String PARAMETER_3 = "p3";
private static final String PARAMETER_4 = "p4";
private static final String PARAMETER_5 = "p5";
// Returns str trimmed, or an empty string if str is null.
private static String noNull(String str) {
String retStr;
if (str == null)
retStr = "";
else
retStr = str.trim();
return retStr;
}
// Returns a list of Integers with listSize elements.
private static List getIntList(int listSize) {
ArrayList retList = new ArrayList(listSize);
for (int i = 0; i < listSize; i++)
retList.add(new Integer( (int) (Math.random() * 100) ));
return retList;
}
%>

Some files were not shown because too many files have changed in this diff Show More