Mercurial > octave-dspies
comparison src/lex.l @ 3208:e8a7163701be
[project @ 1998-11-03 05:12:47 by jwe]
author | jwe |
---|---|
date | Tue, 03 Nov 1998 05:12:48 +0000 |
parents | 81738e630f57 |
children | 3deb1105fbc1 |
comparison
equal
deleted
inserted
replaced
3207:dddfaa93a99c | 3208:e8a7163701be |
---|---|
1611 } | 1611 } |
1612 | 1612 |
1613 return LEXICAL_ERROR; | 1613 return LEXICAL_ERROR; |
1614 } | 1614 } |
1615 | 1615 |
1616 static bool | |
1617 next_token_is_assign_op (void) | |
1618 { | |
1619 bool retval = false; | |
1620 | |
1621 int c0 = yyinput (); | |
1622 | |
1623 switch (c0) | |
1624 { | |
1625 case '=': | |
1626 { | |
1627 int c1 = yyinput (); | |
1628 unput (c1); | |
1629 if (c1 != '=') | |
1630 retval = true; | |
1631 } | |
1632 break; | |
1633 | |
1634 case '+': | |
1635 case '-': | |
1636 case '*': | |
1637 case '/': | |
1638 case '\\': | |
1639 case '&': | |
1640 case '|': | |
1641 { | |
1642 int c1 = yyinput (); | |
1643 unput (c1); | |
1644 if (c1 == '=') | |
1645 retval = true; | |
1646 } | |
1647 break; | |
1648 | |
1649 case '.': | |
1650 { | |
1651 int c1 = yyinput (); | |
1652 if (match_any (c1, "+-*/\\")) | |
1653 { | |
1654 int c2 = yyinput (); | |
1655 unput (c2); | |
1656 if (c2 == '=') | |
1657 retval = true; | |
1658 } | |
1659 unput (c1); | |
1660 } | |
1661 break; | |
1662 | |
1663 case '>': | |
1664 { | |
1665 int c1 = yyinput (); | |
1666 if (c1 == '>') | |
1667 { | |
1668 int c2 = yyinput (); | |
1669 unput (c2); | |
1670 if (c2 == '=') | |
1671 retval = true; | |
1672 } | |
1673 unput (c1); | |
1674 } | |
1675 break; | |
1676 | |
1677 case '<': | |
1678 { | |
1679 int c1 = yyinput (); | |
1680 if (c1 == '<') | |
1681 { | |
1682 int c2 = yyinput (); | |
1683 unput (c2); | |
1684 if (c2 == '=') | |
1685 retval = true; | |
1686 } | |
1687 unput (c1); | |
1688 } | |
1689 break; | |
1690 | |
1691 default: | |
1692 break; | |
1693 } | |
1694 | |
1695 unput (c0); | |
1696 | |
1697 return retval; | |
1698 } | |
1699 | |
1616 static int | 1700 static int |
1617 handle_close_brace (int spc_gobbled) | 1701 handle_close_brace (int spc_gobbled) |
1618 { | 1702 { |
1703 int retval = ']'; | |
1704 | |
1619 if (! nesting_level.none ()) | 1705 if (! nesting_level.none ()) |
1620 { | 1706 { |
1621 nesting_level.remove (); | 1707 nesting_level.remove (); |
1622 lexer_flags.braceflag--; | 1708 lexer_flags.braceflag--; |
1623 } | 1709 } |
1624 | 1710 |
1625 if (lexer_flags.braceflag == 0) | 1711 if (lexer_flags.braceflag == 0) |
1626 BEGIN 0; | 1712 BEGIN 0; |
1627 | 1713 |
1628 // XXX FIXME XXX -- this needs to handle +=, -=, etc. | 1714 if (next_token_is_assign_op () && ! lexer_flags.looking_at_return_list) |
1629 | 1715 { |
1630 int c1 = yyinput (); | 1716 retval = CLOSE_BRACE; |
1631 if (c1 == '=') | |
1632 { | |
1633 lexer_flags.quote_is_transpose = false; | |
1634 lexer_flags.cant_be_identifier = false; | |
1635 lexer_flags.convert_spaces_to_comma = true; | |
1636 | |
1637 int c2 = yyinput (); | |
1638 unput (c2); | |
1639 unput (c1); | |
1640 | |
1641 if (c2 == '=' || lexer_flags.looking_at_return_list) | |
1642 return ']'; | |
1643 else | |
1644 return CLOSE_BRACE; | |
1645 } | 1717 } |
1646 else | 1718 else |
1647 { | 1719 { |
1720 int c1 = yyinput (); | |
1648 unput (c1); | 1721 unput (c1); |
1649 | 1722 |
1650 if (lexer_flags.braceflag && Vwhitespace_in_literal_matrix != 2) | 1723 if (lexer_flags.braceflag && Vwhitespace_in_literal_matrix != 2) |
1651 { | 1724 { |
1652 int bin_op = next_token_is_bin_op (spc_gobbled, yytext); | 1725 int bin_op = next_token_is_bin_op (spc_gobbled, yytext); |
1666 } | 1739 } |
1667 | 1740 |
1668 lexer_flags.quote_is_transpose = true; | 1741 lexer_flags.quote_is_transpose = true; |
1669 lexer_flags.cant_be_identifier = false; | 1742 lexer_flags.cant_be_identifier = false; |
1670 lexer_flags.convert_spaces_to_comma = true; | 1743 lexer_flags.convert_spaces_to_comma = true; |
1671 return ']'; | 1744 |
1745 return retval; | |
1672 } | 1746 } |
1673 | 1747 |
1674 static void | 1748 static void |
1675 maybe_unput_comma (int spc_gobbled) | 1749 maybe_unput_comma (int spc_gobbled) |
1676 { | 1750 { |