From e72d941ab63ed65c82c5ad8b902f1944f40823a3 Mon Sep 17 00:00:00 2001 From: Crystal Prieb Date: Tue, 18 Oct 2022 10:30:29 -0500 Subject: [PATCH 1/2] initial psl code --- README.md | 2 +- lexers/embedded/psl.xml | 106 +++++++++++++++++++++++++++++++++++ lexers/testdata/psl.actual | 10 ++++ lexers/testdata/psl.expected | 70 +++++++++++++++++++++++ 4 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 lexers/embedded/psl.xml create mode 100644 lexers/testdata/psl.actual create mode 100644 lexers/testdata/psl.expected diff --git a/README.md b/README.md index df7e0f14c..9ddbcfe11 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ L | Lighttpd configuration file, LLVM, Lua M | Mako, markdown, Mason, Mathematica, Matlab, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL N | NASM, Newspeak, Nginx configuration file, Nim, Nix O | Objective-C, OCaml, Octave, OnesEnterprise, OpenEdge ABL, OpenSCAD, Org Mode -P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, PromQL, Properties, Protocol Buffer, Puppet, Python 2, Python +P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, PromQL, Properties, Protocol Buffer, PSL, Puppet, Python 2, Python Q | QBasic R | R, Racket, Ragel, Raku, react, ReasonML, reg, reStructuredText, Rexx, Ruby, Rust S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Sed, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Standard ML, Stylus, Svelte, Swift, SYSTEMD, systemverilog diff --git a/lexers/embedded/psl.xml b/lexers/embedded/psl.xml new file mode 100644 index 000000000..0cb9750d3 --- /dev/null +++ b/lexers/embedded/psl.xml @@ -0,0 +1,106 @@ + + + PSL + psl + *.psl + *.BATCH + *.TRIG + *.PROC + text/x-psl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lexers/testdata/psl.actual b/lexers/testdata/psl.actual new file mode 100644 index 000000000..e1ae42f7a --- /dev/null +++ b/lexers/testdata/psl.actual @@ -0,0 +1,10 @@ + +public void SumMethod() { + + type public Number x + type String i = "" + for set i = ^UTBL("test",i).order() quit:i.isNull() { + set x = x + i + } + + quit \ No newline at end of file diff --git a/lexers/testdata/psl.expected b/lexers/testdata/psl.expected new file mode 100644 index 000000000..3c47f8609 --- /dev/null +++ b/lexers/testdata/psl.expected @@ -0,0 +1,70 @@ +[ + {"type":"KeywordDeclaration","value":"type"}, + {"type":"Text","value":" "}, + {"type":"KeywordDeclaration","value":"public"}, + {"type":"Text","value":" "}, + {"type":"NameFunction","value":"SumMethod"}, + {"type":"Punctuation","value":"()"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"{"}, + {"type":"Text","value":"\n"}, + + {"type":"Text","value":"\n "}, + {"type":"CommentSingle","value":"// this is a comment\n"}, + + {"type":"Text","value":" "}, + {"type":"KeywordDeclaration","value":"type"}, + {"type":"Text","value":" "}, + {"type":"KeywordDeclaration","value":"public"}, + {"type":"Text","value":" "}, + {"type":"TypeName","value":"Number"}, + {"type":"Text","value":" "}, + {"type":"VariableName","value":"x"}, + + {"type":"Text","value":"\n "}, + {"type":"KeywordDeclaration","value":"type"}, + {"type":"Text","value":" "}, + {"type":"KeywordDeclaration","value":"String"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"i"}, + {"type":"Text","value":" "}, + {"type":"Operator","value":"="}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"\"\""}, + + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"for"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"set"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"i"}, + {"type":"Text","value":" "}, + {"type":"Name","value":"^UTBL"}, + {"type":"Punctuation","value":"("}, + {"type":"LiteralString","value":"\"test\""}, + {"type":"Punctuation","value":","}, + {"type":"Name","value":"i"}, + {"type":"Punctuation","value":")"}, + {"type":"Operator","value":"."}, + {"type":"NameFunction","value":"order"}, + {"type":"Punctuation","value":"("}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"quit"}, + {"type":"Operator","value":":"}, + {"type":"Name","value":"i"}, + {"type":"Operator","value":"."}, + {"type":"NameFunction","value":"isNull"}, + {"type":"Punctuation","value":"("}, + {"type":"Punctuation","value":")"}, + {"type":"Text","value":" "}, + {"type":"Punctuation","value":"}"}, + + {"type":"Text","value":"\n "}, + {"type":"Punctuation","value":"}"}, + + {"type":"Text","value":"\n"}, + + {"type":"Text","value":"\n "}, + {"type":"Keyword","value":"quit"} +] \ No newline at end of file From f8f35dc050f5c37b9fd296255bb28bb3b4c2e351 Mon Sep 17 00:00:00 2001 From: Crystal Prieb Date: Tue, 18 Oct 2022 16:31:40 -0500 Subject: [PATCH 2/2] added PSL lexer logic --- lexers/embedded/psl.xml | 106 ++++--- lexers/testdata/psl.actual | 9 +- lexers/testdata/psl.expected | 546 ++++++++++++++++++++++++++++++----- 3 files changed, 546 insertions(+), 115 deletions(-) diff --git a/lexers/embedded/psl.xml b/lexers/embedded/psl.xml index 0cb9750d3..93b24d2e9 100644 --- a/lexers/embedded/psl.xml +++ b/lexers/embedded/psl.xml @@ -9,6 +9,7 @@ text/x-psl + @@ -16,70 +17,50 @@ - - - - - + - - - - - - - - - - - - - - + + - - + + + - - + + + - + + - - - - - + + - - + + - - + + + - - + + - - + + - + - - - @@ -102,5 +83,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lexers/testdata/psl.actual b/lexers/testdata/psl.actual index e1ae42f7a..9d948f735 100644 --- a/lexers/testdata/psl.actual +++ b/lexers/testdata/psl.actual @@ -1,10 +1,13 @@ - -public void SumMethod() { - +public Number SumMethod() { + // this is a comment type public Number x + set x = 10.0 + type String thisIsAString = "this"_x_"conjoined" type String i = "" for set i = ^UTBL("test",i).order() quit:i.isNull() { set x = x + i } + set x = x + $$getMore^ProcedureName("AAA") + do finishTask(x, "AAA") quit \ No newline at end of file diff --git a/lexers/testdata/psl.expected b/lexers/testdata/psl.expected index 3c47f8609..7e84b5c20 100644 --- a/lexers/testdata/psl.expected +++ b/lexers/testdata/psl.expected @@ -1,70 +1,478 @@ -[ - {"type":"KeywordDeclaration","value":"type"}, - {"type":"Text","value":" "}, - {"type":"KeywordDeclaration","value":"public"}, - {"type":"Text","value":" "}, - {"type":"NameFunction","value":"SumMethod"}, - {"type":"Punctuation","value":"()"}, - {"type":"Text","value":" "}, - {"type":"Punctuation","value":"{"}, - {"type":"Text","value":"\n"}, - - {"type":"Text","value":"\n "}, - {"type":"CommentSingle","value":"// this is a comment\n"}, - - {"type":"Text","value":" "}, - {"type":"KeywordDeclaration","value":"type"}, - {"type":"Text","value":" "}, - {"type":"KeywordDeclaration","value":"public"}, - {"type":"Text","value":" "}, - {"type":"TypeName","value":"Number"}, - {"type":"Text","value":" "}, - {"type":"VariableName","value":"x"}, - - {"type":"Text","value":"\n "}, - {"type":"KeywordDeclaration","value":"type"}, - {"type":"Text","value":" "}, - {"type":"KeywordDeclaration","value":"String"}, - {"type":"Text","value":" "}, - {"type":"Name","value":"i"}, - {"type":"Text","value":" "}, - {"type":"Operator","value":"="}, - {"type":"Text","value":" "}, - {"type":"LiteralString","value":"\"\""}, - - {"type":"Text","value":"\n "}, - {"type":"Keyword","value":"for"}, - {"type":"Text","value":" "}, - {"type":"Keyword","value":"set"}, - {"type":"Text","value":" "}, - {"type":"Name","value":"i"}, - {"type":"Text","value":" "}, - {"type":"Name","value":"^UTBL"}, - {"type":"Punctuation","value":"("}, - {"type":"LiteralString","value":"\"test\""}, - {"type":"Punctuation","value":","}, - {"type":"Name","value":"i"}, - {"type":"Punctuation","value":")"}, - {"type":"Operator","value":"."}, - {"type":"NameFunction","value":"order"}, - {"type":"Punctuation","value":"("}, - {"type":"Punctuation","value":")"}, - {"type":"Text","value":" "}, - {"type":"Keyword","value":"quit"}, - {"type":"Operator","value":":"}, - {"type":"Name","value":"i"}, - {"type":"Operator","value":"."}, - {"type":"NameFunction","value":"isNull"}, - {"type":"Punctuation","value":"("}, - {"type":"Punctuation","value":")"}, - {"type":"Text","value":" "}, - {"type":"Punctuation","value":"}"}, - - {"type":"Text","value":"\n "}, - {"type":"Punctuation","value":"}"}, - - {"type":"Text","value":"\n"}, - - {"type":"Text","value":"\n "}, - {"type":"Keyword","value":"quit"} +[ + { + "type": "KeywordDeclaration", + "value": "public" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "KeywordType", + "value": "Number" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "SumMethod" + }, + { + "type": "Punctuation", + "value": "()" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Punctuation", + "value": "{" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "CommentSingle", + "value": "// this is a comment" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "KeywordDeclaration", + "value": "type" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "KeywordDeclaration", + "value": "public" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "NameClass", + "value": "Number" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "x" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "Keyword", + "value": "set" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "x" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Operator", + "value": "=" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "LiteralNumber", + "value": "10.0" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "KeywordDeclaration", + "value": "type" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "NameClass", + "value": "String" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "thisIsAString" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Operator", + "value": "=" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "LiteralString", + "value": "\"this\"" + }, + { + "type": "Operator", + "value": "_" + }, + { + "type": "Name", + "value": "x" + }, + { + "type": "Operator", + "value": "_" + }, + { + "type": "LiteralString", + "value": "\"conjoined\"" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "KeywordDeclaration", + "value": "type" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "NameClass", + "value": "String" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "i" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Operator", + "value": "=" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "LiteralString", + "value": "\"\"" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "Keyword", + "value": "for" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Keyword", + "value": "set" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "i" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Operator", + "value": "=" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "^UTBL" + }, + { + "type": "Punctuation", + "value": "(" + }, + { + "type": "LiteralString", + "value": "\"test\"" + }, + { + "type": "Punctuation", + "value": "," + }, + { + "type": "Name", + "value": "i" + }, + { + "type": "Punctuation", + "value": ")" + }, + { + "type": "Operator", + "value": "." + }, + { + "type": "NameFunction", + "value": "order" + }, + { + "type": "Punctuation", + "value": "()" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Keyword", + "value": "quit" + }, + { + "type": "Operator", + "value": ":" + }, + { + "type": "Name", + "value": "i" + }, + { + "type": "Operator", + "value": "." + }, + { + "type": "NameFunction", + "value": "isNull" + }, + { + "type": "Punctuation", + "value": "()" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Punctuation", + "value": "{" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "Keyword", + "value": "set" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "x" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Operator", + "value": "=" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "x" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Operator", + "value": "+" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "i" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "Punctuation", + "value": "}" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "Keyword", + "value": "set" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "x" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Operator", + "value": "=" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Name", + "value": "x" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "Operator", + "value": "+" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "NameFunction", + "value": "$$getMore" + }, + { + "type": "NameClass", + "value": "^ProcedureName" + }, + { + "type": "Punctuation", + "value": "(" + }, + { + "type": "LiteralString", + "value": "\"AAA\"" + }, + { + "type": "Punctuation", + "value": ")" + }, + { + "type": "Text", + "value": "\n " + }, + { + "type": "KeywordReserved", + "value": "do" + }, + { + "type": "Text", + "value": " " + }, + { + "type": "NameFunction", + "value": "finishTask" + }, + { + "type": "Punctuation", + "value": "(" + }, + { + "type": "Name", + "value": "x" + }, + { + "type": "Punctuation", + "value": "," + }, + { + "type": "Text", + "value": " " + }, + { + "type": "LiteralString", + "value": "\"AAA\"" + }, + { + "type": "Punctuation", + "value": ")" + }, + { + "type": "Text", + "value": "\n\n " + }, + { + "type": "Keyword", + "value": "quit" + } ] \ No newline at end of file