@@ -827,11 +827,13 @@ Parser2::parsePrimary()
827827 return parseString ();
828828 case TokenKind::IDENTIFIER:
829829 return parseIdentifier ();
830+ case TokenKind::LIST:
831+ return parseList ();
830832 default :
831833 errorhandler->handle (
832834 new Error2 (currentToken->col , currentToken->line ,
833835 " Expected a valid primary token such as a boolean, "
834- " integer, float, string, or identifier ." ,
836+ " integer, float, string, identifier, or list ." ,
835837 " Received: " , currentToken->value ,
836838 " of type " + displayKind (currentToken->kind ) + " ." ));
837839 return parseIdentifier (); // unreachable
@@ -844,6 +846,8 @@ Parser2::parsePrimary()
844846std::shared_ptr<LeafLexeme>
845847Parser2::parseType ()
846848{
849+ if (currentToken->kind == TokenKind::LISTTYPE)
850+ return parseListType ();
847851 return parseIdentifier ();
848852}
849853
@@ -914,3 +918,25 @@ Parser2::parseString()
914918 advanceAndCheckToken (TokenKind::STRING); // eat string
915919 return makeLeaf (LIT::STRING, v);
916920}
921+
922+ /* *
923+ * List := lexvalue
924+ */
925+ std::shared_ptr<LeafLexeme>
926+ Parser2::parseList ()
927+ {
928+ auto v = currentToken->value ;
929+ advanceAndCheckToken (TokenKind::LIST); // eat list
930+ return makeLeaf (LIT::LIST, v);
931+ }
932+
933+ /* *
934+ * ListType := lexvalue
935+ */
936+ std::shared_ptr<LeafLexeme>
937+ Parser2::parseListType ()
938+ {
939+ auto v = currentToken->value ;
940+ advanceAndCheckToken (TokenKind::LISTTYPE); // eat list type
941+ return makeLeaf (LIT::LISTTYPE, v);
942+ }
0 commit comments