Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

SourcePawn

< >

SourcePawn is an open source programming language created in 2014.

#493on PLDB 10Years Old 8kRepos
Download source code:
git clone https://github.com/alliedmodders/sourcepawn
Source Code

A small, statically typed scripting language.


Example from Linguist:
/* Fixed point arithmetic * * (c) Copyright 1998-2011, ITB CompuPhase * This file is provided as is (no warranties). */ #pragma library Fixed const fround_method: { fround_round = 0, fround_floor, fround_ceil, fround_tozero, fround_unbiased } native Fixed:fixed(value); native Fixed:strfixed(const string[]); native Fixed:fmul(Fixed:oper1, Fixed:oper2); native Fixed:fdiv(Fixed:dividend, Fixed:divisor); native Fixed:ffract(Fixed:value); native fround(Fixed:value, fround_method:method=fround_round); native Fixed:fpower(Fixed:value, exponent); native Fixed:fsqroot(Fixed:value); native Fixed:fabs(Fixed:value); #pragma rational Fixed(3) /* user defined operators */ native Fixed:operator*(Fixed:oper1, Fixed:oper2) = fmul; native Fixed:operator/(Fixed:oper1, Fixed:oper2) = fdiv; native Fixed:operator=(oper) = fixed; stock Fixed:operator++(Fixed:oper) return oper + fixed(1); stock Fixed:operator--(Fixed:oper) return oper - fixed(1); stock Fixed:operator*(Fixed:oper1, oper2) return Fixed: (_:oper1 * oper2); /* "*" is commutative */ stock Fixed:operator/(Fixed:oper1, oper2) return oper1 / fixed(oper2); stock Fixed:operator/(oper1, Fixed:oper2) return fdiv(fixed(oper1), oper2); stock Fixed:operator+(Fixed:oper1, oper2) return oper1 + fixed(oper2); /* "+" is commutative */ stock Fixed:operator-(Fixed:oper1, oper2) return oper1 - fixed(oper2); stock Fixed:operator-(oper1, Fixed:oper2) return fixed(oper1) - oper2; stock bool:operator>(Fixed:oper1, oper2) return oper1 > fixed(oper2); stock bool:operator>(oper1, Fixed:oper2) return fixed(oper1) > oper2; stock bool:operator>=(Fixed:oper1, oper2) return oper1 >= fixed(oper2); stock bool:operator>=(oper1, Fixed:oper2) return fixed(oper1) >= oper2; stock bool:operator<(Fixed:oper1, oper2) return oper1 < fixed(oper2); stock bool:operator<(oper1, Fixed:oper2) return fixed(oper1) < oper2; stock bool:operator<=(Fixed:oper1, oper2) return oper1 <= fixed(oper2); stock bool:operator<=(oper1, Fixed:oper2) return fixed(oper1) <= oper2; stock bool:operator==(Fixed:oper1, oper2) /* "==" is commutative */ return oper1 == fixed(oper2); stock bool:operator!=(Fixed:oper1, oper2) /* "!=" is commutative */ return oper1 != fixed(oper2); /* forbidden operations */ forward operator%(Fixed:oper1, Fixed:oper2); forward operator%(Fixed:oper1, oper2); forward operator%(oper1, Fixed:oper2);

Language features

Feature Supported Example Token
Line Comments ✓
Integers ✓
Floats ✓
Hexadecimals ✓
Octals ✓
Comments ✓ /* A comment */
MultiLine Comments ✓ /* A comment */ /* */
Semantic Indentation X

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v161.0.4