Skip to content

Commit

Permalink
feat(Lezer grammar): Allow tabs (#3742)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanillajonathan authored Oct 24, 2023
1 parent 5f133b3 commit bb96b0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions grammars/prql-lezer/src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const prqlHighlight = styleTags({
Boolean: t.bool,
Integer: t.integer,
Float: t.float,
TypeTerm: t.typeName,
Escape: t.escape,
String: t.string,
FString: t.special(t.string),
Expand Down
2 changes: 1 addition & 1 deletion grammars/prql-lezer/src/prql.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ LambdaParam { identPart TypeDefinition? (":" expression)? }
Float { @digit ( @digit | "_" )* "." @digit ( @digit | "_" )* ("e" Integer)? }
// TODO: This is not as precise as PRQL, which doesn't allow trailing
// underscores and allows no digit before the decimal point.
space { " "+ }
space { $[ \t] }

Escape {
"\\" ("x" hex hex | "u" "{" hex+ "}" | $[bfnrt])
Expand Down
16 changes: 16 additions & 0 deletions grammars/prql-lezer/test/misc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ let my_func = arg1 arg2 -> arg1 + arg2

Query(Statements(VariableDeclaration(let,VariableName,Equals,Lambda(LambdaParam,LambdaParam,BinaryExpression(Identifier,ArithOp,Identifier)))))

# Function declaration with type annotation

let my_func = arg1<int32> -> arg1

==>

Query(Statements(VariableDeclaration(let,VariableName,Equals,Lambda(LambdaParam(TypeDefinition(TypeTerm)),Identifier))))

# Simple pipeline

from foo | select bar
Expand Down Expand Up @@ -117,3 +125,11 @@ group customer_id (
==>

Query(Statements(PipelineStatement(Pipeline(CallExpression(Identifier,Identifier,NestedPipeline(Pipeline(CallExpression(Identifier,TupleExpression(CallExpression(Identifier,Identifier))))))))))

# Tabs as spaces

let foo = (1)

==>

Query(Statements(VariableDeclaration(let,VariableName,Equals,NestedPipeline(Pipeline(Integer)))))

0 comments on commit bb96b0c

Please sign in to comment.