pegisland
Version:
General PEG-based parser supporting island grammars with lake symbols
3 lines • 1.17 kB
TypeScript
export declare const exampleSource = "function make_cmp_f(x)\n{\n if (x == 0)\n\tfunc = lambda (y) {\n\t if (y > x) {\n\t\tresult = \"positive\";\n\t }\n\t else if (y < x) {\n\t\tresult = \"negative\";\n\t }\n\t else {\n\t\tresult = \"zero\";\n\t }\n\t result;\n\t};\n else \n func = lambda (y) {\n\t 0;\n\t};\n func;\n}\n\ncompare = make_cmp_f(0);\ncompare(1);\n";
export declare const exampleGrammar = "program <- spacing program_sea*\nprogram_sea <- if_else_stmt / water\nwater <- STRING / .\nif_else_stmt <- if_stmt (ELSE stmt)?\nif_stmt <- IF LPAREN expr RPAREN stmt\nstmt <- block / if_else_stmt / exp_stmt\nexp_stmt <- expr SEMICOLON\nblock <- LBRACE stmt* RBRACE\nexpr <- <expr_lake>*\n<expr_lake> <- if_else_stmt / expr_water\nexpr_water <- LPAREN <expr_lake>* RPAREN / block\n\nspacing <- [ \\t\\n]*\nLPAREN <- '(' spacing\nRPAREN <- ')' spacing \nLBRACE <- '{' spacing\nRBRACE <- '}' spacing\nSEMICOLON <- ';' spacing \nIF <- 'if' spacing\nELSE <- 'else' spacing\nSTRING <- '\"' [^\"]* '\"' spacing \n";
//# sourceMappingURL=example.d.ts.map