diff --git a/docs/editor/scripts/urdujs/keywords.js.txt b/docs/editor/scripts/urdujs/keywords.js.txt index 3c84e50..975860c 100644 --- a/docs/editor/scripts/urdujs/keywords.js.txt +++ b/docs/editor/scripts/urdujs/keywords.js.txt @@ -152,4 +152,44 @@ export syntax karo = function(ctx) { } +} + + +//try catch finally +export syntax koshish = function(ctx){ + let tryblock = ctx.next().value; + let next = ctx.next(); + if(next.value!=null){ + if(next.value.value.token.value === "pakro"){ + let catchparams =ctx.next().value; + let catchblock = ctx.next().value; + let akhir = ctx.next(); + if(akhir.value!=null){ + if(akhir.value.value.token.value === "akhir"){ + let finallyblock = ctx.next().value; + return #`try ${tryblock} catch ${catchparams} ${catchblock} finally ${finallyblock}`; + } else { + return #`console.log("galti: akhir sahi tarah nahin likha")`; + } + } else { + return #`try ${tryblock} catch ${catchparams} ${catchblock}`; + + } + } + if(next.value.value.token.value === "akhir"){ + let finallyblock = ctx.next().value; + return #`try ${tryblock} finally ${finallyblock}`; + } + else { + return #`console.log("galti: koshish ke liye pakro ya akhir hona lazmi hai!")`; + } + } else { + return #`console.log("galti: koshish ke liye pakro ya akhir hona lazmi hai!")`; + } + +} + +//throw +export syntax phenko = function(ctx){ + return #`throw`; } \ No newline at end of file diff --git a/hello.js b/hello.js index 4e57675..0f520aa 100644 --- a/hello.js +++ b/hello.js @@ -11,7 +11,8 @@ import { bhejo, khali, pucho, - karo + karo, + koshish } from './src/keywords' ///////////////////////////////// diff --git a/src/keywords.js b/src/keywords.js index 3c84e50..8a7a518 100644 --- a/src/keywords.js +++ b/src/keywords.js @@ -150,6 +150,31 @@ export syntax karo = function(ctx) { } else { return #`console.log("galti: karo ke liye jabtak hona lazmi hai!")`; } - - +} + +//try catch finally +export syntax koshish = function(ctx){ + let tryblock = ctx.next().value; + let pakro = ctx.next(); + if(pakro.value!=null){ + if(pakro.value.value.token.value === "pakro"){ + let catchparams =ctx.next().value; + let catchblock = ctx.next().value; + let akhir = ctx.next(); + if(akhir.value!=null){ + if(akhir.value.value.token.value === "akhir"){ + let finallyblock = ctx.next().value; + return #`try ${tryblock} catch ${catchparams} ${catchblock} finally ${finallyblock}`; + } else { + return #`console.log("galti: akhir sahi tarah nahin likha")`; + } + } else { + return #`try ${tryblock} catch ${catchparams} ${catchblock}`; + + } + } + } else { + return #`console.log("galti: koshish ke liye pakro hona lazmi hai!")`; + } + } \ No newline at end of file