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:
parent
823f2f1bad
commit
9955f61bcb
|
@ -178,10 +178,10 @@ module Oga
|
||||||
|
|
||||||
# Whitespace preceding these tokens is _not_ matched to make the parser
|
# Whitespace preceding these tokens is _not_ matched to make the parser
|
||||||
# rules more consistent. As such input such as " > x" will result in
|
# rules more consistent. As such input such as " > x" will result in
|
||||||
# tokens [T_SPACE, T_CHILD, T_IDENT].
|
# tokens [T_SPACE, T_GREATER, T_IDENT].
|
||||||
op_child = '>' whitespace*;
|
op_greater = '>' whitespace*;
|
||||||
op_fol_direct = '+' whitespace*;
|
op_plus = '+' whitespace*;
|
||||||
op_fol = '~' whitespace*;
|
op_tilde = '~' whitespace*;
|
||||||
|
|
||||||
# Numbers
|
# Numbers
|
||||||
#
|
#
|
||||||
|
@ -301,9 +301,9 @@ module Oga
|
||||||
main := |*
|
main := |*
|
||||||
hash | dot | colon;
|
hash | dot | colon;
|
||||||
|
|
||||||
op_child => { add_token(:T_CHILD) };
|
op_greater => { add_token(:T_GREATER) };
|
||||||
op_fol_direct => { add_token(:T_FOLLOWING_DIRECT) };
|
op_plus => { add_token(:T_PLUS) };
|
||||||
op_fol => { add_token(:T_FOLLOWING) };
|
op_tilde => { add_token(:T_TILDE) };
|
||||||
|
|
||||||
lbrack => emit_lbrack;
|
lbrack => emit_lbrack;
|
||||||
pipe => emit_pipe;
|
pipe => emit_pipe;
|
||||||
|
|
|
@ -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_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_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
|
token T_NTH T_INT T_STRING T_ODD T_EVEN T_DOT T_HASH
|
||||||
|
|
||||||
options no_result_var
|
options no_result_var
|
||||||
|
|
||||||
prechigh
|
prechigh
|
||||||
left T_COLON T_HASH T_DOT
|
left T_COLON T_HASH T_DOT
|
||||||
left T_CHILD T_FOLLOWING T_FOLLOWING_DIRECT
|
left T_GREATER T_TILDE T_PLUS
|
||||||
preclow
|
preclow
|
||||||
|
|
||||||
rule
|
rule
|
||||||
|
@ -41,9 +41,9 @@ rule
|
||||||
;
|
;
|
||||||
|
|
||||||
axis
|
axis
|
||||||
: T_CHILD axis_selector { s(:axis, 'child', val[1]) }
|
: T_GREATER axis_selector { s(:axis, 'child', val[1]) }
|
||||||
| T_FOLLOWING axis_selector { s(:axis, 'following', val[1]) }
|
| T_TILDE axis_selector { s(:axis, 'following', val[1]) }
|
||||||
| T_FOLLOWING_DIRECT axis_selector { s(:axis, 'following-direct', val[1]) }
|
| T_PLUS axis_selector { s(:axis, 'following-direct', val[1]) }
|
||||||
;
|
;
|
||||||
|
|
||||||
axis_selector
|
axis_selector
|
||||||
|
|
|
@ -3,52 +3,52 @@ require 'spec_helper'
|
||||||
describe Oga::CSS::Lexer do
|
describe Oga::CSS::Lexer do
|
||||||
context 'axes' do
|
context 'axes' do
|
||||||
example 'lex the > axis' do
|
example 'lex the > axis' do
|
||||||
lex_css('>').should == [[:T_CHILD, nil]]
|
lex_css('>').should == [[:T_GREATER, nil]]
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'lex the expression "> y"' do
|
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
|
end
|
||||||
|
|
||||||
example 'lex the expression "x > y"' do
|
example 'lex the expression "x > y"' do
|
||||||
lex_css('x > y').should == [
|
lex_css('x > y').should == [
|
||||||
[:T_IDENT, 'x'],
|
[:T_IDENT, 'x'],
|
||||||
[:T_SPACE, nil],
|
[:T_SPACE, nil],
|
||||||
[:T_CHILD, nil],
|
[:T_GREATER, nil],
|
||||||
[:T_IDENT, 'y']
|
[:T_IDENT, 'y']
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'lex the + axis' do
|
example 'lex the + axis' do
|
||||||
lex_css('+').should == [[:T_FOLLOWING_DIRECT, nil]]
|
lex_css('+').should == [[:T_PLUS, nil]]
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'lex the expression "+ y"' do
|
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
|
end
|
||||||
|
|
||||||
example 'lex the expression "x + y"' do
|
example 'lex the expression "x + y"' do
|
||||||
lex_css('x + y').should == [
|
lex_css('x + y').should == [
|
||||||
[:T_IDENT, 'x'],
|
[:T_IDENT, 'x'],
|
||||||
[:T_SPACE, nil],
|
[:T_SPACE, nil],
|
||||||
[:T_FOLLOWING_DIRECT, nil],
|
[:T_PLUS, nil],
|
||||||
[:T_IDENT, 'y']
|
[:T_IDENT, 'y']
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'lex the ~ axis' do
|
example 'lex the ~ axis' do
|
||||||
lex_css('~').should == [[:T_FOLLOWING, nil]]
|
lex_css('~').should == [[:T_TILDE, nil]]
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'lex the expression "~ y"' do
|
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
|
end
|
||||||
|
|
||||||
example 'lex the expression "x ~ y"' do
|
example 'lex the expression "x ~ y"' do
|
||||||
lex_css('x ~ y').should == [
|
lex_css('x ~ y').should == [
|
||||||
[:T_IDENT, 'x'],
|
[:T_IDENT, 'x'],
|
||||||
[:T_SPACE, nil],
|
[:T_SPACE, nil],
|
||||||
[:T_FOLLOWING, nil],
|
[:T_TILDE, nil],
|
||||||
[:T_IDENT, 'y']
|
[:T_IDENT, 'y']
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue