diff options
-rw-r--r-- | pygments/lexers/postgres.py | 9 | ||||
-rw-r--r-- | tests/examplefiles/psql_session.txt | 9 |
2 files changed, 15 insertions, 3 deletions
diff --git a/pygments/lexers/postgres.py b/pygments/lexers/postgres.py index 696b3baf..b0cceab3 100644 --- a/pygments/lexers/postgres.py +++ b/pygments/lexers/postgres.py @@ -50,11 +50,14 @@ class PostgresLexer(RegexLexer): (r"'(''|[^'])*'", String.Single), (r'"(""|[^"])*"', String.Name), # quoted identifier (r'[a-zA-Z_][a-zA-Z0-9_]*', Name), - (r'[;:()\[\],\.]', Punctuation), - # psql backslash command. - # This actually belongs to the console lexer, + + # psql backslash command and variable + # These actually belongs to the console lexer, # but putting it here makes things easier. (r'\\.*?\n', Name), # TODO: what is a good token? + (r':[a-z][a-z0-9_]*\b', Name.Variable), + + (r'[;:()\[\],\.]', Punctuation), ], 'multiline-comments': [ (r'/\*', Comment.Multiline, 'multiline-comments'), diff --git a/tests/examplefiles/psql_session.txt b/tests/examplefiles/psql_session.txt index 81a07610..fc39b42c 100644 --- a/tests/examplefiles/psql_session.txt +++ b/tests/examplefiles/psql_session.txt @@ -14,6 +14,15 @@ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. x (1 row) +piro=> \set foo 30; +piro=> select * from test where foo < :foo; + foo | bar +-----+----- + 10 | + 20 | +(2 rows) + + regression=# select ( regression(# 1); ?column? |