Skip to content

Commit 64231c7

Browse files
committed
Allow whitespace before CallArguments (fixes #124)
This is picking up the tests for projectfluent/fluent#281, and adjusts the parser to pass those tests.
1 parent 267e2e0 commit 64231c7

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

fluent.syntax/fluent/syntax/parser.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -564,17 +564,21 @@ def get_inline_expression(self, ps):
564564
ps.next()
565565
attribute = self.get_identifier(ps)
566566
arguments = None
567-
if ps.current_char == '(':
567+
ps.peek_blank()
568+
if ps.current_peek == '(':
569+
ps.skip_to_peek()
568570
arguments = self.get_call_arguments(ps)
569571
return ast.TermReference(id, attribute, arguments)
570572

571573
if ps.is_identifier_start():
572574
id = self.get_identifier(ps)
575+
ps.peek_blank()
573576

574-
if ps.current_char == '(':
577+
if ps.current_peek == '(':
575578
# It's a Function. Ensure it's all upper-case.
576579
if not re.match('^[A-Z][A-Z0-9_-]*$', id.name):
577580
raise ParseError('E0008')
581+
ps.skip_to_peek()
578582
args = self.get_call_arguments(ps)
579583
return ast.FunctionReference(id, args)
580584

fluent.syntax/tests/syntax/fixtures_reference/call_expressions.ftl

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ duplicate-named-args = {FUN(x: 1, x: "X")}
2929
3030
## Whitespace around arguments
3131

32-
sparse-inline-call = {FUN( "a" , msg, x: 1 )}
32+
sparse-inline-call = {FUN ( "a" , msg, x: 1 )}
3333
empty-inline-call = {FUN( )}
3434
multiline-call = {FUN(
3535
"a",
3636
msg,
3737
x: 1
3838
)}
39-
sparse-multiline-call = {FUN(
39+
sparse-multiline-call = {FUN
40+
(
4041
4142
"a" ,
4243
msg

fluent.syntax/tests/syntax/fixtures_reference/term_parameters.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
}
44
55
key01 = { -term }
6-
key02 = { -term() }
6+
key02 = { -term () }
77
key03 = { -term(arg: 1) }
88
key04 = { -term("positional", narg1: 1, narg2: 2) }

0 commit comments

Comments
 (0)