48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
continue;
}
return;
}
}
optional< Term > Lexer::readToken()
{
skipSpacingIfAny();
if( !m_input.good() )
return nullopt;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
continue;
}
return;
}
}
Term Lexer::readStringLiteral( ir::Location&& loc )
{
string str;
bool complete = false;
// TODO this is very simplistic, at some point
// we'll want to handle escape characters etc.
while( m_input.good() )
{
auto c = m_input.get();
if( c == '"' )
{
complete = true;
break;
}
if( c == '\n' )
{
newLine();
break;
}
str += c;
}
ir::Term result( move( loc ), str );
if( !complete )
{
cout << result.location() << ": unterminated string literal.\n";
result.setFaulty();
}
return result;
}
optional< Term > Lexer::readToken()
{
skipSpacingIfAny();
if( !m_input.good() )
return nullopt;
|
83
84
85
86
87
88
89
90
91
92
93
|
case '[':
m_input.get();
return ir::Term( move( loc ), "["_sid );
case ']':
m_input.get();
return ir::Term( move( loc ), "]"_sid );
}
return nullopt;
}
|
>
>
>
>
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
case '[':
m_input.get();
return ir::Term( move( loc ), "["_sid );
case ']':
m_input.get();
return ir::Term( move( loc ), "]"_sid );
case '"':
m_input.get();
return readStringLiteral( move( loc ) );
}
return nullopt;
}
|