diff --git a/ets2panda/lexer/scripts/keywords.yaml b/ets2panda/lexer/scripts/keywords.yaml index e437a74c86ef070257cd8999feac3d91b4d110e4..b00c4eba8706674b2cc85ec2edf9d4c38a32e2f4 100644 --- a/ets2panda/lexer/scripts/keywords.yaml +++ b/ets2panda/lexer/scripts/keywords.yaml @@ -64,7 +64,7 @@ keywords: - name: 'bigint' token: KEYW_BIGINT - keyword_like: [ts] + keyword_like: [ets, ts] - name: 'boolean' token: KEYW_BOOLEAN @@ -317,7 +317,7 @@ keywords: - name: 'number' token: KEYW_NUMBER - keyword_like: [ts] + keyword_like: [ets, ts] - name: 'object' token: KEYW_OBJECT @@ -390,7 +390,7 @@ keywords: - name: 'string' token: KEYW_STRING - keyword_like: [ts] + keyword_like: [ets, ts] - name: 'struct' token: KEYW_STRUCT diff --git a/ets2panda/lexer/token/token.cpp b/ets2panda/lexer/token/token.cpp index cf4e3e30337f97d6a3d3e715a0d097643d4ce638..6804f7f3bff32975330902134a6541b66a6fea1f 100644 --- a/ets2panda/lexer/token/token.cpp +++ b/ets2panda/lexer/token/token.cpp @@ -84,10 +84,7 @@ bool Token::IsReservedTypeName() const case TokenType::KEYW_ANY: case TokenType::KEYW_UNKNOWN: case TokenType::KEYW_NEVER: - case TokenType::KEYW_NUMBER: - case TokenType::KEYW_BIGINT: case TokenType::KEYW_BOOLEAN: - case TokenType::KEYW_STRING: case TokenType::KEYW_VOID: case TokenType::KEYW_OBJECT: return true; @@ -107,6 +104,14 @@ bool Token::IsDefinableTypeName() const case TokenType::KEYW_INT: case TokenType::KEYW_CHAR: case TokenType::KEYW_LONG: + case TokenType::KEYW_UNDEFINED: + case TokenType::KEYW_VAR: + case TokenType::KEYW_IS: + case TokenType::KEYW_TYPEOF: + case TokenType::KEYW_YIELD: + case TokenType::KEYW_STRING: + case TokenType::KEYW_NUMBER: + case TokenType::KEYW_BIGINT: return true; default: return false; diff --git a/ets2panda/test/parser/ets/user_defined_10-expected.txt b/ets2panda/test/parser/ets/user_defined_10-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..efd8c3d9e8e1827409709e6e7e77c0aebb9f053e --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_10-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_10.ets:16:8] diff --git a/ets2panda/test/parser/ets/user_defined_10.ets b/ets2panda/test/parser/ets/user_defined_10.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9e1cfaf294d917e73d17b6a94e5b91d4f71f0d0 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_10.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct number{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_11-expected.txt b/ets2panda/test/parser/ets/user_defined_11-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..ccb37342889137a61e91e1380cef40bc89b8663e --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_11-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_11.ets:16:7] diff --git a/ets2panda/test/parser/ets/user_defined_11.ets b/ets2panda/test/parser/ets/user_defined_11.ets new file mode 100644 index 0000000000000000000000000000000000000000..81c6a8eba4fbc77a656bbce299100d03c182ec93 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_11.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class number{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_12-expected.txt b/ets2panda/test/parser/ets/user_defined_12-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..982182343689973849e5939078bd824b012b8de9 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_12-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_12.ets:16:7] diff --git a/ets2panda/test/parser/ets/user_defined_12.ets b/ets2panda/test/parser/ets/user_defined_12.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddf26139fea8c0a196e8dcfc18183342612f280f --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_12.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class yield{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_13-expected.txt b/ets2panda/test/parser/ets/user_defined_13-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..5f612f88730012121daabe8fe0d1f0069ada56da --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_13-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_13.ets:16:7] diff --git a/ets2panda/test/parser/ets/user_defined_13.ets b/ets2panda/test/parser/ets/user_defined_13.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a3731bd149279083248477e2ff41d5243087439 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_13.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class var{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_14-expected.txt b/ets2panda/test/parser/ets/user_defined_14-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..284028330d16a7664b4d73436610b57910e580b1 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_14-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_14.ets:16:7] diff --git a/ets2panda/test/parser/ets/user_defined_14.ets b/ets2panda/test/parser/ets/user_defined_14.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a029a471b85e0b84626d2b9b8140e4010411dda --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_14.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class typeof{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_15-expected.txt b/ets2panda/test/parser/ets/user_defined_15-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..7b9e0e15592a18eb9e7e9c8dcf8e313ba5d25624 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_15-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_15.ets:16:7] diff --git a/ets2panda/test/parser/ets/user_defined_15.ets b/ets2panda/test/parser/ets/user_defined_15.ets new file mode 100644 index 0000000000000000000000000000000000000000..6cbc42525aa85bbb4eea4198a06e6288774ebc4f --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_15.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class is{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_16-expected.txt b/ets2panda/test/parser/ets/user_defined_16-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..dc9ff85f0b4c747b25c6856c9d40584800fe4267 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_16-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_16.ets:16:8] diff --git a/ets2panda/test/parser/ets/user_defined_16.ets b/ets2panda/test/parser/ets/user_defined_16.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c8941f3c1ef26eec24b3bfec9b732e2b79193ad --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_16.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct is{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_17-expected.txt b/ets2panda/test/parser/ets/user_defined_17-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..df6fbce58c223b46909dd20d1da33f03291eb95e --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_17-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_17.ets:16:8] diff --git a/ets2panda/test/parser/ets/user_defined_17.ets b/ets2panda/test/parser/ets/user_defined_17.ets new file mode 100644 index 0000000000000000000000000000000000000000..72768b9dd6b37cbf9deefd20acd8178bf633be3f --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_17.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct var{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_18-expected.txt b/ets2panda/test/parser/ets/user_defined_18-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..2c1b7e257d928a3e59ac3f6ce85502cb921802f4 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_18-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_18.ets:16:8] diff --git a/ets2panda/test/parser/ets/user_defined_18.ets b/ets2panda/test/parser/ets/user_defined_18.ets new file mode 100644 index 0000000000000000000000000000000000000000..43394973d9eb1a1cff3050089c075c7693bd7848 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_18.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct yield{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_19-expected.txt b/ets2panda/test/parser/ets/user_defined_19-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9ccabf77dc7cd4ab6975ecf6bfa6304b28d92267 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_19-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_19.ets:16:8] diff --git a/ets2panda/test/parser/ets/user_defined_19.ets b/ets2panda/test/parser/ets/user_defined_19.ets new file mode 100644 index 0000000000000000000000000000000000000000..764039bc9c734137a69e7c5f5824796fe3e73048 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_19.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct typeof{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_20-expected.txt b/ets2panda/test/parser/ets/user_defined_20-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4b63249df42de83afb9e4b6c83affa5d14923be8 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_20-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_20.ets:16:8] diff --git a/ets2panda/test/parser/ets/user_defined_20.ets b/ets2panda/test/parser/ets/user_defined_20.ets new file mode 100644 index 0000000000000000000000000000000000000000..602a2bbcd8de8a9c9f08ef4a1112748bab1bfb74 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_20.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct bigint{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_21-expected.txt b/ets2panda/test/parser/ets/user_defined_21-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..0b71c4d3a4617a64642c04101b3524c1f75da4e8 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_21-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_21.ets:16:7] diff --git a/ets2panda/test/parser/ets/user_defined_21.ets b/ets2panda/test/parser/ets/user_defined_21.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb13f23e66f3ac7127f20a46bb3058ae3d4468a6 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_21.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class bigint{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_8-expected.txt b/ets2panda/test/parser/ets/user_defined_8-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c5113c1b0c575621bf34f9d4c25ab894d1bedc3f --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_8-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_8.ets:16:8] diff --git a/ets2panda/test/parser/ets/user_defined_8.ets b/ets2panda/test/parser/ets/user_defined_8.ets new file mode 100644 index 0000000000000000000000000000000000000000..49550fffd7788b7206d4c412b22ec665e15063da --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_8.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +struct string{ + a : string = "15"; +} diff --git a/ets2panda/test/parser/ets/user_defined_9-expected.txt b/ets2panda/test/parser/ets/user_defined_9-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..a89aa4ff1942b52beadb2749065bf0c0f048d443 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_9-expected.txt @@ -0,0 +1 @@ +SyntaxError: Cannot be used as user-defined type. [user_defined_9.ets:16:7] diff --git a/ets2panda/test/parser/ets/user_defined_9.ets b/ets2panda/test/parser/ets/user_defined_9.ets new file mode 100644 index 0000000000000000000000000000000000000000..7ccd121781a84b5c1888a46e12fd28e972562679 --- /dev/null +++ b/ets2panda/test/parser/ets/user_defined_9.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class string{ + a : string = "15"; +}