Browse Source
- added missing unittest for c - added further function lists for ada, fortran, fortran77, haskell from previous PR of MAPJe71_functionlist_update3 - added simple rust function list - unittest files from the internet probably no complex ones - added to installer Fix #9698, close #3393, close #9727pull/9733/head
Christian Grasser
4 years ago
committed by
Don HO
18 changed files with 885 additions and 31 deletions
@ -0,0 +1 @@
|
||||
{"leaves":["BiSeqOut"],"root":"unitTest"} |
@ -0,0 +1,43 @@
|
||||
-- Chapter 24 - Program 1 from https://perso.telecom-paristech.fr/pautet/Ada95/e_c24_p1.ada |
||||
with Ada.Text_IO; |
||||
use Ada.Text_IO; |
||||
with Ada.Sequential_IO; |
||||
|
||||
procedure BiSeqOut is |
||||
|
||||
type MY_REC is |
||||
record |
||||
Age : INTEGER; |
||||
Sex : CHARACTER; |
||||
Initial : CHARACTER; |
||||
end record; |
||||
|
||||
package Seq_IO is new Ada.Sequential_IO(MY_REC); |
||||
use Seq_IO; |
||||
|
||||
Myself : MY_REC; |
||||
My_Out_File : Seq_IO.FILE_TYPE; |
||||
|
||||
begin |
||||
|
||||
Create(My_Out_File, Out_File, "NAMEFILE.TXT"); |
||||
|
||||
Myself.Sex := 'M'; |
||||
Myself.Initial := 'X'; |
||||
|
||||
for Index in 1..100 loop |
||||
Myself.Age := Index; |
||||
Write(My_Out_File, Myself); |
||||
end loop; |
||||
|
||||
Close(My_Out_File); |
||||
|
||||
end BiSeqOut; |
||||
|
||||
|
||||
|
||||
|
||||
-- Result of Execution |
||||
|
||||
-- (The only output is a binary file named NAMEFILE.TXT) |
||||
|
@ -0,0 +1,131 @@
|
||||
/** |
||||
* @file |
||||
* @brief Functions related to 3D quaternions and Euler angles. |
||||
* @author Krishna Vedala |
||||
*/ |
||||
|
||||
#include <stdio.h> |
||||
#ifdef __arm__ // if compiling for ARM-Cortex processors |
||||
#define LIBQUAT_ARM |
||||
#include <arm_math.h> |
||||
#else |
||||
#include <math.h> |
||||
#endif |
||||
#include <assert.h> |
||||
|
||||
#include "geometry_datatypes.h" |
||||
|
||||
/** |
||||
* @addtogroup quats 3D Quaternion operations |
||||
* @{ |
||||
*/ |
||||
|
||||
/** |
||||
* Function to convert given Euler angles to a quaternion. |
||||
* \f{eqnarray*}{ |
||||
* q_{0} & = |
||||
* &\cos\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right) |
||||
* + |
||||
* \sin\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\ |
||||
* q_{1} & = |
||||
* &\sin\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right) |
||||
* - |
||||
* \cos\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\ |
||||
* q_{2} & = |
||||
* &\cos\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right) |
||||
* + |
||||
* \sin\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right)\\ |
||||
* q_{3} & = |
||||
* &\cos\left(\frac{\phi}{2}\right)\cos\left(\frac{\theta}{2}\right)\sin\left(\frac{\psi}{2}\right) |
||||
* - |
||||
* \sin\left(\frac{\phi}{2}\right)\sin\left(\frac{\theta}{2}\right)\cos\left(\frac{\psi}{2}\right)\\ |
||||
* \f} |
||||
* |
||||
* @param [in] in_euler input Euler angles instance |
||||
* @returns converted quaternion |
||||
*/ |
||||
quaternion quat_from_euler(const euler *in_euler) |
||||
{ |
||||
quaternion out_quat; |
||||
|
||||
if (!in_euler) // if null |
||||
{ |
||||
fprintf(stderr, "%s: Invalid input.", __func__); |
||||
return out_quat; |
||||
} |
||||
|
||||
quaternion temp; |
||||
|
||||
float cy = cosf(in_euler->yaw * 0.5f); |
||||
float sy = sinf(in_euler->yaw * 0.5f); |
||||
float cp = cosf(in_euler->pitch * 0.5f); |
||||
float sp = sinf(in_euler->pitch * 0.5f); |
||||
float cr = cosf(in_euler->roll * 0.5f); |
||||
float sr = sinf(in_euler->roll * 0.5f); |
||||
|
||||
temp.w = cr * cp * cy + sr * sp * sy; |
||||
temp.q1 = sr * cp * cy - cr * sp * sy; |
||||
temp.q2 = cr * sp * cy + sr * cp * sy; |
||||
temp.q3 = cr * cp * sy - sr * sp * cy; |
||||
|
||||
return temp; |
||||
} |
||||
|
||||
/** |
||||
* Function to convert given quaternion to Euler angles. |
||||
* \f{eqnarray*}{ |
||||
* \phi & = & |
||||
* \tan^{-1}\left[\frac{2\left(q_0q_1+q_2q_3\right)}{1-2\left(q_1^2+q_2^2\right)}\right]\\ |
||||
* \theta & = |
||||
* &-\sin^{-1}\left[2\left(q_0q_2-q_3q_1\right)\right]\\ |
||||
* \psi & = & |
||||
* \tan^{-1}\left[\frac{2\left(q_0q_3+q_1q_2\right)}{1-2\left(q_2^2+q_3^2\right)}\right]\\ |
||||
* \f} |
||||
* |
||||
* @param [in] in_quat input quaternion instance |
||||
* @returns converted euler angles |
||||
*/ |
||||
euler euler_from_quat(const quaternion *in_quat) |
||||
{ |
||||
euler out_euler; |
||||
if (!in_quat) // if null |
||||
{ |
||||
fprintf(stderr, "%s: Invalid input.", __func__); |
||||
return out_euler; |
||||
} |
||||
|
||||
out_euler.roll = atan2f( |
||||
2.f * (in_quat->w * in_quat->q1 + in_quat->q2 * in_quat->q3), |
||||
1.f - 2.f * (in_quat->q1 * in_quat->q1 + in_quat->q2 * in_quat->q2)); |
||||
out_euler.pitch = |
||||
asinf(2.f * (in_quat->w * in_quat->q2 + in_quat->q1 * in_quat->q3)); |
||||
out_euler.yaw = atan2f( |
||||
2.f * (in_quat->w * in_quat->q3 + in_quat->q1 * in_quat->q2), |
||||
1.f - 2.f * (in_quat->q2 * in_quat->q2 + in_quat->q3 * in_quat->q3)); |
||||
|
||||
return out_euler; |
||||
} |
||||
|
||||
/** @} */ |
||||
|
||||
static void test() |
||||
{ |
||||
quaternion quat = {0.7071f, 0.7071f, 0.f, 0.f}; |
||||
euler eul = euler_from_quat(&quat); |
||||
printf("Euler: %.4g, %.4g, %.4g\n", eul.pitch, eul.roll, eul.yaw); |
||||
|
||||
quaternion test_quat = quat_from_euler(&eul); |
||||
printf("Quaternion: %.4g %+.4g %+.4g %+.4g\n", test_quat.w, |
||||
test_quat.dual.x, test_quat.dual.y, test_quat.dual.z); |
||||
|
||||
assert(fabsf(test_quat.w - quat.w) < .01); |
||||
assert(fabsf(test_quat.q1 - quat.q1) < .01); |
||||
assert(fabsf(test_quat.q2 - quat.q2) < .01); |
||||
assert(fabsf(test_quat.q3 - quat.q3) < .01); |
||||
} |
||||
|
||||
int main() |
||||
{ |
||||
test(); |
||||
return 0; |
||||
} |
@ -1 +1 @@
|
||||
{"root":"unitTest"} |
||||
{"leaves":["quat_from_euler(const euler *in_euler)","euler_from_quat(const quaternion *in_quat)","test()","main()"],"root":"unitTest"} |
@ -0,0 +1 @@
|
||||
{"leaves":["setTime","getTime","printTime","PredictTime","PrintTimeSecondsHoursDays"],"root":"unitTest"} |
@ -0,0 +1,152 @@
|
||||
! Fortran Time Module |
||||
! |
||||
! To Use: |
||||
! 1) declare a ClockTime variable: type (ClockTime) :: Timer |
||||
! 2) Set a beginning Time: call set(Timer) |
||||
! 3a) Print Elapsed Time: printTime(Timer) |
||||
! 3b) Print Remaining Time: printRemainingTime(Timer,ratio) |
||||
! 3c) Predict Completion Time: predict(Timer,ratio) |
||||
! |
||||
! Copyright (c) 2008 Charles O'Neill |
||||
! |
||||
! Permission is hereby granted, free of charge, to any person |
||||
! obtaining a copy of this software and associated documentation |
||||
! files (the "Software"), to deal in the Software without |
||||
! restriction, including without limitation the rights to use, |
||||
! copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
! copies of the Software, and to permit persons to whom the |
||||
! Software is furnished to do so, subject to the following |
||||
! conditions: |
||||
! |
||||
! The above copyright notice and this permission notice shall be |
||||
! included in all copies or substantial portions of the Software. |
||||
! |
||||
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
||||
! OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||||
! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
||||
! HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
||||
! WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
! FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||||
! OTHER DEALINGS IN THE SOFTWARE. |
||||
|
||||
module ClockTiming |
||||
implicit none |
||||
|
||||
! Integer Precision |
||||
integer, parameter :: IS = 2 |
||||
! Real Single Precision |
||||
integer, parameter :: SP = 4 ! 4 gives 32 bits |
||||
! Real Double Precision |
||||
integer, parameter :: DP = 8 ! 4 gives 32 bits, 8 gives 64 bits (double) |
||||
|
||||
type ClockTime |
||||
private |
||||
real(SP) :: time_begin |
||||
end type |
||||
|
||||
! Time Constants |
||||
real(SP),parameter :: SecondsPerMinutes = 60.0 |
||||
real(SP),parameter :: MinutesPerHour = 60.0 |
||||
real(SP),parameter :: HoursPerDay = 24.0 |
||||
|
||||
real(SP),parameter :: PrintMaxSeconds = 90.0d0 |
||||
real(SP),parameter :: PrintMaxMinutes = SecondsPerMinutes*MinutesPerHour |
||||
real(SP),parameter :: PrintMaxHours = SecondsPerMinutes*MinutesPerHour*HoursPerDay |
||||
|
||||
!................................. |
||||
! Public Interfaces to ClockTime Data |
||||
|
||||
! Resets timer to zero |
||||
interface set |
||||
module procedure setTime |
||||
end interface |
||||
|
||||
! Returns elapsed time |
||||
interface get |
||||
module procedure getTime |
||||
end interface |
||||
|
||||
! Prints total elapsed time |
||||
interface printTime |
||||
module procedure printTime |
||||
end interface |
||||
|
||||
! Prints total remaining time |
||||
interface printRemainingTime |
||||
module procedure PrintTimeSecondsHoursDays |
||||
end interface |
||||
|
||||
! Predicts total elapsed time |
||||
interface predict |
||||
module procedure PredictTime |
||||
end interface |
||||
|
||||
private :: setTime, getTime, PredictTime, PrintTimeSecondsHoursDays |
||||
|
||||
contains |
||||
|
||||
! Resets timer to zero |
||||
subroutine setTime(this) |
||||
implicit none |
||||
type (ClockTime) :: this |
||||
! CPU_TIME is the system's clock time function |
||||
CALL CPU_TIME ( this%time_begin ) |
||||
end subroutine setTime |
||||
|
||||
! Returns elapsed time |
||||
function getTime(this) |
||||
implicit none |
||||
real(SP) :: getTime, time_end |
||||
type (ClockTime) :: this |
||||
CALL CPU_TIME ( time_end ) |
||||
getTime=time_end - this%time_begin |
||||
end function getTime |
||||
|
||||
! Prints total elapsed time |
||||
subroutine printTime(this) |
||||
implicit none |
||||
type (ClockTime) :: this |
||||
write(*,'(/ '' Operation time '', f8.3, '' seconds.'')') getTime(this) |
||||
end subroutine printTime |
||||
|
||||
! Predicts remaining time before completion |
||||
function PredictTime(this,CompletionRatio) |
||||
implicit none |
||||
real(SP) :: PredictTime |
||||
type (ClockTime) :: this |
||||
real(SP) :: CompletionRatio |
||||
! Definitions: |
||||
! CompletionRatio = Ratio of Completed Tasks to Total Tasks |
||||
! Time_Remaining = Time_TotalPredicted - Time_elapsed |
||||
! = Time_elapsed/CompletionRatio*(1-CompletionRatio) |
||||
PredictTime = getTime(this)*(1-CompletionRatio)/CompletionRatio |
||||
end function PredictTime |
||||
|
||||
! Pretty Prints remaining time |
||||
subroutine PrintTimeSecondsHoursDays(this, PredictionRatio) |
||||
! Choose to output either seconds, hours or days depending on magnitude |
||||
implicit none |
||||
type (ClockTime) :: this |
||||
real(SP) :: PredictionRatio |
||||
real(SP) :: Seconds |
||||
|
||||
Seconds = PredictTime(this,PredictionRatio) |
||||
|
||||
if(Seconds<PrintMaxSeconds)then |
||||
! Seconds |
||||
write(*,'( f5.1 , '' seconds'')',advance='no') Seconds |
||||
elseif(Seconds<PrintMaxMinutes)then |
||||
! Minutes |
||||
write(*,'( f5.1 , '' minutes'')',advance='no') Seconds/SecondsPerMinutes |
||||
elseif(Seconds<PrintMaxHours)then |
||||
! Hours |
||||
write(*,'( f5.1 , '' hours'')',advance='no') Seconds/SecondsPerMinutes/MinutesPerHour |
||||
else |
||||
! Days |
||||
write(*,'( f5.1 , '' days'')',advance='no') Seconds/SecondsPerMinutes/MinutesPerHour/HoursPerDay |
||||
endif |
||||
|
||||
end subroutine |
||||
|
||||
end module |
@ -0,0 +1 @@
|
||||
{"leaves":["printtext"],"root":"unitTest"} |
@ -0,0 +1,17 @@
|
||||
program hello_world3 |
||||
implicit none |
||||
character*32 text |
||||
c |
||||
text = 'Hello World' |
||||
c |
||||
call printtext(text) |
||||
|
||||
end |
||||
|
||||
subroutine printtext(tekst) |
||||
implicit none |
||||
character*32 tekst |
||||
c |
||||
write (*,*) tekst |
||||
c |
||||
end |
@ -0,0 +1 @@
|
||||
{"leaves":["main","getAllUsernames","getAllUserIds","getUsernameById","sql"],"root":"unitTest"} |
@ -0,0 +1,116 @@
|
||||
-- Necessary: |
||||
{-# LANGUAGE DeriveDataTypeable #-} |
||||
{-# LANGUAGE GADTs #-} |
||||
{-# LANGUAGE MultiParamTypeClasses #-} |
||||
{-# LANGUAGE OverloadedStrings #-} |
||||
{-# LANGUAGE StandaloneDeriving #-} |
||||
{-# LANGUAGE TypeFamilies #-} |
||||
|
||||
-- Incidental: |
||||
{-# LANGUAGE FlexibleInstances #-} |
||||
{-# LANGUAGE TypeSynonymInstances #-} |
||||
|
||||
module Main where |
||||
|
||||
import Control.Monad |
||||
import Data.Hashable |
||||
import Data.List |
||||
import Data.Text (Text) |
||||
import Data.Traversable (for) |
||||
import Data.Typeable |
||||
import Haxl.Core |
||||
import System.Random |
||||
|
||||
import qualified Data.Text as Text |
||||
|
||||
main :: IO () |
||||
main = do |
||||
let stateStore = stateSet UserState{} stateEmpty |
||||
env0 <- initEnv stateStore () |
||||
names <- runHaxl env0 getAllUsernames |
||||
print names |
||||
|
||||
-- Data source API. |
||||
|
||||
getAllUsernames :: Haxl [Name] |
||||
getAllUsernames = do |
||||
userIds <- getAllUserIds |
||||
for userIds $ \userId -> do |
||||
getUsernameById userId |
||||
|
||||
getAllUserIds :: Haxl [Id] |
||||
getAllUserIds = dataFetch GetAllIds |
||||
|
||||
getUsernameById :: Id -> Haxl Name |
||||
getUsernameById userId = dataFetch (GetNameById userId) |
||||
|
||||
-- Aliases. |
||||
|
||||
type Haxl = GenHaxl () () |
||||
type Id = Int |
||||
type Name = Text |
||||
|
||||
-- Data source implementation. |
||||
|
||||
data UserReq a where |
||||
GetAllIds :: UserReq [Id] |
||||
GetNameById :: Id -> UserReq Name |
||||
deriving (Typeable) |
||||
|
||||
deriving instance Eq (UserReq a) |
||||
instance Hashable (UserReq a) where |
||||
hashWithSalt s GetAllIds = hashWithSalt s (0::Int) |
||||
hashWithSalt s (GetNameById a) = hashWithSalt s (1::Int, a) |
||||
|
||||
deriving instance Show (UserReq a) |
||||
instance ShowP UserReq where showp = show |
||||
|
||||
instance StateKey UserReq where |
||||
data State UserReq = UserState {} |
||||
|
||||
instance DataSourceName UserReq where |
||||
dataSourceName _ = "UserDataSource" |
||||
|
||||
instance DataSource u UserReq where |
||||
fetch _state _flags _userEnv = SyncFetch $ \blockedFetches -> do |
||||
let |
||||
allIdVars :: [ResultVar [Id]] |
||||
allIdVars = [r | BlockedFetch GetAllIds r <- blockedFetches] |
||||
|
||||
idStrings :: [String] |
||||
idStrings = map show ids |
||||
|
||||
ids :: [Id] |
||||
vars :: [ResultVar Name] |
||||
(ids, vars) = unzip |
||||
[(userId, r) | BlockedFetch (GetNameById userId) r <- blockedFetches] |
||||
|
||||
unless (null allIdVars) $ do |
||||
allIds <- sql "select id from ids" |
||||
mapM_ (\r -> putSuccess r allIds) allIdVars |
||||
|
||||
unless (null ids) $ do |
||||
names <- sql $ unwords |
||||
[ "select name from names where" |
||||
, intercalate " or " $ map ("id = " ++) idStrings |
||||
, "order by find_in_set(id, '" ++ intercalate "," idStrings ++ "')" |
||||
] |
||||
mapM_ (uncurry putSuccess) (zip vars names) |
||||
|
||||
-- Mock SQL API. |
||||
|
||||
class SQLResult a where |
||||
mockResult :: IO a |
||||
|
||||
instance SQLResult a => SQLResult [a] where |
||||
mockResult = replicateM 10 mockResult |
||||
|
||||
instance SQLResult Name where |
||||
-- An infinite number of employees, all named Jim. |
||||
mockResult = ("Jim" `Text.append`) . Text.pack . show <$> randomRIO (1::Int, 100) |
||||
|
||||
instance SQLResult Id where |
||||
mockResult = randomRIO (1, 100) |
||||
|
||||
sql :: SQLResult a => String -> IO a |
||||
sql query = print query >> mockResult |
@ -0,0 +1,77 @@
|
||||
// Unlike C/C++, there's no restriction on the order of function definitions |
||||
fn main() { |
||||
// We can use this function here, and define it somewhere later |
||||
fizzbuzz_to(100); |
||||
} |
||||
|
||||
// Function that returns a boolean value |
||||
fn is_divisible_by(lhs: u32, rhs: u32) -> bool { |
||||
// Corner case, early return |
||||
if rhs == 0 { |
||||
return false; |
||||
} |
||||
|
||||
// This is an expression, the `return` keyword is not necessary here |
||||
lhs % rhs == 0 |
||||
} |
||||
|
||||
// Functions that "don't" return a value, actually return the unit type `()` |
||||
fn fizzbuzz(n: u32) -> () { |
||||
if is_divisible_by(n, 15) { |
||||
println!("fizzbuzz"); |
||||
} else if is_divisible_by(n, 3) { |
||||
println!("fizz"); |
||||
} else if is_divisible_by(n, 5) { |
||||
println!("buzz"); |
||||
} else { |
||||
println!("{}", n); |
||||
} |
||||
} |
||||
|
||||
// When a function returns `()`, the return type can be omitted from the |
||||
// signature |
||||
fn fizzbuzz_to(n: u32) { |
||||
for n in 1..n + 1 { |
||||
fizzbuzz(n); |
||||
} |
||||
} |
||||
|
||||
async fn async_example(n: u32) { |
||||
for n in 1..n + 1 { |
||||
fizzbuzz(n); |
||||
} |
||||
} |
||||
|
||||
const fn const_example(n: u32) { |
||||
for n in 1..n + 1 { |
||||
fizzbuzz(n); |
||||
} |
||||
} |
||||
|
||||
extern "Rust" fn foo() {} |
||||
|
||||
unsafe fn unsafe_example(n: u32) { |
||||
for n in 1..n + 1 { |
||||
fizzbuzz(n); |
||||
} |
||||
} |
||||
|
||||
// Declares a function with the "C" ABI |
||||
extern "C" fn new_i32() -> i32 { 0 } |
||||
|
||||
// Declares a function with the "stdcall" ABI |
||||
extern "stdcall" fn new_i32_stdcall() -> i32 { 0 } |
||||
|
||||
async fn regular_example() { } |
||||
async unsafe fn unsafe_example() { } |
||||
|
||||
const fn generic_example<'a>(x: &'a str) -> impl Future<Output = usize> + 'a { |
||||
async move { x.len() } |
||||
} |
||||
|
||||
fn generic_example2<const N: usize>(arr: [i32; N]) { |
||||
// Used as a type within a function body. |
||||
let x: [i32; N]; |
||||
// Used as an expression. |
||||
println!("{}", N * 2); |
||||
} |
@ -0,0 +1 @@
|
||||
{"leaves":["main","is_divisible_by","fizzbuzz","fizzbuzz_to","async_example","const_example","foo","unsafe_example","new_i32","new_i32_stdcall","regular_example","unsafe_example","generic_example","generic_example2"],"root":"unitTest"} |
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- ==========================================================================\ |
||||
| |
||||
| To learn how to make your own language parser, please check the following |
||||
| link: |
||||
| https://npp-user-manual.org/docs/function-list/ |
||||
| |
||||
\=========================================================================== --> |
||||
<NotepadPlus> |
||||
<functionList> |
||||
<!-- |
||||
| Based on: |
||||
| http://stackoverflow.com/questions/32126855/notepad-and-ada |
||||
\--> |
||||
<parser |
||||
displayName="ADA" |
||||
id ="ada_syntax" |
||||
commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
(?m-s:-{2}.*?$) # Single Line Comment |
||||
" |
||||
> |
||||
<function |
||||
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
^\h* # optional leading whitespace at start-of-line |
||||
(?: |
||||
(?-i:function) |
||||
\s+ |
||||
(?'VALID_ID' # valid identifier, use as subroutine |
||||
\b(?!(?-i: # keywords (case-sensitive), not to be used as identifier |
||||
a(?:b(?:ort|s(?:tract)?)|cce(?:pt|ss)|l(?:iased|l)|nd|rray|t) |
||||
| b(?:egin|ody) |
||||
| c(?:ase|onstant) |
||||
| d(?:eclare|el(?:ay|ta)|igits|o) |
||||
| e(?:ls(?:e|if)|n(?:d|try)|x(?:ception|it)) |
||||
| f(?:or|unction) |
||||
| g(?:eneric|oto) |
||||
| i(?:[fs]|n(?:terface)?) |
||||
| l(?:imited|oop) |
||||
| mod |
||||
| n(?:ew|ot|ull) |
||||
| o(?:[fr]|thers|ut|verriding) |
||||
| p(?:ackage|r(?:agma|ivate|o(?:cedure|tected))) |
||||
| r(?:a(?:is|ng)e|e(?:cord|m|names|queue|turn|verse)) |
||||
| s(?:e(?:lect|parate)|ome|ubtype|ynchronized) |
||||
| t(?:a(?:gged|sk)|erminate|hen|ype) |
||||
| u(?:ntil|se) |
||||
| w(?:h(?:en|ile)|ith) |
||||
| xor |
||||
)\b) |
||||
[A-Za-z_]\w* # valid character combination for identifiers |
||||
) |
||||
(?'PARAMETERS' |
||||
\s* |
||||
\( # start-of-parameters indicator |
||||
[^()]* # parameters |
||||
\) # end-of-parameters indicator |
||||
)? # parentheses and parameters optional |
||||
\s*return # function returns a value with... |
||||
\s+(?&VALID_ID) # ...type-name |
||||
| |
||||
(?-i:procedure) |
||||
\s+(?&VALID_ID) |
||||
(?:(?&PARAMETERS))? # Boost::Regex 1.58-1.59 do not correctly handle quantifiers on subroutine calls |
||||
) |
||||
\s*(?-i:\bis\b) # end-of-definition indicator |
||||
" |
||||
> |
||||
<functionName> |
||||
<nameExpr expr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
(?:function|procedure)\s+ |
||||
\K # discard text matched so far |
||||
[A-Za-z_]\w* |
||||
(?:\s*\([^()]*\))? # parentheses and parameters optional |
||||
(?= |
||||
\s* |
||||
\b(?:return|is) |
||||
) |
||||
" |
||||
/> |
||||
<!-- comment out the following node to display the method with its parameters --> |
||||
<!-- <nameExpr expr="[A-Za-z_]\w*" /> --> |
||||
</functionName> |
||||
</function> |
||||
</parser> |
||||
</functionList> |
||||
</NotepadPlus> |
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- ==========================================================================\ |
||||
| |
||||
| To learn how to make your own language parser, please check the following |
||||
| link: |
||||
| https://npp-user-manual.org/docs/function-list/ |
||||
| |
||||
\=========================================================================== --> |
||||
<NotepadPlus> |
||||
<functionList> |
||||
<!-- |
||||
| Based on: |
||||
| https://notepad-plus-plus.org/community/topic/11059/custom-functions-list-rules |
||||
| https://notepad-plus-plus.org/community/topic/13553/functionlist-xml-regular-expressions-not-parsing-properly |
||||
\--> |
||||
<parser |
||||
displayName="Fortran Free Form style - FORmula TRANslation" |
||||
id ="fortran_freeform" |
||||
commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
(?m-s:!.*$) # Single Line Comment |
||||
" |
||||
> |
||||
<function |
||||
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
(?im-s) # case-insensitive, ^ and $ match at line breaks, dot does not |
||||
^\h* # optional leading whitespace at start-of-line |
||||
(?: |
||||
(?: |
||||
ELEMENTAL |
||||
| (?:IM)?PURE |
||||
| MODULE |
||||
| (?:NON_)?RECURSIVE |
||||
) |
||||
\s+ |
||||
)* |
||||
(?:FUNCTION|SUBROUTINE)\s+ |
||||
\K # discard text matched so far |
||||
[A-Z]\w{0,62} # valid character combination for identifiers |
||||
(?:\s*\([^()]*\))? # optional paramater list |
||||
" |
||||
> |
||||
<!-- comment out the following node to display the method with its parameters --> |
||||
<functionName> |
||||
<nameExpr expr="\w+" /> |
||||
</functionName> |
||||
</function> |
||||
</parser> |
||||
</functionList> |
||||
</NotepadPlus> |
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- ==========================================================================\ |
||||
| |
||||
| To learn how to make your own language parser, please check the following |
||||
| link: |
||||
| https://npp-user-manual.org/docs/function-list/ |
||||
| |
||||
\=========================================================================== --> |
||||
<NotepadPlus> |
||||
<functionList> |
||||
<parser |
||||
displayName="Fortran Fixed Form style - FORmula TRANslation" |
||||
id ="fortran_fixedform" |
||||
commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
(?m-s:(?:!|^[Cc*].*$) # Single Line Comment 1..3 |
||||
" |
||||
> |
||||
<function |
||||
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
(?im-s) # case-insensitive, ^ and $ match at line breaks, dot does not |
||||
^\h* # optional leading whitespace at start-of-line |
||||
(?:FUNCTION|SUBROUTINE)\s+ |
||||
\K # discard text matched so far |
||||
[A-Z]\w{0,62} # valid character combination for identifiers |
||||
(?:\s*\([^()]*\))? # optional paramater list |
||||
" |
||||
> |
||||
<!-- comment out the following node to display the method with its parameters --> |
||||
<functionName> |
||||
<nameExpr expr="\w+" /> |
||||
</functionName> |
||||
</function> |
||||
</parser> |
||||
</functionList> |
||||
</NotepadPlus> |
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- ==========================================================================\ |
||||
| |
||||
| To learn how to make your own language parser, please check the following |
||||
| link: |
||||
| https://npp-user-manual.org/docs/function-list/ |
||||
| |
||||
\=========================================================================== --> |
||||
<NotepadPlus> |
||||
<functionList> |
||||
<!-- |
||||
| Based on: |
||||
| https://notepad-plus-plus.org/community/topic/12972/trouble-with-defining-a-function-list-entry/7 |
||||
| |
||||
| By convention, the style of comment is indicated by the file extension, |
||||
| with ".hs" indicating a "usual" Haskell file |
||||
| and ".lhs" indicating a literate Haskell file. |
||||
\--> |
||||
<parser |
||||
displayName="Haskell" |
||||
id ="haskell_function" |
||||
commentExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
(?s: # Multi Line Comment (nesting allowed) |
||||
\{- # - start-of-comment indicator |
||||
(?> # - followed by zero or more characters... |
||||
[^{-] # ...not part of the start indicator, |
||||
| \{(?!-) # ...not being a start-of-comment indicator, |
||||
| -(?!\}) # ...not being an end-of-comment indicator and |
||||
| (?R) # ...balancing through recursion (nesting) |
||||
)* |
||||
-\} # - end-of-comment indicator |
||||
) |
||||
| (?m-s:-{2}.*?$) # Single Line Comment |
||||
" |
||||
> |
||||
<function |
||||
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
(?m-s) # ^ and $ match at line breaks, dot does not |
||||
^ # NO leading whitespace at start-of-line |
||||
[A-Za-z][\w\x27]* # valid character combination for identifiers |
||||
\x20+::\x20 |
||||
.*?$ # whatever, until end-of-line |
||||
" |
||||
> |
||||
<functionName> |
||||
<nameExpr expr="[A-Za-z][\w\x27]*" /> |
||||
</functionName> |
||||
</function> |
||||
</parser> |
||||
</functionList> |
||||
</NotepadPlus> |
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!-- ==========================================================================\ |
||||
| |
||||
| To learn how to make your own language parser, please check the following |
||||
| link: |
||||
| https://npp-user-manual.org/docs/function-list/ |
||||
| |
||||
\=========================================================================== --> |
||||
<NotepadPlus> |
||||
<functionList> |
||||
<!-- =========================================================== [ C ] --> |
||||
<parser |
||||
displayName="Rust" |
||||
id ="rust_function" |
||||
commentExpr="(?x) # Utilize inline comments (see `RegEx - Pattern Modifiers`) |
||||
(?s:\x2F\x2A.*?\x2A\x2F) # Multi Line Comment |
||||
| (?m-s:\x2F{2}.*$) # Single Line Comment |
||||
" |
||||
> |
||||
<function |
||||
mainExpr="(?x) # free-spacing (see `RegEx - Pattern Modifiers`) |
||||
^\h* # optional leading whitespace at start-of-line |
||||
(?: |
||||
(?-i: |
||||
async |
||||
| const |
||||
| (?-i:extern\s+(?s:\x22(?:[^\x22\x5C]|\x5C.)*\x22)) |
||||
| unsafe |
||||
) |
||||
\s+ |
||||
)* |
||||
(?-i:fn)\s+ |
||||
\K # discard text matched so far |
||||
(?:[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+) # valid character combination for identifiers |
||||
(?:<.*$gt;)? # optional generic params |
||||
(?:\s*\([^()]*\))? # optional parameter list |
||||
" |
||||
> |
||||
<!-- comment out the following node to display the method with its parameters --> |
||||
<functionName> |
||||
<nameExpr expr="\w+" /> |
||||
</functionName> |
||||
</function> |
||||
</parser> |
||||
</functionList> |
||||
</NotepadPlus> |
Loading…
Reference in new issue