Skip to content
This repository has been archived by the owner on Jun 6, 2021. It is now read-only.

Commit

Permalink
Make vector type syntax more symmetric with the expression syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Jun 8, 2013
1 parent fec95a1 commit 9d6fa12
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions lib/compiler/syntax/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,9 @@ defmodule Flect.Compiler.Syntax.Parser do
@spec parse_vector_type(state()) :: return_n()
defp parse_vector_type(state) do
{_, tok_open, state} = expect_token(state, :brace_open, "opening brace")
{type, state} = parse_type(state)
{_, tok_period_period, state} = expect_token(state, :period_period, "type/size-separating ellipsis")
{_, tok_int, state} = expect_token(state, :integer, "vector size integer")
{_, tok_period_period, state} = expect_token(state, :period_period, "size/type-separating ellipsis")
{type, state} = parse_type(state)
{_, tok_close, state} = expect_token(state, :brace_close, "closing brace")

{new_node(:vector_type, tok_open.location(),
Expand Down
5 changes: 0 additions & 5 deletions tests/parse-fail/vec_no_ellipsis.fl

This file was deleted.

7 changes: 0 additions & 7 deletions tests/parse-fail/vec_no_ellipsis.fl.0.exp

This file was deleted.

4 changes: 2 additions & 2 deletions tests/parse-fail/vec_no_size.fl.0.exp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Error: vec_no_size.fl(3,25): Expected vector size integer, but got '}'
Error: vec_no_size.fl(3,18): Expected vector size integer, but got 'int'
pub mod vec_no_size {
pub struct VecNoSize {
pub v : {int .. };
^
^
}
}
5 changes: 5 additions & 0 deletions tests/parse-fail/vec_no_type.fl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod vec_no_size {
pub struct VecNoSize {
pub v : {42 .. };
}
}
7 changes: 7 additions & 0 deletions tests/parse-fail/vec_no_type.fl.0.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Error: vec_no_type.fl(3,24): Expected type signature, but got '}'
pub mod vec_no_size {
pub struct VecNoSize {
pub v : {42 .. };
^
}
}
6 changes: 3 additions & 3 deletions tests/parse-pass/vector_types.fl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod vector_types {
pub struct VectorTypes {
pub a : {int .. 32};
pub b : {foo .. 123456789};
pub c : {(foo, bar) .. 4};
pub a : {32 .. int};
pub b : {123456789 .. foo};
pub c : {4 .. (foo, bar)};
}
}
32 changes: 16 additions & 16 deletions tests/parse-pass/vector_types.fl.0.exp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ module_declaration (1,5) [ "pub" (1,1), "mod" (1,5), "{" (1,22), "}" (7,1) ]
simple_name (3,13) [ "a" (3,13) ]
{
}
vector_type (3,17) [ "{" (3,17), ".." (3,22), "32" (3,25), "}" (3,27) ]
vector_type (3,17) [ "{" (3,17), ".." (3,21), "32" (3,18), "}" (3,27) ]
{
nominal_type (3,18) [ ]
nominal_type (3,24) [ ]
{
qualified_name (3,18) [ ]
qualified_name (3,24) [ ]
{
simple_name (3,18) [ "int" (3,18) ]
simple_name (3,24) [ "int" (3,24) ]
{
}
}
Expand All @@ -34,13 +34,13 @@ module_declaration (1,5) [ "pub" (1,1), "mod" (1,5), "{" (1,22), "}" (7,1) ]
simple_name (4,13) [ "b" (4,13) ]
{
}
vector_type (4,17) [ "{" (4,17), ".." (4,22), "123456789" (4,25), "}" (4,34) ]
vector_type (4,17) [ "{" (4,17), ".." (4,28), "123456789" (4,18), "}" (4,34) ]
{
nominal_type (4,18) [ ]
nominal_type (4,31) [ ]
{
qualified_name (4,18) [ ]
qualified_name (4,31) [ ]
{
simple_name (4,18) [ "foo" (4,18) ]
simple_name (4,31) [ "foo" (4,31) ]
{
}
}
Expand All @@ -52,24 +52,24 @@ module_declaration (1,5) [ "pub" (1,1), "mod" (1,5), "{" (1,22), "}" (7,1) ]
simple_name (5,13) [ "c" (5,13) ]
{
}
vector_type (5,17) [ "{" (5,17), ".." (5,29), "4" (5,32), "}" (5,33) ]
vector_type (5,17) [ "{" (5,17), ".." (5,20), "4" (5,18), "}" (5,33) ]
{
tuple_type (5,18) [ "(" (5,18), "," (5,22), ")" (5,27) ]
tuple_type (5,23) [ "(" (5,23), "," (5,27), ")" (5,32) ]
{
nominal_type (5,19) [ ]
nominal_type (5,24) [ ]
{
qualified_name (5,19) [ ]
qualified_name (5,24) [ ]
{
simple_name (5,19) [ "foo" (5,19) ]
simple_name (5,24) [ "foo" (5,24) ]
{
}
}
}
nominal_type (5,24) [ ]
nominal_type (5,29) [ ]
{
qualified_name (5,24) [ ]
qualified_name (5,29) [ ]
{
simple_name (5,24) [ "bar" (5,24) ]
simple_name (5,29) [ "bar" (5,29) ]
{
}
}
Expand Down

0 comments on commit 9d6fa12

Please sign in to comment.