Renamed CSS axis tokens.

These have been renamed as following:

T_CHILD => T_GREATER
T_FOLLOWING => T_TILDE
T_FOLLOWING_DIRECT => T_PLUS
This commit is contained in:
Yorick Peterse 2014-10-21 23:25:11 +02:00
parent 823f2f1bad
commit 9955f61bcb
3 changed files with 21 additions and 21 deletions

View File

@ -178,10 +178,10 @@ module Oga
# Whitespace preceding these tokens is _not_ matched to make the parser
# rules more consistent. As such input such as " > x" will result in
# tokens [T_SPACE, T_CHILD, T_IDENT].
op_child = '>' whitespace*;
op_fol_direct = '+' whitespace*;
op_fol = '~' whitespace*;
# tokens [T_SPACE, T_GREATER, T_IDENT].
op_greater = '>' whitespace*;
op_plus = '+' whitespace*;
op_tilde = '~' whitespace*;
# Numbers
#
@ -301,9 +301,9 @@ module Oga
main := |*
hash | dot | colon;
op_child => { add_token(:T_CHILD) };
op_fol_direct => { add_token(:T_FOLLOWING_DIRECT) };
op_fol => { add_token(:T_FOLLOWING) };
op_greater => { add_token(:T_GREATER) };
op_plus => { add_token(:T_PLUS) };
op_tilde => { add_token(:T_TILDE) };
lbrack => emit_lbrack;
pipe => emit_pipe;

View File

@ -5,14 +5,14 @@ class Oga::CSS::Parser
token T_IDENT T_PIPE T_LBRACK T_RBRACK T_COLON T_SPACE T_LPAREN T_RPAREN T_MINUS
token T_EQ T_SPACE_IN T_STARTS_WITH T_ENDS_WITH T_IN T_HYPHEN_IN
token T_CHILD T_FOLLOWING T_FOLLOWING_DIRECT
token T_GREATER T_TILDE T_PLUS
token T_NTH T_INT T_STRING T_ODD T_EVEN T_DOT T_HASH
options no_result_var
prechigh
left T_COLON T_HASH T_DOT
left T_CHILD T_FOLLOWING T_FOLLOWING_DIRECT
left T_GREATER T_TILDE T_PLUS
preclow
rule
@ -41,9 +41,9 @@ rule
;
axis
: T_CHILD axis_selector { s(:axis, 'child', val[1]) }
| T_FOLLOWING axis_selector { s(:axis, 'following', val[1]) }
| T_FOLLOWING_DIRECT axis_selector { s(:axis, 'following-direct', val[1]) }
: T_GREATER axis_selector { s(:axis, 'child', val[1]) }
| T_TILDE axis_selector { s(:axis, 'following', val[1]) }
| T_PLUS axis_selector { s(:axis, 'following-direct', val[1]) }
;
axis_selector

View File

@ -3,52 +3,52 @@ require 'spec_helper'
describe Oga::CSS::Lexer do
context 'axes' do
example 'lex the > axis' do
lex_css('>').should == [[:T_CHILD, nil]]
lex_css('>').should == [[:T_GREATER, nil]]
end
example 'lex the expression "> y"' do
lex_css('> y').should == [[:T_CHILD, nil], [:T_IDENT, 'y']]
lex_css('> y').should == [[:T_GREATER, nil], [:T_IDENT, 'y']]
end
example 'lex the expression "x > y"' do
lex_css('x > y').should == [
[:T_IDENT, 'x'],
[:T_SPACE, nil],
[:T_CHILD, nil],
[:T_GREATER, nil],
[:T_IDENT, 'y']
]
end
example 'lex the + axis' do
lex_css('+').should == [[:T_FOLLOWING_DIRECT, nil]]
lex_css('+').should == [[:T_PLUS, nil]]
end
example 'lex the expression "+ y"' do
lex_css('+ y').should == [[:T_FOLLOWING_DIRECT, nil], [:T_IDENT, 'y']]
lex_css('+ y').should == [[:T_PLUS, nil], [:T_IDENT, 'y']]
end
example 'lex the expression "x + y"' do
lex_css('x + y').should == [
[:T_IDENT, 'x'],
[:T_SPACE, nil],
[:T_FOLLOWING_DIRECT, nil],
[:T_PLUS, nil],
[:T_IDENT, 'y']
]
end
example 'lex the ~ axis' do
lex_css('~').should == [[:T_FOLLOWING, nil]]
lex_css('~').should == [[:T_TILDE, nil]]
end
example 'lex the expression "~ y"' do
lex_css('~ y').should == [[:T_FOLLOWING, nil], [:T_IDENT, 'y']]
lex_css('~ y').should == [[:T_TILDE, nil], [:T_IDENT, 'y']]
end
example 'lex the expression "x ~ y"' do
lex_css('x ~ y').should == [
[:T_IDENT, 'x'],
[:T_SPACE, nil],
[:T_FOLLOWING, nil],
[:T_TILDE, nil],
[:T_IDENT, 'y']
]
end