Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added lexer for PSL #688

Merged
merged 3 commits into from Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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
Expand Down
126 changes: 126 additions & 0 deletions lexers/embedded/psl.xml
@@ -0,0 +1,126 @@
<lexer>
<config>
<name>PSL</name>
<alias>psl</alias>
<filename>*.psl</filename>
<filename>*.BATCH</filename>
<filename>*.TRIG</filename>
<filename>*.PROC</filename>
<mime_type>text/x-psl</mime_type>
</config>
<rules>
<!-- NameFunction|TypeName -->
<state name="root">
<rule pattern="//.*$">
<token type="CommentSingle"/>
</rule>
<rule pattern="/(\\\n)?[*](.|\n)*?[*](\\\n)?/">
<token type="CommentMultiline"/>
</rule>
<rule pattern="\+|-|\*|/|%|'?&lt;|'?&gt;|'?=|\band\b|\bor\b|_|:">
<token type="Operator"/>
</rule>
<rule pattern="[{}(),\[\]]">
<token type="Punctuation"/>
</rule>
<rule pattern="[+-]?\d*\.\d+">
<token type="LiteralNumber"/>
</rule>
<rule pattern="&quot;">
<token type="LiteralString"/>
<push state="string"/>
</rule>
<rule pattern="\.">
<token type="Operator"/>
<push state="method"/>
</rule>
<rule pattern="\$\$">
<token type="NameFunction"/>
<push state="method"/>
</rule>
<rule pattern="\bdo\b">
<token type="KeywordReserved"/>
<push state="callmethod"/>
</rule>
<rule pattern="\b(do|set|if|for|while|quit|catch|return|while)\b">
<token type="Keyword"/>
</rule>
<rule pattern="\b(true|false)\b">
<token type="KeywordConstant"/>
</rule>
<rule pattern="\btype\b">
<token type="KeywordDeclaration"/>
<push state="typename"/>
</rule>
<rule pattern="\b(public|req|private|void)\b">
<token type="KeywordDeclaration"/>
</rule>
<rule pattern="\b(Boolean|String|Number|Date)\b">
<token type="KeywordType"/>
</rule>
<rule pattern="\^?[a-zA-Z][a-zA-Z0-9]*">
<token type="Name"/>
</rule>
<rule pattern="\s+">
<token type="Text"/>
</rule>
</state>
<state name="string">
<rule pattern="&quot;">
<token type="LiteralString"/>
<pop depth="1"/>
</rule>
<rule pattern="\\([\\abfnrtv&quot;\&#x27;]|x[a-fA-F0-9]{2,4}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|[0-7]{1,3})">
<token type="LiteralStringEscape"/>
</rule>
<rule pattern="[^\\&quot;\n]+">
<token type="LiteralString"/>
</rule>
<rule pattern="\\\n">
<token type="LiteralString"/>
</rule>
<rule pattern="\\">
<token type="LiteralString"/>
</rule>
</state>
<state name="method">
<rule pattern="\(">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
<rule pattern="\^[a-zA-Z][a-zA-Z0-9]*">
<token type="NameClass"/>
</rule>
<rule pattern="[a-zA-Z][a-zA-Z0-9]*">
<token type="NameFunction"/>
</rule>
</state>
<state name="callmethod">
<rule pattern="\(|{">
<token type="Punctuation"/>
<pop depth="1"/>
</rule>
<rule pattern="\^[a-zA-Z][a-zA-Z0-9]*">
<token type="NameClass"/>
</rule>
<rule pattern="[a-zA-Z][a-zA-Z0-9]*">
<token type="NameFunction"/>
</rule>
<rule pattern="\s+">
<token type="Text"/>
</rule>
</state>
<state name="typename">
<rule pattern="\s+">
<token type="Text"/>
</rule>
<rule pattern="\b(public|req|private|void)\b">
<token type="KeywordDeclaration"/>
</rule>
<rule pattern="[a-zA-Z][a-zA-Z0-9]*">
<token type="NameClass"/>
<pop depth="1"/>
</rule>
</state>
</rules>
</lexer>
13 changes: 13 additions & 0 deletions lexers/testdata/psl.actual
@@ -0,0 +1,13 @@
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